mavlink / MAVSDK

API and library for MAVLink compatible systems written in C++17
https://mavsdk.mavlink.io
BSD 3-Clause "New" or "Revised" License
615 stars 503 forks source link

Telemetry.set_rate_attitude() seems to have no effect #1569

Closed fas2037 closed 2 years ago

fas2037 commented 2 years ago

'm trying to set the rate of the attitude messages. I tried setting it to a lower hertz rate, for example 10 Hz. But the messages still seem to get published in a very high rate (100 Hz)

I subscribe to Telemetry.subscribe_attitude_quaternion()

The function should set the rate of this MAVLINK Message. https://github.com/mavlink/MAVSDK/blob/ee84bd93b7e0ef802963503a34783772e31eb10e/src/plugins/telemetry/telemetry_impl.cpp#L215-L219

So I took a look at this: https://github.com/mavlink/MAVSDK/blob/ee84bd93b7e0ef802963503a34783772e31eb10e/src/plugins/telemetry/telemetry_impl.cpp#L640-L720 I assume that both of this functions are able to publish the quaternion. Is there any cause for that? When checking with QGC both MAVLINK_MSG_ID_ATTITUDE_QUATERNION and MAVLINK_MSG_ID_ATTITUDE are published with 50 Hz. I guess as MAVSDK takes both messages into account and therefore the receiving rate of 100 Hz is archived.

But when using Telemetry.set_rate_attitude() I assume that this will set the rate of the subscription to a attitude message, for example the quaternion, to the desired one. This is not the case right now.

julianoes commented 2 years ago

Good point, this is a bit messy. The problem is that PX4 was supposed to move from ATTITUDE to ATTITUDE_QUATERNION in general, however, that has not happened, and for compatibility reasons probably won't happen soon.

In an idea world neither of the messages would be sent by default allowing you to request them at whatever rate you want them.

My suggestion would be to change PX4 so it does not send both at 50 Hz.

elpiel commented 2 years ago

My suggestion would be to change PX4 so it does not send both at 50 Hz. Is this the default for sending telemetry messages in PX4?

In my observation, I receive telemetry responses for Position & Quarternions in 200 milliseconds from the MAVSDK server which is well below 50 Hz, I think that's 5 Hz?

I still have some evaluation to do and tweaking of the setup in order to validate how the communication is performed. I'm currently using a simulation & MAVSDK server for ease of use.

linuxguy123 commented 2 years ago

This is still a problem in MAVSDK version: v1.4.3.

julianoes commented 2 years ago

Right. I guess we need to decouple the two attitude subscriptions and respective set_rate callers. So, for instance, instead of calling the attitude_euler callback when ATTITUDE or ATTITUDE_QUATERNION are called, only do so when ATTITUDE arrives.

julianoes commented 2 years ago

Fix coming:

It would be great if someone could review and test it, so I don't have to :smile:.

https://github.com/mavlink/MAVSDK-Proto/pull/293 https://github.com/mavlink/MAVSDK/pull/1878

julianoes commented 2 years ago

:wave: anyone willing to test this? Or am I on my own here...

elpiel commented 2 years ago

@julianoes let me try to look into this but last time I was running the sim locally I was getting bad performance. Probably because of my machine, however, I will try to test this anyway.

julianoes commented 2 years ago

You should be able to test it even when it's running a bit slower. You can see how fast it runs in the bottom left in Gazebo, and then you need to adjust the rates that telemetry is sent by it.

julianoes commented 2 years ago

@elpiel :wave:

elpiel commented 2 years ago

You should be able to test it even when it's running a bit slower. You can see how fast it runs in the bottom left in Gazebo, and then you need to adjust the rates that telemetry is sent by it.

I'm still planning to look into it, I've had some personal errands and I'm still traveling. I'll be more available in the coming 10 days.