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

mavlink altitude fix and general cleanup #9158

Merged
merged 6 commits into from
Mar 28, 2018
Merged

mavlink altitude fix and general cleanup #9158

merged 6 commits into from
Mar 28, 2018

Conversation

dagar
Copy link
Member

@dagar dagar commented Mar 25, 2018

While testing #8771 I noticed the QGC altitude would stop updating in various situations if the global position validity was lost, even though the system still had a valid altitude.

I went through Mavlink altitude usage in VFD_HUD, GLOBAL_POSITION_INT, and ALTITUDE to make the usage consistent.

I also saw quite a few timestamps throughout the mavlink module that weren't actually used, so I removed them.

@dagar dagar changed the title Pr mavlink altitude mavlink altitude fix and general cleanup Mar 25, 2018
@dagar dagar force-pushed the pr-mavlink_altitude branch 5 times, most recently from 1f113d6 to 95f9ad8 Compare March 26, 2018 14:14
bkueng
bkueng previously requested changes Mar 27, 2018
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

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

Generally nice cleanup

if (_global_pos_time != 0 && global_pos.terrain_alt_valid) {
msg.altitude_terrain = global_pos.terrain_alt;
msg.bottom_clearance = global_pos.alt - global_pos.terrain_alt;
if ((sensor.timestamp > 0) && (sensor_time > 0)) {
Copy link
Member

Choose a reason for hiding this comment

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

Checking for sensor.timestamp > 0 is enough (and then _sensor_time can be removed) and the added brackets make it less readable

Copy link
Member Author

Choose a reason for hiding this comment

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

This is another one that's a bit awkward. In the nominal case we want to make sure everything is populated from both sensor_combined and vehicle_local_position. I'll look again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be better now.

updated |= _gpos_sub->update(&gpos);
updated |= _lpos_sub->update(&lpos);
updated |= _home_sub->update(&home);
updated |= _sensor_sub->update(&sensor);
Copy link
Member

Choose a reason for hiding this comment

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

Can you move the sensor topic & update into the if else block, as to avoid copying the data when not needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was done to continue updating the alt from baro if everything else is lost. It's not ideal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I made GLOBAL_POSITION_INT update a little more conservative and it should almost never actually need to copy sensor_combined unless the estimator is behaving weirdly.

@@ -326,23 +326,22 @@ class MavlinkStreamHeartbeat : public MavlinkStream

bool send(const hrt_abstime t)
{
struct vehicle_status_s status = {};
vehicle_status_s status;

/* always send the heartbeat, independent of the update status of the topics */
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct anymore. Please change it back to always send the heartbeat.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see now that the comment is wrong, but this is intentional. Commander publishes vehicle_status at >= 1 Hz. HEARTBEAT send will now sync up with commander publication and more importantly reflect if commander is actually alive.

Copy link
Member

Choose a reason for hiding this comment

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

I see your reasoning, but I think it's more important to always send a heartbeat, even in the case commander is not running or misbehaving (or for some reasons the >1Hz assumption does not hold anymore). This makes link debugging and a lot easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, original HEARTBEAT restored.

_raw_gyro_sub->update(&_raw_gyro_time, &_sensor_gyro);
bool updated = false;
updated |= _raw_accel_sub->update(&_raw_accel_time, &sensor_accel);
updated |= _raw_gyro_sub->update(&_raw_gyro_time, &sensor_gyro);

// send if raw_accel has been updated and use the newest gyro values we have
Copy link
Member

Choose a reason for hiding this comment

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

Comment needs updating

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@dagar dagar force-pushed the pr-mavlink_altitude branch 2 times, most recently from d955b63 to cf33c17 Compare March 27, 2018 17:12
@dagar dagar dismissed bkueng’s stale review March 27, 2018 17:16

Most comments addressed, a couple points may need further discussion.

// always update monotonic altitude
bool sensor_updated = false;
sensor_combined_s sensor = {};
_sensor_sub->update(&_sensor_time, &sensor);
Copy link
Member

Choose a reason for hiding this comment

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

_sensor_time is not required anymore since we don't check the return value.

Copy link
Member Author

Choose a reason for hiding this comment

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

deleted

@dagar dagar merged commit d40d165 into master Mar 28, 2018
@dagar dagar deleted the pr-mavlink_altitude branch March 28, 2018 19:38
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.

2 participants