Program Listing for File undock_robot.hpp

Return to documentation for file (include/opennav_docking_bt/undock_robot.hpp)

// Copyright (c) 2024 Open Navigation LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef OPENNAV_DOCKING_BT__UNDOCK_ROBOT_HPP_
#define OPENNAV_DOCKING_BT__UNDOCK_ROBOT_HPP_

#include <string>
#include <memory>
#include <vector>

#include "opennav_docking_msgs/action/undock_robot.hpp"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "nav2_behavior_tree/bt_action_node.hpp"

namespace opennav_docking_bt
{

class UndockRobotAction
  : public nav2_behavior_tree::BtActionNode<
    opennav_docking_msgs::action::UndockRobot>
{
  using Action = opennav_docking_msgs::action::UndockRobot;
  using ActionResult = Action::Result;

public:
  UndockRobotAction(
    const std::string & xml_tag_name,
    const std::string & action_name,
    const BT::NodeConfiguration & conf);

  void on_tick() override;

  BT::NodeStatus on_success() override;

  BT::NodeStatus on_aborted() override;

  BT::NodeStatus on_cancelled() override;

  void halt() override;

  static BT::PortsList providedPorts()
  {
    return providedBasicPorts(
      {
        BT::InputPort<std::string>(
          "dock_type", "The dock plugin type, if not previous instance used for docking"),
        BT::InputPort<float>(
          "max_undocking_time", 30.0, "Maximum time to get back to the staging pose"),

        BT::OutputPort<ActionResult::_success_type>(
          "success", "If the action was successful"),
        BT::OutputPort<ActionResult::_error_code_type>(
          "error_code", "Error code"),
      });
  }
};

}  // namespace opennav_docking_bt

#endif  // OPENNAV_DOCKING_BT__UNDOCK_ROBOT_HPP_