best option to control ArduCopter attitude from mavros

852 views
Skip to first unread message

Francois Chataigner

unread,
Oct 23, 2015, 9:41:56 AM10/23/15
to drones-discuss
Hi,

I'm very new to ardupilot and I am trying to issue dynamic setpoints to a quadrotor using ArduCopter and mavros. I want to control both position and attitude (yaw). I am testing using ardupilot SITL (ArduCopter sim_vehicle)

Position control works perfectly by publishing on the /setpoint_position/local topic in mavros which converts into SET_POSITION_TARGET mavlink messages.

For the attitude I tried sending SET_POSITION_ATTITUDE messages by publising on the /setpoint_attitude/attitude mavros topic. I had understood that the latest version of ArduCopter supports this:

https://github.com/diydrones/ardupilot/pull/2959#issuecomment-150538301

However this was giving me strange control and ultimately my waypoints were not being achieved. I can provide details/screenshots if required.

To work around this I tried to send CONDITION_YAW commands as explained here:

http://copter.ardupilot.com/wiki/mission-command-list/#Condition-Yaw

These work perfectly and I am able to control both position and attitude. I made a small change (locally) in ArduCopter to read the yaw from the SET_POSITION_TARGET and then trigger the yaw control using copter.set_auto_yaw_look_at_heading(). Details are in the github post above

I'm just wondering if this is the correct solution for my problem, and what the differences are between the different attitude control modes? Also I'm not sure why I wasn't able to control the yaw using the SET_POSITION_ATTITUDE messages.

Thank you,
Francois

Randy Mackay

unread,
Nov 24, 2015, 1:00:41 AM11/24/15
to drones-...@googlegroups.com

Francois,

 

     Sorry for missing this email.

 

     In short, yes, I think we should add support for the yaw and yaw_rate fields of the SET_POSITION_TARGET messages (http://mavlink.org/messages/common#SET_POSITION_TARGET_LOCAL_NED).  The solution you’ve come up with in the comments of the pull request looks pretty good to me (https://github.com/diydrones/ardupilot/pull/2959#issuecomment-150538301) so if you want to PR it I’ll pull it in.

 

     I suppose it’s also possible to allow the yaw to also be set with the SET_ATTITUDE_TARGET message but because you above fix resolves the issue, I’d prefer we just tell people to use that SET_POSITION_TARGET_ message.

 

     Thanks for the contribution!

 

-Randy

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Francois Chataigner

unread,
Nov 25, 2015, 9:17:55 AM11/25/15
to drones-discuss
Hi Randy,

Thanks for your reply! The reason I used SET_POSITION_TARGET_LOCAL_NED instead of SET_ATTITUDE_TARGET for the yaw request is that I wanted to be in line with mavros, which is the interface we use between MAVLINK and ROS -- it replaced mavlink_ros and I believe it is the most commonly used one? Since mavros is meant to be an abstract layer independent of the autopilot used underneath (I believe it was originally written for pixhawk), I think it makes sense to try and keep the interfaces consistent?

http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.setpoint_position

You can see in the doc above that mavros expects the yaw request is read from the setpoint_position topic

I'm happy to submit my changes for review/merge, though I'm new to both git and github so what is the process I should follow?

Kind regards,
Francois
Reply all
Reply to author
Forward
0 new messages