1
$\begingroup$

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\","
              "\"p_rkp\":%.2f,\"p_rki\":%.2f,\"p_rkd\":%.4f,\"p_rimax\":%.2f,"
              "\"r_rkp\":%.2f,\"r_rki\":%.2f,\"r_rkd\":%.4f,\"r_rimax\":%.2f,"
              "\"y_rkp\":%.2f,\"y_rki\":%.2f,\"y_rkd\":%.4f,\"y_rimax\":%.2f,"
              "\"p_skp\":%.2f,\"r_skp\":%.2f,\"y_skp\":%.4f}\n",
              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) );
$\endgroup$
1
  • $\begingroup$ static_cast is a C++ feature, not C. please modify the list of tags to indicate C++ and not C $\endgroup$ Commented Apr 11, 2015 at 19:40

1 Answer 1

1
$\begingroup$

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/)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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