Control roll from mavros

Hi all,

I am trying to control the roll of a plane using mavros and in particular the topic /mavros/setpoint_attitude/attitude. This is basically the code I am using:
ros::Publisher mav_att_pub = nh.advertise<geometry_msgs::PoseStamped>( “mavros/setpoint_attitude/attitude”, 100 );
ros::Publisher mav_thr_pub = nh.advertise<std_msgs::Float64>( “mavros/setpoint_attitude/att_throttle”, 100 );

// attitude
geometry_msgs::PoseStamped cmd_att;
//throttle
std_msgs::Float64 cmd_thr;

// Create attitude command message
cmd_att.header.stamp = ros::Time::now();
cmd_att.header.seq = count;
cmd_att.pose.position.x = 0.0;
cmd_att.pose.position.y = 0.0;
cmd_att.pose.position.z = 0.0;

// here your desired angles
tf::Quaternion mav_orientation = tf::createQuaternionFromRPY( 0.6, 0, 0 );

cmd_att.pose.orientation.x = mav_orientation.x();
cmd_att.pose.orientation.y = mav_orientation.y();
cmd_att.pose.orientation.z = mav_orientation.z();
cmd_att.pose.orientation.w = mav_orientation.w();

mav_att_pub.publish( cmd_att );

// here your throttle value a [0,1]
cmd_thr.data = 0.8;

mav_thr_pub.publish( cmd_thr );

++count;

I hardcoded some values just to try but unfortunately the plane does not respond to these messages. I am currently using the SITL. I tried with mode AUTO and GUIDED but the plane still do not respond to the messages.

I have also set the parameter setpoint_attitude/use_quaternion to true as described here http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.setpoint_attitude.

I am using the latest ardupilot code (master) from github.

I am very new to mavros/ardupilot so any help would be appreciated.
Thanks!

1 Like

Did you solve that issue?