64 ROS_ERROR(
"Unable to find valid group config for StompSmoothingAdapter");
67 virtual std::string getDescription()
const override 69 return "Stomp Smoothing Adapter";
72 bool adaptAndPlan(
const PlannerFn& planner,
const planning_scene::PlanningSceneConstPtr& ps,
74 std::vector<std::size_t>& added_path_index)
const override 78 if (!planner(ps, req, res))
82 const size_t seed_waypoint_count = res.
trajectory_->getWayPointCount();
83 const std::vector<std::string> variable_names =
84 res.
trajectory_->getFirstWayPoint().getJointModelGroup(req.group_name)->getVariableNames();
85 const size_t variable_count = variable_names.size();
87 seed_req.trajectory_constraints.constraints.clear();
88 seed_req.trajectory_constraints.constraints.resize(seed_waypoint_count);
89 for (
size_t i = 0; i < seed_waypoint_count; ++i)
91 seed_req.trajectory_constraints.constraints[i].joint_constraints.resize(variable_count);
92 for (
size_t j = 0; j < variable_count; ++j)
94 seed_req.trajectory_constraints.constraints[i].joint_constraints[j].joint_name = variable_names[j];
95 seed_req.trajectory_constraints.constraints[i].joint_constraints[j].position =
96 res.
trajectory_->getWayPoint(i).getVariablePosition(variable_names[j]);
101 const auto& group_config_it = group_config_.find(req.group_name);
102 if (group_config_it == group_config_.end())
104 ROS_ERROR_STREAM(
"STOMP is not configured for planning group " << req.group_name);
105 res.
error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
111 if(!stomp_planner.canServiceRequest(seed_req))
113 ROS_ERROR(
"STOMP planner unable to service request");
114 res.
error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
119 stomp_planner.clear();
120 stomp_planner.setPlanningScene(ps);
121 stomp_planner.setMotionPlanRequest(seed_req);
124 ROS_DEBUG(
"Smoothing result trajectory with STOMP");
126 bool success = stomp_planner.solve(stomp_res);
138 std::map<std::string, XmlRpc::XmlRpcValue> group_config_;
robot_trajectory::RobotTrajectoryPtr trajectory_
This defines the stomp planner for MoveIt.
moveit_msgs::MoveItErrorCodes error_code_
moveit_msgs::MoveItErrorCodes error_code_
std::vector< double > processing_time_
moveit_msgs::MotionPlanRequest MotionPlanRequest
boost::function< bool(const planning_scene::PlanningSceneConstPtr &planning_scene, const planning_interface::MotionPlanRequest &req, planning_interface::MotionPlanResponse &res)> PlannerFn
std::vector< robot_trajectory::RobotTrajectoryPtr > trajectory_
static bool getConfigData(ros::NodeHandle &nh, std::map< std::string, XmlRpc::XmlRpcValue > &config, std::string param=std::string("stomp"))
Convenience method to load extract the parameters for each supported planning group.
#define ROS_ERROR_STREAM(args)
The PlanningContext specialization that wraps the STOMP algorithm.
CLASS_LOADER_REGISTER_CLASS(Dog, Base)