AutoAPMS
Resilient Robot Mission Management
Loading...
Searching...
No Matches
takeoff.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/takeoff.hpp"
16
17#include "auto_apms_behavior_tree_core/node.hpp"
18
19#define INPUT_KEY_ALTITUDE "alt"
20
21namespace auto_apms_px4
22{
23
24class TakeoffAction : public auto_apms_behavior_tree::core::RosActionNode<auto_apms_interfaces::action::Takeoff>
25{
26public:
27 using RosActionNode::RosActionNode;
28
29 static BT::PortsList providedPorts()
30 {
31 return providedBasicPorts({BT::InputPort<double>(INPUT_KEY_ALTITUDE, "Target takeoff altitude in meter (AMSL)")});
32 }
33
34 bool setGoal(Goal & goal)
35 {
36 if (const BT::Expected<double> expected = getInput<double>(INPUT_KEY_ALTITUDE)) {
37 goal.altitude_amsl_m = expected.value();
38 } else {
39 RCLCPP_ERROR(logger_, "%s", expected.error().c_str());
40 return false;
41 }
42 return true;
43 }
44};
45
46} // namespace auto_apms_px4
47
48AUTO_APMS_BEHAVIOR_TREE_DECLARE_NODE(auto_apms_px4::TakeoffAction)
#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