I’m trying to set mode to Guided via MAVLink command but it fails. Following is my code
mavlink_msg_command_long_pack(mavlink_system.sysid, mavlink_system.compid, &msg, targetSysId, targetCompId, MAV_CMD_DO_SET_MODE, 0, MAV_MODE_GUIDED_ARMED, 0, 0, 0, 0, 0, 0);
len = mavlink_msg_to_send_buffer(buf, &msg);
I also tried MAV_MODE_GUIDED_DISARMED
but in both cases the result is
Got MAVLink msg: COMMAND_ACK {command : 176, result : 3}
which means MAV_MISSION_UNSUPPORTED
. How can I fix this?
I’m also trying to fly the drone to a position relative to the current position of the drone, i.e., moving to just one waypoint and not doing a full mission. I thought that SET_POSITION_TARGET_LOCAL_NED
is the way to do it but it didn’t work. Then I tried to follow the instructions here and here. Here is my code:
uint16_t targetSysId = 1;
uint16_t targetCompId = 1;
void mavMissionCount(uint8_t count)
{
mavlink_msg_mission_count_pack(mavlink_system.sysid, mavlink_system.compid, &msg, targetSysId, targetCompId, count);
len = mavlink_msg_to_send_buffer(buf, &msg);
//Sending
}
void mavMissionClearAll(void)
{
mavlink_msg_mission_clear_all_pack(mavlink_system.sysid, mavlink_system.compid, &msg, targetSysId, targetCompId);
len = mavlink_msg_to_send_buffer(buf, &msg);
//Sending
}
void mavMissionItem(int32_t xNed, int32_t yNed, int32_t zNed)
{
mavlink_msg_mission_item_pack(mavlink_system.sysid, mavlink_system.compid, &msg, targetSysId, targetCompId, 1, MAV_FRAME_LOCAL_OFFSET_NED, MAV_CMD_NAV_WAYPOINT, 1, 1, 0, 2, 0, NAN, xNed, yNed, zNed);
len = mavlink_msg_to_send_buffer(buf, &msg);
//Sending
}
int main(void)
{
mavlink_system.sysid = 20;
mavlink_system.compid = 20;
...
mavMissionClearAll();
mavMissionCount(1);
mavReceive();
//mavMissionItem(5, 0, 0);
...
}
But the output on MAVProxy console is
Got MAVLink msg: MISSION_ACK {target_system : 20, target_component : 200, type : 0}
not loading waypoints
Got MAVLink msg: MISSION_ACK {target_system : 1, target_component : 1, type : 0}
APM: Flight plan received
Got MAVLink msg: MISSION_ACK {target_system : 1, target_component : 1, type : 1}
And I receive COMMAND_ACK
from MAVProxy and not MISSION_REQUEST
.
Also, when I tried to get HEARTBEAT before sending these messages, I didn’t receive anything from MAVProxy
How can I fix this? And is sending waypoint the only way to do it? As I said this is not an auto mission, it’s just moving from current position to another and that’s it.
Many thanks