MAV_CMD_NAV_WAYPOINT - with mavlink?


Im current build and arduino based follow me box, I've got my apm and arduin oboards talking nicely over mavlink, i can read and send heartbeats happily, I'm now try to send a MAV_CMD_NAV_WAYPOINT as explained  here. I'm now trying to send my apm a set of co-ordinates to travel to (to be an offset from the gps connected - not connected at present)

By looking some other code around, notably in the follow-me code from the github repo here.

I've created the following MAVLink command based off the official follow-me code using a 


uint8_t _target_system = 178; // Target drone id of 178
uint8_t _target_component = 0; // Target component, 0 = all

uint16_t seq = 0; // Sequence is always set to 0
uint8_t frame = MAV_FRAME_GLOBAL; // Set target frame to global default
uint16_t command = MAV_CMD_NAV_WAYPOINT; // Specific command for APM as it uses different paramters than the standard MAVLINK implementation
uint8_t current = 2; // Guided mode waypoint
uint8_t autocontinue = 0; // Always 0
float param1 = 0; // Loiter time
float param2 = 1; // Acceptable range from target - radius in meters
float param3 = 0; // Pass through waypoint
float param4 = 0; // Desired yaw angle
float x = 52.464217; // Latitude - degrees
float y = -1.280222; // Longitude - degrees
float z = 200; // Altitude - meters

// Initialize the required buffers
mavlink_message_t msg;

// Pack the message
// NOTE : _target_systen & _target_component are defined in setup
// found by searching mission item .h from mavlink library
mavlink_msg_mission_item_pack(sysid,compid, &msg, _target_system, _target_component, seq, frame, command, current, autocontinue, param1, param2, param3, param4, x, y, z);

// Copy the message to the send buffer
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);

I've intercepted the command using QGC and it looks like this;3691019812?profile=original

This however doesn't match exactly what the APM wants for a MAV_CMD_NAV_WAYPOINT, all the infomation the comand needs are there, but I am sending more information, will the APM just ignore this, and also do i have to fly in auto or guided mode?

I'm just looking for some clarification , specifically if I am correctly implement a MAV_CMD_NAV_WAYPOINT command within a mavlink_msg_mission_item packet?

Any help would be HUGELY appreciated,



You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • Hi, i have the same project as yours, can you please share with us the way you start, my problem is that i can't find libraries for mavlink on the arduino, i've found some but there is always an error somewhere, can you please post the libraries that you used.

    your help will be appreciated.

  • Matthew, I am interested in you work here. I am doing something similar and I have yet to understand exactly what the APM (Quadcopter in my case) wants in the mission_item message. I have formatted my messages very similar to the way you have. I have two questions for you. 

    1. have you successfully completed you project.

    2. What is the parameter 'current' supposed to be set to? I have seen a number of cases where it is set to 2 for guided mode waypoints though I don't see the documentation for this anywhere. In common.xml it says that the 'current' parameter is to be set to 0 or 1. Do you know why there is this discrepancy and can you point me in the right direction to understand it. 

    I would like to be able to send Waypoints to my copter no matter what type e.g. guided mode, follow me, or just a mission. Any information you can give would be helpful.

    Thanks, Aaron

    • Hello, I am currently working on a project quite similar to this as well?? I would please like to know if you succesfully completed yours. As I just have a few questions?

This reply was deleted.


Chris Anderson liked Zara Mae Pickering's profile
May 21
Azjeg liked Azjeg's profile
Apr 27
DIY Robocars via Twitter
RT @chr1sa: Donkeycar 4.4 released with tons of new features, including path learning (useful with GPS outdoors), better Web and Lidar supp…
Nov 27, 2022
DIY Robocars via Twitter
RT @NXP: We are already biting our nails in anticipation of the #NXPCupEMEA challenge! 😉 Did you know there are great cash prizes to be won…
Nov 24, 2022
DIY Robocars via Twitter
RT @gclue_akira: レースまであと3日。今回のコースは激ムズかも。あと一歩 #jetracer
Nov 24, 2022
DIY Robocars via Twitter
UC Berkeley's DIY robocar program
Nov 24, 2022
DIY Robocars via Twitter
RT @chr1sa: The next @DIYRobocars autonomous car race at @circuitlaunch will be on Sat, Dec 10. Thrills, spills and a Brazilian BBQ. Fun…
Nov 24, 2022
DIY Robocars via Twitter
RT @arthiak_tc: Donkey car platform ... Still training uses behavioral cloning #TCXpo #diyrobocar @OttawaAVGroup
Nov 20, 2022
DIY Robocars via Twitter
RT @emurmur77: Points for style. @donkeycar racing in @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video.…
Nov 20, 2022
DIY Robocars via Twitter
RT @SmallpixelCar: Going to @diyrobocars race at @UCSDJacobs
Nov 8, 2022
DIY Robocars via Twitter
RT @SmallpixelCar: Race @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video.
Nov 8, 2022
DIY Robocars via Twitter
RT @PiWarsRobotics: Presenting: the Hacky Racers Robotic Racing Series in collaboration with #PiWars. Find out more and register your inter…
Oct 23, 2022
DIY Robocars via Twitter
RT @Hacky_Racers: There will be three classes at this event: A4, A2, and Hacky Racer! A4 and A2 are based around UK paper sizing and existi…
Oct 23, 2022
DIY Robocars via Twitter
Oct 23, 2022
DIY Robocars via Twitter
Oct 19, 2022
DIY Robocars via Twitter
Oct 18, 2022