#include "behaviortree_ros2/bt_action_node.hpp" #include "rbs_skill_interfaces/action/moveit_send_pose_with_constraints.hpp" #include #include #include #include using namespace BT; using MoveitSendPoseWithConstraintAction = rbs_skill_interfaces::action::MoveitSendPoseWithConstraints; class MoveToPoseOrientationConstraint : public RosActionNode { public: MoveToPoseOrientationConstraint(const std::string &name, const NodeConfig &conf, const RosNodeParams ¶ms) : RosActionNode(name, conf, params) { RCLCPP_INFO(this->logger(), "Starting MoveToPose"); } static BT::PortsList providedPorts() { return providedBasicPorts( {BT::InputPort("robot_name"), BT::InputPort>("pose"), BT::InputPort("x_tol"), BT::InputPort("y_tol"), BT::InputPort("z_tol"), BT::InputPort("weight"), BT::InputPort("duration")}); } bool setGoal(RosActionNode::Goal &goal) override { RCLCPP_INFO(this->logger(), "[%s] Starting send goal [%s]", name().c_str(), this->action_name_.c_str()); getInput("x_tol", goal.orientation_constraint.absolute_x_axis_tolerance); getInput("y_tol", goal.orientation_constraint.absolute_y_axis_tolerance); getInput("z_tol", goal.orientation_constraint.absolute_z_axis_tolerance); getInput("weight", goal.orientation_constraint.weight); getInput("robot_name", goal.robot_name); getInput("pose", m_target_pose); getInput("duration", goal.duration); goal.target_pose = *m_target_pose; return true; } NodeStatus onResultReceived(const WrappedResult &wr) override { RCLCPP_INFO(this->logger(), "[%s] Starting get response %s with status %b", name().c_str(), this->action_name_.c_str(), wr.result->success); if (!wr.result->success) { return NodeStatus::FAILURE; } return NodeStatus::SUCCESS; } private: std::shared_ptr m_target_pose; }; CreateRosNodePlugin(MoveToPoseOrientationConstraint, "MtpOrientationConstraint");