Skip to content

Commit 9878780

Browse files
eyeam3bkueng
authored andcommitted
mission_execution: add interface for failsafe deferral to ActionHandler
1 parent f1efa9e commit 9878780

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

px4_ros2_cpp/include/px4_ros2/mission/mission_executor.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,36 @@ class ActionHandler
418418

419419
const Mission & mission() const {return _mission_executor.mission();}
420420

421+
/**
422+
* @brief enable/disable deferral of failsafes
423+
*
424+
* @param enabled
425+
* @param timeout_s 0=system default, -1=no timeout
426+
* @return true on success
427+
*/
428+
bool deferFailsafes(bool enabled, int timeout_s = 0)
429+
{
430+
if (!_valid) {
431+
RCLCPP_WARN(_mission_executor._node.get_logger(), "ActionHandler is not valid anymore");
432+
return false;
433+
}
434+
return _mission_executor.deferFailsafes(enabled, timeout_s);
435+
}
436+
437+
/**
438+
* @brief register callback for failsafe notification
439+
*
440+
* The callback is triggerd when a failsafe occurs while deferral is enabled.
441+
*/
442+
void onFailsafeDeferred(const std::function<void()> & callback)
443+
{
444+
if (!_valid) {
445+
RCLCPP_WARN(_mission_executor._node.get_logger(), "ActionHandler is not valid anymore");
446+
return;
447+
}
448+
_mission_executor.onFailsafeDeferred(callback);
449+
}
450+
421451
/**
422452
* @brief Check if the handler is still valid
423453
*

0 commit comments

Comments
 (0)