Skip to content
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

Added sensor_msg.id to avoid out of range error from PX4's SimulatorMavlink #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

toshiharutf
Copy link

@toshiharutf toshiharutf commented Feb 26, 2024

Problem description

While running PX4_Autopilot (d98800521644ff2ba5d761c66a0d601016b96dac) in SITL with jsbsim, the following problem arise

image

This is originated here
src/modules/simulation/simulator_mavlink/SimulatorMavlink.cpp

if (sensors.id >= ACCEL_COUNT_MAX) { PX4_ERR("Number of simulated accelerometer %d out of range. Max: %d", sensors.id, ACCEL_COUNT_MAX); return; if (sensors.id >= MAG_COUNT_MAX) { PX4_ERR("Number of simulated magnetometer %d out of range. Max: %d", sensors.id, MAG_COUNT_MAX); return;

Note
Not sure why sensors.id is used as the max field length.

Solution
Added sensor_msg.id to acc, gyro and mag to avoid "Number of simulated…… xxx out of range" error from PX4's SimulatorMavlink class.

… xxx out of range" error from SimulatorMavlink in PX4
Copy link
Contributor

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this with using a simulated mag sensor?

e.g. SENS_EN_MAGSIM=1

This might interfere with the simulated sensors.

@toshiharutf
Copy link
Author

Hi Jaeyoung,
Thanks for the fast response. I have updated the bug description to better explain the fix.
I haven't tested the setting you mentioned, but I think it is not related from what I saw in the code.

P.D. I wrote you an email to your instutional account. Please, check when you have the time.

@toshiharutf
Copy link
Author

The other possibility would be to address it from PX4, but since Gazebo seems to be working fine, I think this fix presents the least modifications.

@Jaeyoung-Lim
Copy link
Contributor

Jaeyoung-Lim commented Feb 26, 2024

@toshiharutf The problem is that the simulated sensors would be publishing to instance 0. Therefore, if you hardcode the instance number here, it would interfere with the simulated sensor instances.

@dagar FYI

@toshiharutf
Copy link
Author

@Jaeyoung-Lim , in the PX4 codebase, I only see mavlink_hil_sensor_t been used in SimulatorMavlink.
If by interference, you mean problems between other sensors in the HIL_SENSOR msg, that is addressed with fields_updated.

TBH, I don't understand why SimulatorMavlink is sensors.id as a max length field.
What would be your suggestion? should I attemp a fix for PX4?

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants