Servers by jDrones

Creating new MAVLink Message: Problem with building ArduCopter code

arducopter
(Peter) #1

Hi everyone!

We want to send sensor data via MAVLink messages (the system uses ArduCopter in the drone and Mission Planner on the GCS). In order to do this, we want to introduce a new MAVLink message (probably into the ardupilotmega dialect), if it is useful for others. In case it is too special for general application, just for the use of our project.

As of now the sensor data is sent via an additional radio module on the drone which just sends the sensor data and a time stamp.

The sensor data has a 24 bit resolution and is measured with a sample rate of 50 Hz.

The data also should have a 32 bit timestamp.

Several sensor data values can be packed with one timestamp, because the sensor data intervals are quiet reliably at 20 ms. So in the end the new MAVLink message would be something like

CSMAG0
time uint32_t
induction int32_t[N]

N ::= 1 … 63, for example N=10

if we use 32 bit sensor data values (and waste 8 bits per value). The timestamp is 32 b as of now, but since MAVLink seems to use time_us uint64_t timestamp as a quasi standard, we should adapt this later on.

I followed the instructions of http://ardupilot.org/dev/docs/code-overview-adding-a-new-mavlink-message.html
but at step #4 the instructions seem deprecated, since there is no ./libraries/GCS_MAVLink/generate.sh file. Later I found this code generation python program:

…/ardupilot-cs/modules/mavlink$ ./mavgenerate.py

Now my questions:

Where should be the output folder of the generated files?
I traced the call hierarchy of RANGEFINDER.distance, to learn about how ArduCopter works and found out, it includes some files in “modules/mavlink/pymavlink/generator/C/include_v1.0”, when ArduCopter is about to send the RANGEFINDER message. So should this be the output path for mavgenerate.py?

Is it necessary to introduce a new parameter for the sensor data according to http://ardupilot.org/dev/docs/code-overview-adding-a-new-parameter.html ?

Have other details of the MAVLink message adding process changed in regard to the introduction?
Thanks for your help :slight_smile:

Best Regards,
Peter

(Peter) #2

Update: I successfully generated headerfiles, it turned out i chose a wrong parameter in mavgenerate.py

Once its gui pops up, finally I selected

XML:
ardupilot/modules/mavlink/message_definitions/v1.0/ardupilotmega.xml

Out:
ardupilot/modules/mavlink/pymavlink/generator/C/include_v1.0

Language: C
Protocol: 1.0
Validate: True
Vali Units: False

and that generated header files. Before I selected C++ and it said, only MAVLink v2.0 is supported.
I didn’t find this anywhere in the docu. If the way I did it is correct, we might add this to http://ardupilot.org/dev/docs/code-overview-adding-a-new-mavlink-message.html ?