15#include "auto_apms_px4_interfaces/action/takeoff.hpp"
17#include "auto_apms_behavior_tree_core/node.hpp"
19#define INPUT_KEY_ALTITUDE "alt"
20#define INPUT_KEY_USE_AMSL "use_amsl"
21#define INPUT_KEY_HEADING "heading"
26class TakeoffAction :
public auto_apms_behavior_tree::core::RosActionNode<auto_apms_px4_interfaces::action::Takeoff>
29 using RosActionNode::RosActionNode;
31 static BT::PortsList providedPorts()
34 BT::InputPort<float>(INPUT_KEY_ALTITUDE,
"Target altitude for takeoff in meters"),
36 INPUT_KEY_USE_AMSL,
false,
37 "If true, altitude is interpreted as above mean sea level (AMSL), otherwise as altitude above takeoff point"),
38 BT::InputPort<float>(INPUT_KEY_HEADING, 0.0,
"Heading after takeoff in radians from north in NED frame")};
41 bool setGoal(Goal & goal)
43 if (
const BT::Expected<float> expected = getInput<float>(INPUT_KEY_ALTITUDE)) {
44 goal.alt = expected.value();
46 RCLCPP_ERROR(logger_,
"%s", expected.error().c_str());
49 goal.use_amsl = getInput<bool>(INPUT_KEY_USE_AMSL).value();
50 goal.heading_rad = getInput<float>(INPUT_KEY_HEADING).value();
#define AUTO_APMS_BEHAVIOR_TREE_REGISTER_NODE(type)
Macro for registering a behavior tree node plugin.
Implementation of PX4 mode peers offered by px4_ros2_cpp enabling integration with AutoAPMS.