67 command_list_manager_ = std::make_unique<pilz_industrial_motion_planner::CommandListManager>(
68 context_->moveit_cpp_->getNode(),
context_->planning_scene_monitor_->getRobotModel());
70 sequence_service_ =
context_->moveit_cpp_->getNode()->create_service<moveit_msgs::srv::GetMotionSequence>(
71 SEQUENCE_SERVICE_NAME,
72 [
this](
const moveit_msgs::srv::GetMotionSequence::Request::SharedPtr& req,
73 const moveit_msgs::srv::GetMotionSequence::Response::SharedPtr& res) {
return plan(req, res); });
76bool MoveGroupSequenceService::plan(
const moveit_msgs::srv::GetMotionSequence::Request::SharedPtr& req,
77 const moveit_msgs::srv::GetMotionSequence::Response::SharedPtr& res)
80 if (req->request.items.empty())
82 RCLCPP_WARN(getLogger(),
"Received empty request. That's ok but maybe not what you intended.");
83 res->response.error_code.val = moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
91 rclcpp::Time planning_start =
context_->moveit_cpp_->getNode()->now();
101 RCLCPP_ERROR_STREAM(getLogger(),
"Could not load planning pipeline " << req->request.items[0].req.pipeline_id);
102 res->response.error_code.val = moveit_msgs::msg::MoveItErrorCodes::FAILURE;
106 traj_vec = command_list_manager_->solve(ps,
context_->planning_pipeline_, req->request);
108 catch (
const MoveItErrorCodeException& ex)
111 "Planner threw an exception (error code: " << ex.getErrorCode() <<
"): " << ex.what());
112 res->response.error_code.val = ex.getErrorCode();
116 catch (
const std::exception& ex)
118 RCLCPP_ERROR_STREAM(
getLogger(),
"Planner threw an exception: " << ex.what());
124 res->response.planned_trajectories.resize(traj_vec.size());
125 for (RobotTrajCont::size_type i = 0; i < traj_vec.size(); ++i)
128 res->response.planned_trajectories.at(i));
130 res->response.error_code.val = moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
131 res->response.planning_time = (
context_->moveit_cpp_->getNode()->now() - planning_start).seconds();
137#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
void convertToMsg(const std::vector< plan_execution::ExecutableTrajectory > &trajectory, moveit_msgs::msg::RobotState &first_state_msg, std::vector< moveit_msgs::msg::RobotTrajectory > &trajectory_msg) const
MoveGroupContextPtr context_
planning_pipeline::PlanningPipelinePtr resolvePlanningPipeline(const std::string &pipeline_id) const
Provide service to blend multiple trajectories in the form of a MoveGroup capability (plugin).
void initialize() override
MoveGroupSequenceService()
~MoveGroupSequenceService() override
This is a convenience class for obtaining access to an instance of a locked PlanningScene.
rclcpp::Logger getLogger()
rclcpp::Logger getLogger(const std::string &name)
Creates a namespaced logger.
std::vector< robot_trajectory::RobotTrajectoryPtr > RobotTrajCont