AutoAPMS
Resilient Robot Mission Management
Loading...
Searching...
No Matches
mission.cpp
1// Copyright 2024 Robin Müller
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "auto_apms_interfaces/action/mission.hpp"
16
17#include "auto_apms_behavior_tree_core/node.hpp"
18
19#define INPUT_KEY_DO_RESTART "do_restart"
20
21namespace auto_apms_px4
22{
23
24class MissionAction : public auto_apms_behavior_tree::core::RosActionNode<auto_apms_interfaces::action::Mission>
25{
26public:
27 using RosActionNode::RosActionNode;
28
29 static BT::PortsList providedPorts()
30 {
31 return providedBasicPorts(
32 {BT::InputPort<bool>(INPUT_KEY_DO_RESTART, false, "Wether to restart (true) or resume (false) the mission.")});
33 }
34
35 bool setGoal(Goal & goal)
36 {
37 if (const BT::Expected<bool> expected = getInput<bool>(INPUT_KEY_DO_RESTART)) {
38 goal.do_restart = expected.value();
39 } else {
40 RCLCPP_ERROR(logger_, "%s", expected.error().c_str());
41 return false;
42 }
43 return true;
44 }
45};
46
47} // namespace auto_apms_px4
48
49AUTO_APMS_BEHAVIOR_TREE_DECLARE_NODE(auto_apms_px4::MissionAction)
#define AUTO_APMS_BEHAVIOR_TREE_DECLARE_NODE(type)
Macro for registering a behavior tree node plugin.
Definition node.hpp:40
Implementation of PX4 mode peers offered by px4_ros2_cpp enabling integration with AutoAPMS.
Definition mode.hpp:26