New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simulator: set sensor update rate according to HIL_SENSOR bitmask #14228
Conversation
There are build failures |
@julianoes I might need your input here: it seems that this change have uncovered some corner case on the optical flow testing that leads the vehicle to toilet bowl after it takes off - this is even more visible while flying in offboard. The interesting thing is that this behavior is not visible with other models like GPS, which leads me to discard this is a problem on the implementation of the sensor rate definition per si. I am running the MAVSDK tests on my local system with the GUI set so to check the issue visually. After speaking with @jkflying there are three different sources that might cause the problem:
@kamilritz if you have the opportunity to evaluate this as well your input is welcomed. |
Setting an high rate to optical flow updates seems to cause the toilet bowl issue - which I suppose it shouldn't happen. The update rate of the optical flow mock is currently set to 20Hz, which seems to avoid the issue. Though, it is visible on the MAVSDK tests that on takeoff, the vehicle starts shaking a lot when it reaches the takeoff altitude - and after a couple of seconds it stabilises. I am not sure what's causing it at this point. |
2f8e17d
to
edc8a21
Compare
Sending data at a higher rate to the EKF than usual can cause problems. As it will cause overflow of the buffers. For some sensors we added protection against this by downsampling the incoming data, but this is only done for mag and baro. I don't think it is done for the optical flow. |
b88f38b
to
16aaa10
Compare
a0c9913
to
d240235
Compare
c6bc184
to
de36578
Compare
9ee9ed7
to
334aa7c
Compare
334aa7c
to
30b8a6a
Compare
Describe problem solved by this pull request
Fixes #14220.
Describe your solution
A check is made to the bitmask field in
HIL_SENSOR
Mavlink message and according to how the bitmask is set, the respective sensors get updated. This allows to properly set the sensor rate for each sensor source.Test data / coverage
In SITL, running
uorb top sensor_accel sensor_gyro sensor_baro sensor_mag
:Note that baro is a bit lower than 50Hz and mag lower than 100Hz. The reason is that they are dependent of the Subscription callbacks in Gazebo, which have lower priority than the
OnUpdate()
function thread. A possible fix can be found by running specific Mavlink publishing threads for each of these sensor sources.