New version of Mega Posted

This is a new version of Mega for Alpha testers to try out. Please use this thread to let me know if you are having issue or questions.


Things left to do:
- Move the Reverse servo functions to the hardware switches
- finish binary GCS
- uplink parser
- magnetometer support
- better integration of baro sensor

What this release has:
- A complete waypoint command set including Auto Launch, Loiter N times, Loiter N seconds, Land, etc.
- missed waypoint detection
- All flight modes are available.
- Xplane integration with the IMU library for tetsing
- a Waypoint Writer for manually uploading commands - sorry, no GCS yet!

Here are the commands:

CMD_WAYPOINT   - normal autopilot waypoints
CMD_LOITER - enter Loiter mode around the specified coordinates
CMD_LOITER_N_TURNS - enter Loiter mode around the specified coordinates N times
CMD_LOITER_TIME - enter Loiter mode around the specified coordinates N seconds
CMD_RTL - enter RTL mode - come home
CMD_LAND_WP - enter landing mode, got to the specified coordinates
CMD_TAKEOFF - enter takeoff mode, height and pitch defined

CMD_CH_MODE - change flight mode - see defines for corresponding numbers
CMD_RESET_INDEX - start over waypoint commands
CMD_GETVAR_INDEX - return the variable referenced by an index code
CMD_SENDVAR_INDEX - send a variable value referenced by an index code
CMD_TELEMETRY - toggle telemetry on or off

CMD_THROTTLE_CRUISE - set the value of the throttle for cruising
CMD_AIRSPEED_CRUISE - set the value of the target airspeed in meters/second
CMD_LAND - set the pitch, target airspeed, and throttle cruise for landing
CMD_RESET_HOME - resets home to current location

CMD_PAYLOAD_0 - not implemented
CMD_PAYLOAD_1 - not implemented

CMD_KP_GAIN - set the value
CMD_KI_GAIN - set the value
CMD_KD_GAIN - set the value
CMD_KI_MAX - set the value
CMD_KFF_GAIN - set the value
CMD_RADIO_TRIM - set the value
CMD_RADIO_MAX - set the value
CMD_RADIO_MIN - set the value

Here is an example of a command set to launch, loiter 4 times and land. I used special CMD_LAND_WP waypoints for two reasons. They keep the flight mode in "Land" which lets me override the pitch with my own special value. Then it lets me stage my landing in multiple steps. As I reach each waypoint, the next CMD_LAND function is executed and I pitch the nose up and cut the throttle at the last minute.

// 1 pitch 20°, Altitude meters
CMD_TAKEOFF, 20, 0, 0, 100
// 2 Loiter 4 turns around this waypoint
CMD_LOITER_N_TURNS, 4, 37.621392, -122.374660, 80
// 3 Extra point for line up
CMD_WAYPOINT, 0, 37.622354, -122.378007, 40
// 4 Pitch 20°, reduce airspeed to 10 m/s, throttle to 30%, track WP on
CMD_LAND, 20, 10, 30, 1
// 5 This is a special intra-waypoint to keep us in landing mode
CMD_LAND_WP, 0, 37.623880, -122.381736, 30
// 6 Pitch 20°, reduce airspeed to 5 m/s, throttle to 0%, track WP on
CMD_LAND, 20, 5, 0, 1
// 7 This is a special intra-waypoint to keep us in landing mode
CMD_LAND_WP, 0, 37.626073, -122.387028, 20
// 8 Pitch 30°, reduce airspeed to 0 m/s, throttle to 0%, track WP off
CMD_LAND, 30, 0, 0, 0
// 9 our final destination
CMD_LAND_WP, 0, 37.628123, -122.392101, 0

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

Join diydrones

