42 #include <rclcpp/rclcpp.hpp>
43 #include <rclcpp_action/rclcpp_action.hpp>
45 #include <pluginlib/class_loader.hpp>
47 #include <moveit_msgs/action/local_planner.hpp>
48 #include <moveit_msgs/msg/motion_plan_response.hpp>
49 #include <moveit_msgs/msg/robot_trajectory.hpp>
51 #include <std_msgs/msg/float64.hpp>
52 #include <std_msgs/msg/float64_multi_array.hpp>
54 #include <trajectory_msgs/msg/joint_trajectory.hpp>
61 #include <tf2_ros/buffer.h>
62 #include <tf2_ros/transform_listener.h>
68 void declareOrGetParam(
const std::string& param_name, T& output_value,
const T& default_value,
69 const rclcpp::Node::SharedPtr& node)
73 if (node->has_parameter(param_name))
74 node->get_parameter<T>(param_name, output_value);
76 output_value = node->declare_parameter<T>(param_name, default_value);
78 catch (
const rclcpp::exceptions::InvalidParameterTypeException& e)
80 RCLCPP_ERROR_STREAM(node->get_logger(),
81 "Error getting parameter '" << param_name <<
"', check parameter type in YAML file");
106 void load(
const rclcpp::Node::SharedPtr& node)
108 std::string undefined =
"<undefined>";
109 declareOrGetParam<std::string>(
"group_name",
group_name, undefined, node);
124 declareOrGetParam<std::string>(
"joint_states_topic",
joint_states_topic, undefined, node);
152 if (long_callback_thread_.joinable())
154 long_callback_thread_.join();
175 return node_->get_node_base_interface();
182 std::shared_ptr<rclcpp::Node> node_;
185 LocalPlannerConfig config_;
188 std::atomic<LocalPlannerState> state_;
191 rclcpp::TimerBase::SharedPtr timer_;
194 std::shared_ptr<rclcpp_action::ServerGoalHandle<moveit_msgs::action::LocalPlanner>> local_planning_goal_handle_;
197 std::shared_ptr<moveit_msgs::action::LocalPlanner::Feedback> local_planner_feedback_;
200 planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_;
203 std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
204 std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
207 rclcpp::Subscription<moveit_msgs::msg::MotionPlanResponse>::SharedPtr global_solution_subscriber_;
210 rclcpp_action::Server<moveit_msgs::action::LocalPlanner>::SharedPtr local_planning_request_server_;
213 rclcpp::Publisher<trajectory_msgs::msg::JointTrajectory>::SharedPtr local_trajectory_publisher_;
214 rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr local_solution_publisher_;
217 std::unique_ptr<pluginlib::ClassLoader<LocalConstraintSolverInterface>> local_constraint_solver_plugin_loader_;
220 std::shared_ptr<LocalConstraintSolverInterface> local_constraint_solver_instance_;
223 std::unique_ptr<pluginlib::ClassLoader<TrajectoryOperatorInterface>> trajectory_operator_loader_;
226 std::shared_ptr<TrajectoryOperatorInterface> trajectory_operator_instance_;
229 std::thread long_callback_thread_;
232 rclcpp::CallbackGroup::SharedPtr cb_group_;
~LocalPlannerComponent()
Destructor.
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
LocalPlannerComponent(const rclcpp::NodeOptions &options)
Constructor.
void declareOrGetParam(const std::string ¶m_name, T &output_value, const T &default_value, const rclcpp::Node::SharedPtr &node)
@ AWAIT_GLOBAL_TRAJECTORY
Struct that contains configuration of the local planner component node.
std::string joint_states_topic
std::string global_solution_topic
void load(const rclcpp::Node::SharedPtr &node)
double local_planning_frequency
std::string collision_object_topic
std::string local_planning_action_name
std::string local_constraint_solver_plugin_name
std::string local_solution_topic
std::string monitored_planning_scene_topic
std::string publish_planning_scene_topic
std::string local_solution_topic_type
std::string robot_description_semantic
std::string trajectory_operator_plugin_name
bool publish_joint_velocities
std::string robot_description
bool publish_joint_positions