Guided_No_GPS and SET_ATTITUDE_TARGET Using MAVROS

Hello,

I am trying to be able to send commands via MavROS to my quad (Running 4.0.0) in order to make it take off, reach a desired altitude, take a desired heading and start flying forward.

My approach is: 1st enable Guided_No_GPS and then use SET_ATTITUDE_TARGET. How ever I am getting some problems:

a) I cannot enable Guided_No_GPS, I am using rosrun mavros mavsys mode - c 0 to change mode, it works for mode 0 (stabilize) and mode 1 (acro) but when I use mode 20 ( that is supposed to be Guided_No_GPS) I do not see any change when I do rostpic echo/mavros/state

b) I have studied this link https://mavlink.io/en/messages/common.html#SET_ATTITUDE_TARGET but I do not really understand how the structure works. If somebody could give an example of how to make the drone fly at 10 m from the ground heading south and be tilted 20 degrees in the pitch axis, it would be really helpful for me.

c) It is possible using SET_ATTITUDE_TARGET in for example Altitude hold mode?

Thank you in advance

I have solved the Guided_No_GPS Mode Issue.

But I am still stuck in this:

b) I have studied this link https://mavlink.io/en/messages/common.html#SET_ATTITUDE_TARGET but I do not really understand how the structure works. If somebody could give an example of how to make the drone fly at 10 m from the ground heading south and be tilted 20 degrees in the pitch axis, it would be really helpful for me.

If someone could help me to achieve this task with either MAVproxy/Dronkin or MAVROS I would really appreciate.

Why not try to get SET_ATTITUDE_TARGET working first on its own.

I’m not familiar with MAVROS but these are the fields of the command:

"time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_attitude_target_t, time_boot_ms) }, \
         { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_set_attitude_target_t, target_system) }, \
         { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_set_attitude_target_t, target_component) }, \
         { "type_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 38, offsetof(mavlink_set_attitude_target_t, type_mask) }, \
         { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 4, offsetof(mavlink_set_attitude_target_t, q) }, \
         { "body_roll_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_set_attitude_target_t, body_roll_rate) }, \
         { "body_pitch_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_set_attitude_target_t, body_pitch_rate) }, \
         { "body_yaw_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_set_attitude_target_t, body_yaw_rate) }, \
         { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_set_attitude_target_t, thrust) },

Look in mavlink_msg_set_attitude_target.h for more information. Hope this helps.