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

Imu health reporting and preflight checks improvements #12989

Closed
wants to merge 6 commits into from

Conversation

dusan19
Copy link
Contributor

@dusan19 dusan19 commented Sep 19, 2019

Main issues:

  1. Gyro, accel, mag and baro health is evaluated by different modules (sensors, commander) and each of them set the health bitmask inconsistently, furthermore each of them overrides the health reported by the other.
  2. Preflight checks do not consider sensor failures reported by the sensors module

More detailed explanation and problem examples:

  1. Sensors health bitmask is set in commander::status.onboard_control_sensors_health. It is set by preflight tests function, and by the health reported on the subsystem_info topic by sensors module.
    Preflight checks set the bit in the health bitmask that matches the sensor instance. For example SUBSYSTEM_TYPE_GYRO bit is set for gyro 0, and SUBSYSTEM_TYPE_GYRO2 for gyro 1. On the other hand sensors module sets the bits considering the number of healthy sensors. Which means that in case of a gyro 0 failure, commander would set SUBSYSTEM_TYPE_GYRO to false, and sensors would set SUBSYSTEM_TYPE_GYRO2 to false. That behavior is not consistent.
  • Solution: sensors module should also set the health of a specific sensor according to its index and not to the number of healthy sensors. This way we know which sensor failed by looking at the vehicle_status message. Especially useful when using external sensors, to be able to know which one to replace.
    Furthermore, the health reported by different modules should be passed through a "logical and" function to get the final health. If any module reports a sensor failure, the sensor is flagged as failed.
  1. Preflight checks do not consider health reported by sensors module (no data, stale data, timeout, high error count, high error density).
    I could reproduce the following scenario: I set the required number of healthy sensors to 2 instead of default 1, enabled 2 mags, and had stale data on the second mag. The checks passed even though the second mag was broken.
  • Solution: use the health reported by the sensors module together with the existing health checks in preflight tests.

Other fixes and improvements:

  • Commander runs preflight tests every 2 seconds or when the health message is received, if the vehicle is unarmed. This way we have up to date health checks, and flight readiness, which can be reported over mavlink to the base station such that the user is informed about the system state and failures all the time and not only when arming is requested. Or be used otherwise.

  • I encountered a bug where I had 1 mag enabled but got mag sensors inconsistency failure. This happened because mag 2 was disabled but still had priority set to 100 instead of zero. Mag enabled is initalized to true and overridden by the parameter setting inVotedSensorsUpdate::parametersUpdate(), but only if this sensors uorb instance was published. Due to race conditions this didnt happen before the initial parameter update, but after mag poll was called, so in VotedSensorsUpdate::magPoll since the enable was true, the priority 100 was assigned to the sensor and it was checked in the inconsistency test.
    Solution: sensors enabled array is initialized to false. (priority is already 0 initially, and so should the enabled flags be).

… state, using the subsystem_type that matches the sensor instance
…g health flags for sensors sent by the sensors module,

Preflight checks: use sensor health reported by the sensors module
Preflight checks: write the result to the vehicle status
@julianoes
Copy link
Contributor

@dusan19 thanks for the pull request. I will try to review it as soon as possible!

new_sensors_health &= ~curr_type;
}

if (_sensors_health != new_sensors_health) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should give commander some time to initialize and subscribe to subsystem_info since this is published on change thus failures might get dropped
for instance:
if (_sensors_health != new_sensors_health && hrt_absolute_time > 10_s) {

@dagar
Copy link
Member

dagar commented Sep 19, 2019

In general I think we'd be better to push the specifics of the sensor checks to the sensor module itself and then only publish a higher level summary. Then in commander arming and failsafes can act on this simple information at the state machine level. Sensors would also be in a good position to continuously publish more of the health checks for logging purposes.

@dusan19
Copy link
Contributor Author

dusan19 commented Sep 25, 2019

@dagar I agree, preflight checks in commander shouldn't subscribe to different sensors topics published by the drivers, but only to the relevant topics from the sensors module.
I will push an another PR today, with the proposed changes. Also I found some related bugs in the sensors module and the commander and will include those fixes as well

@dusan19
Copy link
Contributor Author

dusan19 commented Sep 25, 2019

check out #13025

@stale
Copy link

stale bot commented Dec 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale
Copy link

stale bot commented Apr 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@LorenzMeier
Copy link
Member

Unfortunately this is stale and I'm closing it accordingly. We still would want to get this functionality in, but based on the recent improvements that Daniel did on the estimatior.

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

Successfully merging this pull request may close these issues.

4 participants