Guided_NoGPS Filght Mode

HI everyone,
On the Ardupilot document, it mentioned about the Guided_NoGPS. But I don’t know how to switch to that mode and send position or velocity command on it? Does everyone know how to do that? Thanks for your help !

Changing to that mode is done as changing to any other mode. The mode number is 20.
You can’t send position or velocity to this mode, it only accepts attitude (and altitude) messages.

Hi @OXINARF,
Here is my code to change to STABILIZE mode :
" sm = n.serviceClient<mavros_msgs::SetMode>("/mavros/set_mode");

srv_setMode.request.base_mode = 0;  // 0 for setup the custom mode
srv_setMode.request.custom_mode = "STABILIZE";  

"
What does the data format of attitude? If I want to change to the GUIDED_NoGPS, I just change “custom_mode” to 20 as I said ?. Also, how could I publish the attitude message? What is topic I should publish to ? Also, I tried to change mode in mavproxy to 20 (type “mode 20”), but it doesn’t work.Thanks.

John,
I haven’t used mavros but hopefully, as you say, you can set the custom_mode to “20”. It’s also possible that we need to modify mavros to know how to convert “GUIDE_NoGPS” to “20”.
To set the attitude target the SET_ATTITUDE_TARGET mavlink message needs to be sent (http://mavlink.org/messages/common#SET_ATTITUDE_TARGET). I’m not sure how mavros sends that message but I’m pretty sure there is a way.

By the way, in a more general sense, I’m keen to improve ArduPilot’s support of ROS so very happy to try and help resolve any issues in this area.

Hi John,

I didn’t know you were working with mavros so that can be a bit harder. I also haven’t worked with it (or ROS) so bear with me. For mode it looks like we need to update our names in mavros (https://github.com/mavlink/mavros/blob/master/mavros/src/lib/uas_stringify.cpp#L58), but it works with numbers too, so you can do srv_setMode.request.custom_mode = "20";

As for the attitude Randy already mentioned you need the SET_ATTITUDE_TARGET MAVLink message. mavros does have that message (https://github.com/mavlink/mavros/blob/master/mavros_msgs/msg/AttitudeTarget.msg) but I’m not sure how you use it. Since you seem to know ROS you can probably figure that out. If you can’t, please come back and we’ll try to help.

For MAVProxy, it should also work with both string and number. MAVProxy has great tab completion support so you can use that or just entering mode should show you all available modes.

Just to complement, it looks like you have two options for the attitude message:

HI @rmackay9 and @OXINARF ,
I’ve checked my APM version. it is APM:Copter V3.4-dev (fe724032). When I typed “mode” and then enter in MAVProxy, it showed:
('Available modes: ', [‘RTL’, ‘POSHOLD’, ‘LAND’, ‘OF_LOITER’, ‘STABILIZE’, ‘AUTO’, ‘GUIDED’, ‘DRIFT’, ‘FLIP’, ‘AUTOTUNE’, ‘ALT_HOLD’, ‘LOITER’, ‘POSITION’, ‘CIRCLE’, ‘SPORT’, ‘ACRO’])

Also, for the tab completion, it just shows “mode GUIDED”. When I typed “mode 20”, it shows

    "Got MAVLink msg: COMMAND_ACK {command : 11, result : 4}".

After I type “mode 20”, the mode didn’t change, it still keeps same.

Well, that explains it, you are using an old dev version. At that time, Guided NoGPS didn’t exist yet.

Hi @OXINARF,
So then, what’s APM version begins to use Guided_NoGPS ?

For official releases it started with 3.4, it was in master some time before that but I don’t know when exactly.

Hi @OXINARF,
My APM version showed that it’s 3.4 version. But it still doesn’t have it.

If it’s the version you posted, it is Copter-3.4-dev, which means it is a development version that lead to 3.4. From the Git hash you post it is from early March. 3.4 was only released in late October.

Hi @OXINARF,
Oh I see it. Just assume I got the 3.4 version with Guided_NoGPS and change the mode to 20. What command should I send in MAVProxy?

The support in MAVProxy for the SET_ATTITUDE_TARGET message is only for quaternion and thrust. The command is attitude and the usage for that is: Usage: attitude q0 q1 q2 q3 thrust (0~1)

1 Like

For thrust, (0 ~1 ) is Newton unit?

The description from the MAVLink spec says “Collective thrust, normalized to 0 … 1”. This is the throttle value normalized to 0-1, it will be converted to a PWM value (according to your calibrations) on output.

1 Like

I will test it. Thank for your help.

I’ve created a PR against mavros to add in the missing flight modes for copter and plane.

2 Likes