@@ -57,6 +57,8 @@ class SO3CmdToCrazyflie : public nodelet::Nodelet
5757 int thrust_pwm_min_; // Necessary to overcome stiction
5858 int thrust_pwm_max_; // Mapped to PWM
5959
60+ bool send_ctbr_cmds_;
61+
6062 int motor_status_;
6163 bool armed_;
6264 int arm_status_;
@@ -263,8 +265,13 @@ void SO3CmdToCrazyflie::so3_cmd_callback(const kr_mav_msgs::SO3Command::ConstPtr
263265 // TODO change this check to be a param
264266 // throttle the publish rate
265267 // if ((ros::Time::now() - last_so3_cmd_time_).toSec() > 1.0/30.0){
266- crazy_vel_cmd->linear .y = roll_des + msg->aux .angle_corrections [0 ];
267- crazy_vel_cmd->linear .x = pitch_des + msg->aux .angle_corrections [1 ];
268+ if (send_ctbr_cmds_) {
269+ crazy_vel_cmd->linear .y = msg->angular_velocity .x ; // ctbr_cmd->angular_velocity.x = roll rate
270+ crazy_vel_cmd->linear .x = msg->angular_velocity .y ; // ctbr_cmd->angular_velocity.y = pitch rate
271+ } else {
272+ crazy_vel_cmd->linear .y = roll_des + msg->aux .angle_corrections [0 ];
273+ crazy_vel_cmd->linear .x = pitch_des + msg->aux .angle_corrections [1 ];
274+ }
268275 crazy_vel_cmd->linear .z = CLAMP (thrust_pwm, thrust_pwm_min_, thrust_pwm_max_);
269276
270277 // ROS_INFO("commanded thrust is %2.2f", CLAMP(thrust_pwm, thrust_pwm_min_, thrust_pwm_max_));
@@ -306,6 +313,9 @@ void SO3CmdToCrazyflie::onInit(void)
306313 // get param for so3 command timeout duration
307314 priv_nh.param (" so3_cmd_timeout" , so3_cmd_timeout_, 0.1 );
308315
316+ // get param for sending ctbr cmds, default is to send TRPY commands as attitude
317+ priv_nh.param (" send_ctbr_cmds" , send_ctbr_cmds_, false );
318+
309319 priv_nh.param (" thrust_pwm_max" , thrust_pwm_max_, 60000 );
310320 priv_nh.param (" thrust_pwm_min" , thrust_pwm_min_, 10000 );
311321
0 commit comments