Skip to content

Commit 5319b82

Browse files
MissionBase: replay change speed on resume immediately if not going to previous (#24484)
* MissionBase: replay change speed on resume immediately if not going to previous This fixes an issue where the speed was not correctly set at the beginning of a survey (with first wp having a DO_CHANGE_SPEED attached) when the user paused and resumed the mission prior to reaching the first waypoint. Signed-off-by: Silvan Fuhrer <[email protected]> * Update src/modules/navigator/mission_base.cpp Co-authored-by: Stefano Colli <[email protected]> --------- Signed-off-by: Silvan Fuhrer <[email protected]> Co-authored-by: Stefano Colli <[email protected]>
1 parent c6c0f22 commit 5319b82

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/modules/navigator/mission_base.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ MissionBase::on_activation()
218218

219219
int32_t resume_index = _inactivation_index > 0 ? _inactivation_index : 0;
220220

221+
bool resume_mission_on_previous = false;
222+
221223
if (_inactivation_index > 0 && cameraWasTriggering()) {
222224
size_t num_found_items{0U};
223225
getPreviousPositionItems(_inactivation_index - 1, &resume_index, num_found_items, 1U);
@@ -229,9 +231,20 @@ MissionBase::on_activation()
229231
setMissionIndex(resume_index);
230232

231233
_align_heading_necessary = true;
234+
resume_mission_on_previous = true;
232235
}
233236
}
234237

238+
if (!resume_mission_on_previous) {
239+
// Only replay speed changes immediately if we are not resuming the mission at the previous position item.
240+
// Otherwise it must be handled in the on_active() method once we reach the previous position item.
241+
replayCachedSpeedChangeItems();
242+
_speed_replayed_on_activation = true;
243+
244+
} else {
245+
_speed_replayed_on_activation = false;
246+
}
247+
235248
checkClimbRequired(_mission.current_seq);
236249
set_mission_items();
237250

@@ -304,14 +317,16 @@ MissionBase::on_active()
304317
replayCachedGimbalItems();
305318
}
306319

307-
// Replay cached mission commands once the last mission waypoint is re-reached after the mission interruption.
308-
// Each replay function also clears the cached items afterwards
320+
// Replay cached trigger commands once the last mission waypoint is re-reached after the mission resume
309321
if (_mission.current_seq > _mission_activation_index) {
310322
// replay trigger commands
311323
if (cameraWasTriggering()) {
312324
replayCachedTriggerItems();
313325
}
326+
}
314327

328+
if (!_speed_replayed_on_activation && _mission.current_seq > _mission_activation_index) {
329+
// replay speed change items if not already done on mission (re-)activation
315330
replayCachedSpeedChangeItems();
316331
}
317332

src/modules/navigator/mission_base.h

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ class MissionBase : public MissionBlock, public ModuleParams
332332
float _mission_init_climb_altitude_amsl{NAN}; /**< altitude AMSL the vehicle will climb to when mission starts */
333333
int _inactivation_index{-1}; // index of mission item at which the mission was paused. Used to resume survey missions at previous waypoint to not lose images.
334334
int _mission_activation_index{-1}; /**< Index of the mission item that will bring the vehicle back to a mission waypoint */
335+
bool _speed_replayed_on_activation{false}; /**< Flag indicating if the speed change items have been replayed on activation */
335336

336337
int32_t _load_mission_index{-1}; /**< Mission inted of loaded mission items in dataman cache*/
337338
int32_t _dataman_cache_size_signed; /**< Size of the dataman cache. A negativ value indicates that previous mission items should be loaded, a positiv value the next mission items*/

0 commit comments

Comments
 (0)