New message and variables in APM Planner 2

I know that is not the best way to answer few months after but this topic was really helpful for me and I would like to add few details for people who would like to make it works with Mission Planner and SITL rather than a real drone. Hope it could help some people (I adapt the description of @eMrazSVK to give the full steps).

ArduPilot side:

  • Edit /ardupilot/modules/mavlink/message_definitions/v1.0/common.xml by adding your message
  • Build whole project
  • Create your appropriate function in ArduPilot as explain in the other topic
  • Different from this topic. Generate ardupilotmega.py file with mavgenerate.py also located in ardupilot/modules/mavlink/, it will open GUI, the input is message_definitions/ardupilotmega.xml and for the output create a new file called ardupilotmega.py (command to launch mavgenerate python mavgenerate.py)
  • Copy ardupilot/modules/mavlink/ardupilotmega.py to /usr/local/lib/python2.7/dist-packages/pymavlink/dialects/v10/.
  • Run sim_vehicle.py. Ardupilot use by default this dialect (ardupilotmega v10) if no special parameters has been added so if you replaced the file it should find your message. If you followed the instructions of last messages it can also works by adding --mavproxy-args "--dialect common" parameters when you run sim_vehicle.py. If you still have error with BAD_DATA, you may try to copy /ardupilot/modules/mavlink/message_definitions/v1.0/common.xml to /usr/local/lib/python2.7/dist-packages/pymavlink/message_definitions/v1.0/ I did it, but not sure if it is necessary
  • check with status command in MAVProxy console if you can see your message ID and the value you setted. You can also display in real time your data with module load graph and graph YOUR_MSG_ID.NAME_VARIABLE. If it’s working, go to MP side!

Mission Planner side:

  • Follow the instruction to install mission planner
  • Modify the file MissionPlanner\ExtLibs\Mavlink\message_definitions\common.xml with your new message (has to be the same than ArduPilot side)
  • Install python 2.7 for Windows and run MissionPlanner\ExtLibs\Mavlink\regenerate.bat from Windows and not cygwin or cmd prompt. Make sure you added the C:\Python27 to your PATH before. It will generate a new Mavlink.cs with your message ID
  • Build and run MP. A good way to check if your message is received, press ctrl+F in MP and click “MAV Link” button and see if your message is there.

Done !

1 Like