@@ -58,6 +58,7 @@ class SO3CmdToCrazyflie : public nodelet::Nodelet
58
58
int thrust_pwm_max_; // Mapped to PWM
59
59
60
60
bool send_ctbr_cmds_;
61
+ bool is_brushless_;
61
62
62
63
int motor_status_;
63
64
bool armed_;
@@ -158,14 +159,18 @@ void SO3CmdToCrazyflie::so3_cmd_callback(const kr_mav_msgs::SO3Command::ConstPtr
158
159
// switch on motors
159
160
if (msg->aux .enable_motors )
160
161
{
161
- // First try to arm the drone.
162
- if (!armed_)
163
- {
164
- for (int i=0 ; i<1 ; i++)
162
+
163
+ // First try to arm the drone.
164
+ if (is_brushless_) // Only do so if CF is brushless (rosparam)
165
+ {
166
+ if (!armed_)
165
167
{
166
- send_arming_request (true );
167
- }
168
- armed_ = true ;
168
+ for (int i=0 ; i<1 ; i++)
169
+ {
170
+ send_arming_request (true );
171
+ }
172
+ armed_ = true ;
173
+ };
169
174
};
170
175
171
176
// If the crazyflie motors are timed out, we need to send a zero message in order to get them to start
@@ -196,15 +201,18 @@ void SO3CmdToCrazyflie::so3_cmd_callback(const kr_mav_msgs::SO3Command::ConstPtr
196
201
last_so3_cmd_time_ = msg->header .stamp ;
197
202
198
203
// Disarm motors
199
- if (armed_ )
204
+ if (is_brushless_ )
200
205
{
201
- for ( int i= 0 ; i< 1 ; i++ )
206
+ if (armed_ )
202
207
{
203
- send_arming_request (false );
204
- }
205
- armed_ = false ;
206
- // Reboot Crazyflie to be armed again.
207
- reboot ();
208
+ for (int i=0 ; i<1 ; i++)
209
+ {
210
+ send_arming_request (false );
211
+ }
212
+ armed_ = false ;
213
+ // Reboot Crazyflie to be armed again.
214
+ reboot ();
215
+ };
208
216
};
209
217
return ;
210
218
}
@@ -313,6 +321,9 @@ void SO3CmdToCrazyflie::onInit(void)
313
321
// get param for so3 command timeout duration
314
322
priv_nh.param (" so3_cmd_timeout" , so3_cmd_timeout_, 0.1 );
315
323
324
+ // get param for whether or not the crazyflie is of type brushless.
325
+ priv_nh.param (" is_brushless" , is_brushless_, false );
326
+
316
327
// get param for sending ctbr cmds, default is to send TRPY commands as attitude
317
328
priv_nh.param (" send_ctbr_cmds" , send_ctbr_cmds_, false );
318
329
0 commit comments