Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c17c54b

Browse files
julianoesdagar
authored andcommitted
navigator: fix triplet resetting/publication logic
The navigator has a notion of resetting the triplets which means the triplet setpoints are set to invalid and therefore not to be used by downstream modules such as flight tasks. However, before this patch, the triplets were not published if invalid meaning that a valid triplet would stay the truth until a new valid triplet would get published. E.g. this lead to the corner case case where we publish a valid triplet with an IDLE setpoint on ground in HOLD and then don't update the triplet while flying in POSCTL mode. Later, when RTL is engaged, the flight task will use IDLE until navigator (which runs slower) has published the next triplet. The fix involves two main changes: - Publish invalid triplets to avoid stale triplets. - Avoid publishing the triplet on every iteration in manual modes by not setting `_pos_sp_triplet_published_invalid_once = false`. When testing this I realized that a mission upload during RTL would stop RTL. This is because the mission is updated while the mission navigation mode is not active and reset_triplets() is called from there. This is now only done for the case where we are actually in mission navigation mode. The fact that a mission is updated when not active also seems wrong and is something to fix another time.
1 parent 865cf56 commit c17c54b

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

src/modules/navigator/mission.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,14 @@ Mission::on_active()
191191
bool mission_sub_updated = _mission_sub.updated();
192192

193193
if (mission_sub_updated) {
194+
_navigator->reset_triplets();
194195
update_mission();
195196
}
196197

197198
/* reset the current mission if needed */
198199
if (need_to_reset_mission(true)) {
199200
reset_mission(_mission);
201+
_navigator->reset_triplets();
200202
update_mission();
201203
_navigator->reset_cruising_speed();
202204
mission_sub_updated = true;
@@ -442,9 +444,6 @@ Mission::update_mission()
442444

443445
bool failed = true;
444446

445-
/* reset triplets */
446-
_navigator->reset_triplets();
447-
448447
/* Reset vehicle_roi
449448
* Missions that do not explicitly configure ROI would not override
450449
* an existing ROI setting from previous missions */

src/modules/navigator/navigator_main.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ Navigator::run()
620620
case vehicle_status_s::NAVIGATION_STATE_OFFBOARD:
621621
case vehicle_status_s::NAVIGATION_STATE_STAB:
622622
default:
623-
_pos_sp_triplet_published_invalid_once = false;
624623
navigation_mode_new = nullptr;
625624
_can_loiter_at_sp = false;
626625
break;
@@ -720,16 +719,8 @@ Navigator::print_status()
720719
void
721720
Navigator::publish_position_setpoint_triplet()
722721
{
723-
// do not publish an invalid setpoint
724-
if (!_pos_sp_triplet.current.valid) {
725-
return;
726-
}
727-
728722
_pos_sp_triplet.timestamp = hrt_absolute_time();
729-
730-
/* lazily publish the position setpoint triplet only once available */
731723
_pos_sp_triplet_pub.publish(_pos_sp_triplet);
732-
733724
_pos_sp_triplet_updated = false;
734725
}
735726

0 commit comments

Comments
 (0)