Skip to content

Commit e846ee0

Browse files
committed
Added bool for brushless to use arm feature.
1 parent 043cc6d commit e846ee0

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

interfaces/kr_crazyflie_interface/src/so3cmd_to_crazyflie_nodelet.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class SO3CmdToCrazyflie : public nodelet::Nodelet
5858
int thrust_pwm_max_; // Mapped to PWM
5959

6060
bool send_ctbr_cmds_;
61+
bool is_brushless_;
6162

6263
int motor_status_;
6364
bool armed_;
@@ -158,14 +159,18 @@ void SO3CmdToCrazyflie::so3_cmd_callback(const kr_mav_msgs::SO3Command::ConstPtr
158159
// switch on motors
159160
if(msg->aux.enable_motors)
160161
{
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_)
165167
{
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+
};
169174
};
170175

171176
// 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
196201
last_so3_cmd_time_ = msg->header.stamp;
197202

198203
// Disarm motors
199-
if(armed_)
204+
if(is_brushless_)
200205
{
201-
for(int i=0; i<1; i++)
206+
if(armed_)
202207
{
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+
};
208216
};
209217
return;
210218
}
@@ -313,6 +321,9 @@ void SO3CmdToCrazyflie::onInit(void)
313321
// get param for so3 command timeout duration
314322
priv_nh.param("so3_cmd_timeout", so3_cmd_timeout_, 0.1);
315323

324+
// get param for whether or not the crazyflie is of type brushless.
325+
priv_nh.param("is_brushless", is_brushless_, false);
326+
316327
// get param for sending ctbr cmds, default is to send TRPY commands as attitude
317328
priv_nh.param("send_ctbr_cmds", send_ctbr_cmds_, false);
318329

0 commit comments

Comments
 (0)