Uorb messaging in mavsdk

Hi! I want to use below messages but I am using MAVSDK and I couldn’t find exact MAVSDK functions.

1-vehicle_acceleration (UORB message) | PX4 User Guide
2-vehicleangularvelocity (UORB message) | PX4 User Guide
3-vehicle_attitude (UORB message) | PX4 User Guide
4-vehiclelocalposition (UORB message) | PX4 User Guide
5-vehicleglobalposition (UORB message) | PX4 User Guide

Can you show me which MAVSDK functions help me?
Or If I don’t find them, could you show me how I can make a custom mavlink messaging example?


If you whant read information from drone, you can use Telemetry C++, Telemetry python.

for example get vehiclelocalposition:

telemetry.subscribe_position_velocity_ned([&](mavsdk::Telemetry::PositionVelocityNed callback){
local.north_m = callback.position.north_m;
local.east_m = callback.position.east_m;
local.down_m = callback.position.down_m;

Other functions you can find in Telemetry plugin too.

I know them but I want exactly these uorb messages. I have searched PX4-Autopilot codes and find some functions details but in mavlink(PX4-Autopilot/src/modules/mavlink at main · PX4/PX4-Autopilot · GitHub) vehicle_acceleration() is not called anywhere. Only landing target estimator (PX4-Autopilot/src/modules/landing_target_estimator at main · PX4/PX4-Autopilot · GitHub) called this function. How can I use this function via mavlink?

vehicle_acceleration() called from Telemetry plugin by:

ImuHandle subscribe_imu(const ImuCallback& callback);

ImuCallback is:

using ImuCallback = std::function<void(Imu)>;

Imu is:

struct Imu {
        AccelerationFrd acceleration_frd{}; /**< @brief Acceleration */
        AngularVelocityFrd angular_velocity_frd{}; /**< @brief Angular velocity */
        MagneticFieldFrd magnetic_field_frd{}; /**< @brief Magnetic field */
        float temperature_degc{float(NAN)}; /**< @brief Temperature */
        uint64_t timestamp_us{}; /**< @brief Timestamp in microseconds */

where is AccelerationFrd is:

struct AccelerationFrd {
        float forward_m_s2{
            float(NAN)}; /**< @brief Acceleration in forward direction in metres per second^2 */
        float right_m_s2{
            float(NAN)}; /**< @brief Acceleration in right direction in metres per second^2 */
        float down_m_s2{
            float(NAN)}; /**< @brief Acceleration in down direction in metres per second^2 */

you can’t use exactly uorb message via mavlink, but you can get the exactly same data with mavlink using mavsdk.

When I look at this code
PX4-Autopilot/VehicleIMU.cpp at b00efcd9663e93f739046a66934e9f12d5e2e1af · PX4/PX4-Autopilot · GitHub,

I saw,

_sensor_accel_sub(ORB_ID(sensor_accel), accel_index),
_sensor_gyro_sub(this, ORB_ID(sensor_gyro), gyro_index),
there are sensor_accel() and sensor_gyro() functions and I think AccelerationFrd is not using vehicle_acceleration() function.

I know I cannot use uorb messages directly via mavlink but I cannot sure a MAVSDK function called directly vehicle_acceleration(). Or I cannot see something.

vehicle_acceleration() uorb and AccelerationFrd are the same. Because they both geted from

> bool VehicleIMU::Publish()

you can try and check.

But AccelerationFrd get with latencion, beacause via Mavlink.

Thanks for help but I could not understand this. Can you give me detail?