Email me when people reply –


  • It looks like there is a mismatch between the APM_Config.h.example and config.h

    The example file states:
    // The default is to disable air start.
    //#define ENABLE_AIR_START 0

    but the config.h file has:
    #ifndef ENABLE_AIR_START

    I'm not sure if I'm reading this right, but it looks like Air Start is Enabled by default.

  • Thanks for the example landing process! We've had great success with navigating to waypoints with the APM and are gearing up to try auto landings.

    I have a few questions about the above example before attempting to fly a landing mission.

    1. As I understand it, when a level-1 waypoint command is executed (ex: command 3 in the example above), the APM loads the waypoint and STARTS heading towards it. At this point, the next level-2 command may be executed while enroute (ex: command 4 (landing options) in the example above).
    If this is the case, it seems the landing options are all offset by a line. Loading landing options (#4 above) shouldn't have any effect while tracking towards are regular waypoint (#3 above), correct? So I believe the CMD_LAND (_options) should follow each CMD_LAND_WP command, not precede.

    2. Regardless of the command order issue just mentioned, I understand the intent to be setting attitude (pitch, etc) and configuration (speed/throttle) as it tracks to a waypoint. For your final landing segment, the intent is to configure the plane for 30 degrees pitch, zero airspeed, and zero throttle AS IT TRACKS to waypoint 9 ("final destination").
    If this is truly the case, won't the APM try to set the plane to this configuration AS SOON AS the final waypoint is loaded? Won't the plane be at 20meters altitude (having just reached the previous waypoint) when this occurs? What is to prevent a stall at 20m?

    3. I'm a full-scale pilot as well, and I do understand models can be (and are!) flown differently. However, if I were to program a landing from scratch [copying a full-scale approach] I would have thought one would desire a negative pitch (maybe -2 to -8 degrees, depending on airframe) until the flare, when a positive pitch is used for final deceleration and to arrest the descent speed. Thus I'm a bit surprised by the 20 degree pitch up attitude being held for the approach example above. Unless a model is quite overpowered (though admittedly they usually are), 20 degrees pitch-up with only 30% throttle could easily be a decelerating configuration that would lead to a stall.
    Any comments or rationale you can share as to why you executed it this way? I just want to make sure I'm not missing something; as I'd like to program my APM landings in a way that doesn't depend on throttle (i.e., remaining battery power!) so it can land safely even without the motor if needed.

    Thanks for all the help and support! Going go out to the field now for some more flight tests!!

    - James
  • Hello, I encountered a problem and if it's not some software or is my APM, is that when I connect my RX feeding, feeding the APM with all the cables from the RX to APM, the channel mode selection In this case, the pins of the input channel 7 stops working for mode selection and becomes the gas channel 3, to fix I have to cut the power and start the APM only cable channel 7 connected and then continue to connect the other input channels.

    Sorry for the translation.
  • Hi, I’ve just gotten my APM connect up and loaded in with the ver 1.0.1 code. No error was found.
    I’m interested how do I test is it working?
  • Jason,

    Thank you this resolved my issue.

  • Developer
    I've updated Speed 3d in all the libraries. Please re-download them if you have issues.
  • Javier,

    Thank you, just know it can be done helps, I will keep at it and reset my source files and try again.
  • #LeeJR, you've installed the updated library GPS_MTK?
  • Developer
    I re-uploaded it.
    The trick is the GPS can't be set in the header anymore until I figure out how to use defines and includes together to "compute" the header. Anyone know how to do that in C++?

    You need to uncomment the correct GPS library in the main file:

    // GPS
    //#include // ArduPilot IMU/XPLANE GPS Library
    #include // ArduPilot Ublox GPS Library
    //#include // ArduPilot MediaTek GPS Library
    //#include // ArduPilot NMEA GPS library
  • Developer
    For now set GCS_PROTOCOL to 5 in your config like this:

    #define GCS_PROTOCOL 5
This reply was deleted.


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
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
DIY Robocars via Twitter
RT @gclue_akira: レースまであと3日。今回のコースは激ムズかも。あと一歩 #jetracer
Nov 24
DIY Robocars via Twitter
UC Berkeley's DIY robocar program
Nov 24
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
DIY Robocars via Twitter
RT @arthiak_tc: Donkey car platform ... Still training uses behavioral cloning #TCXpo #diyrobocar @OttawaAVGroup
Nov 20
DIY Robocars via Twitter
RT @emurmur77: Points for style. @donkeycar racing in @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video.…
Nov 20
DIY Robocars via Twitter
RT @SmallpixelCar: Going to @diyrobocars race at @UCSDJacobs
Nov 8
DIY Robocars via Twitter
RT @SmallpixelCar: Race @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video.
Nov 8
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
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
DIY Robocars via Twitter
Oct 23
DIY Robocars via Twitter
Oct 19
DIY Robocars via Twitter
Oct 18
DIY Robocars via Twitter
RT @NeaveEng: Calling all UK based folks interested in @diyrobocars, @f1tenth, @donkey_car, and similar robot racing competitions! @hacky_r…
Oct 13
DIY Robocars via Twitter
RT @araffin2: 🏎️ After hours of video editing, I'm happy to share a best of my Twitch videos on learning to race with RL. 🏎️ Each part is…
Oct 13