46 const std::string & instance_name,
const BT::NodeConfig & config,
53 createSubscriber(
"fmu/out/mode_completed" + px4_ros2::getMessageNameVersion<px4_msgs::msg::ModeCompleted>());
56 static BT::PortsList providedPorts()
59 BT::InputPort<int>(INPUT_KEY_NAV_STATE,
"PX4 navigation state (mode id) whose completion is awaited."),
63 BT::NodeStatus onTick(
const std::shared_ptr<px4_msgs::msg::ModeCompleted> & last_msg_ptr)
final
67 if (!last_msg_ptr)
return BT::NodeStatus::FAILURE;
69 const BT::Expected<int> expected_nav_state = getInput<int>(INPUT_KEY_NAV_STATE);
70 if (!expected_nav_state) {
72 logger_,
"%s - Missing required input '%s': %s", context_.getFullyQualifiedTreeNodeName(
this).c_str(),
73 INPUT_KEY_NAV_STATE, expected_nav_state.error().c_str());
74 return BT::NodeStatus::FAILURE;
78 if (last_msg_ptr->nav_state !=
static_cast<uint8_t
>(expected_nav_state.value()))
return BT::NodeStatus::FAILURE;
80 if (last_msg_ptr->result != px4_msgs::msg::ModeCompleted::RESULT_SUCCESS) {
82 logger_,
"%s - Mode nav_state %d reported completion with non-success result %u.",
83 context_.getFullyQualifiedTreeNodeName(
this).c_str(), expected_nav_state.value(), last_msg_ptr->result);
84 return BT::NodeStatus::FAILURE;
87 return BT::NodeStatus::SUCCESS;
Additional parameters specific to ROS 2 determined at runtime by TreeBuilder.