I want to submit my gains for the PID regulator via MAVLink. Unfortunately, I am not very used to MAVLink and there are several functions which may be used for that purpose (I think). My string is currently JSON formatted and I was directly sending it to the serial port before.

Is there a straight forward way to submit the data like it is (see below) with MAVLink, or is it better not to transfer a JSON string with MAVLink and submit each single value? If yes, what is the function of choice.

So far I noticed that for most of the sensors, there are already MAVLink function defined. For the PID gains I found not so much.

AP_HAL::UARTDriver *pOut = uartX == UART_C ? hal.uartC : hal.uartA;
pOut->printf( "{\"t\":\"pid_cnf\","
              static_cast<double>(pit_rkp), static_cast<double>(pit_rki), static_cast<double>(pit_rkd), static_cast<double>(pit_rimax),
              static_cast<double>(rol_rkp), static_cast<double>(rol_rki), static_cast<double>(rol_rkd), static_cast<double>(rol_rimax),
              static_cast<double>(yaw_rkp), static_cast<double>(yaw_rki), static_cast<double>(yaw_rkd), static_cast<double>(yaw_rimax),
              static_cast<double>(pit_skp), static_cast<double>(rol_skp), static_cast<double>(yaw_skp) );
  • $\begingroup$ static_cast is a C++ feature, not C. please modify the list of tags to indicate C++ and not C $\endgroup$ – user3629249 Apr 11 '15 at 19:40

You need to use the mavlink parameter protocol, which is a coordinated set of mavlink messages between the ground control station and the vehicle (a bit trickier than just sending strings over the serial port, unfortunately). The protocol is documented here: http://qgroundcontrol.org/mavlink/parameter_protocol

The following diagrams shows the flow of messages (replace "QGroundControl" with your application and "MAV Component" with your vehicle):

enter image description here

(You might also want to double check the parameter names for the particular flight controller/vehicle you're using, e.g. here are the parameters for ArduCopter/APM:Copter: http://copter.ardupilot.com/wiki/configuration/arducopter-parameters/)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.