3 #include <moveit/robot_state/conversions.h>
13 #define ROBOWFLEX_HAS_CARTESIAN_INTERPOLATOR \
14 ROBOWFLEX_INCLUDE_EXISTS("moveit/robot_state/cartesian_interpolator.h")
16 #if ROBOWFLEX_HAS_CARTESIAN_INTERPOLATOR
17 #include <moveit/robot_state/cartesian_interpolator.h>
27 : robot_(
robot), handler_(robot_->getHandler(), name), name_(name)
74 auto result = planner->plan(
scene, request);
93 return planners_.front()->getPlannerConfigs();
109 if (request.goal_constraints.size() > 1)
111 RBX_ERROR(
"SimpleCartesianPlanner only supports queries with a single goal!");
112 temp.
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
116 const auto &goal = request.goal_constraints[0];
117 if (not goal.joint_constraints.empty() or not goal.visibility_constraints.empty())
119 RBX_ERROR(
"SimpleCartesianPlanner only supports pose goals!");
120 temp.
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
124 if (goal.position_constraints.size() != 1 and goal.orientation_constraints.size() != 1)
126 RBX_ERROR(
"SimpleCartesianPlanner requires single position and orientation constraint!");
127 temp.
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
132 const auto &pc = goal.position_constraints[0];
133 const auto &oc = goal.orientation_constraints[0];
135 query.
attempts = request.num_planning_attempts;
136 query.
timeout = request.allowed_planning_time;
140 auto state =
robot_->allocState();
143 return plan(*state, query);
152 RBX_ERROR(
"SimpleCartesianPlanner only supports queries with a single goal!");
153 response.
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
165 RBX_ERROR(
"Request needs tip frame name!");
166 response.
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
172 const auto &model =
robot_->getModelConst();
173 const auto &jmg = model->getJointModelGroup(request.
group);
174 const auto &lm = model->getLinkModel(tip);
178 gsvcf = request.
scene->getGSVCF(
false);
186 bool success =
false;
187 ros::WallTime start_time = ros::WallTime::now();
200 #if ROBOWFLEX_HAS_CARTESIAN_INTERPOLATOR
202 moveit::core::CartesianInterpolator::computeCartesianPath(
203 &state, jmg, traj, lm, pose,
true, step, jump, gsvcf);
206 state.computeCartesianPath(
207 jmg, traj, lm, pose,
true, step, jump, gsvcf);
212 time = (ros::WallTime::now() - start_time).toSec();
216 for (
const auto &state : traj)
225 response.
error_code_.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
227 response.
error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
262 pipeline_->generatePlan(
scene->getSceneConst(), request, response);
274 if (config_file.
empty())
280 RBX_ERROR(
"Failed to load planner configs.");
286 const auto &planner_configs = config.second[
"planner_configs"];
289 for (YAML::const_iterator it = planner_configs.begin(); it != planner_configs.end(); ++it)
301 : max_goal_samples(10)
302 , max_goal_sampling_attempts(1000)
303 , max_planning_threads(4)
304 , max_solution_segment_length(0.0)
305 , max_state_sampling_attempts(4)
306 , minimum_waypoint_count(10)
307 , simplify_solutions(true)
308 , hybridize_solutions(true)
309 , interpolate_solutions(true)
310 , use_constraints_approximations(false)
311 , display_random_valid_states(false)
312 , link_for_exploration_tree(
"")
313 , maximum_waypoint_distance(0.0)
320 handler.
setParam(prefix +
"max_goal_samples", max_goal_samples);
321 handler.
setParam(prefix +
"max_goal_sampling_attempts", max_goal_sampling_attempts);
322 handler.
setParam(prefix +
"max_planning_threads", max_planning_threads);
323 handler.
setParam(prefix +
"max_solution_segment_length", max_solution_segment_length);
324 handler.
setParam(prefix +
"max_state_sampling_attempts", max_state_sampling_attempts);
325 handler.
setParam(prefix +
"minimum_waypoint_count", minimum_waypoint_count);
326 handler.
setParam(prefix +
"simplify_solutions", simplify_solutions);
327 handler.
setParam(prefix +
"use_constraints_approximations", use_constraints_approximations);
328 handler.
setParam(prefix +
"display_random_valid_states", display_random_valid_states);
329 handler.
setParam(prefix +
"link_for_exploration_tree", link_for_exploration_tree);
330 handler.
setParam(prefix +
"maximum_waypoint_distance", maximum_waypoint_distance);
340 {
"default_planner_request_adapters/AddTimeParameterization",
341 "default_planner_request_adapters/FixWorkspaceBounds",
342 "default_planner_request_adapters/FixStartStateBounds",
343 "default_planner_request_adapters/FixStartStateCollision",
344 "default_planner_request_adapters/FixStartStatePathConstraints"});
358 handler_.setParam(
"planning_plugin", plugin);
364 if (i < adapters.size() - 1)
368 handler_.setParam(
"request_adapters", ss.
str());
371 pipeline_.reset(
new planning_pipeline::PlanningPipeline(robot_->getModelConst(), handler_.getHandle(),
372 "planning_plugin",
"request_adapters"));
388 if (config_file.
empty())
394 RBX_ERROR(
"Failed to load planner configs.");
408 : planning_time_limit(10.0)
409 , max_iterations(200)
410 , max_iterations_after_collision_free(5)
411 , smoothness_cost_weight(0.1)
412 , obstacle_cost_weight(0.0)
413 , learning_rate(0.01)
415 , add_randomness(false)
416 , smoothness_cost_velocity(0.0)
417 , smoothness_cost_acceleration(1.0)
418 , smoothness_cost_jerk(0.0)
419 , hmc_discretization(0.01)
420 , hmc_stochasticity(0.01)
421 , hmc_annealing_factor(0.99)
422 , use_hamiltonian_monte_carlo(false)
423 , ridge_factor(0.001)
424 , use_pseudo_inverse(false)
425 , pseudo_inverse_ridge_factor(1e-4)
426 , animate_endeffector(false)
427 , animate_endeffector_segment(
"")
428 , joint_update_limit(0.1)
429 , collision_clearence(0.2)
430 , collision_threshold(0.07)
431 , random_jump_amount(1.0)
432 , use_stochastic_descent(true)
433 , enable_failure_recovery(true)
434 , max_recovery_attempts(5)
435 , trajectory_initialization_method(
"quintic-spline")
436 , start_state_max_bounds_error(0.1)
443 handler.
setParam(prefix +
"planning_time_limit", planning_time_limit);
444 handler.
setParam(prefix +
"max_iterations", max_iterations);
445 handler.
setParam(prefix +
"max_iterations_after_collision_free", max_iterations_after_collision_free);
446 handler.
setParam(prefix +
"smoothness_cost_weight", smoothness_cost_weight);
447 handler.
setParam(prefix +
"obstacle_cost_weight", obstacle_cost_weight);
448 handler.
setParam(prefix +
"learning_rate", learning_rate);
449 handler.
setParam(prefix +
"animate_path", animate_path);
450 handler.
setParam(prefix +
"add_randomness", add_randomness);
451 handler.
setParam(prefix +
"smoothness_cost_velocity", smoothness_cost_velocity);
452 handler.
setParam(prefix +
"smoothness_cost_acceleration", smoothness_cost_acceleration);
453 handler.
setParam(prefix +
"smoothness_cost_jerk", smoothness_cost_jerk);
454 handler.
setParam(prefix +
"hmc_discretization", hmc_discretization);
455 handler.
setParam(prefix +
"hmc_stochasticity", hmc_stochasticity);
456 handler.
setParam(prefix +
"hmc_annealing_factor", hmc_annealing_factor);
457 handler.
setParam(prefix +
"use_hamiltonian_monte_carlo", use_hamiltonian_monte_carlo);
458 handler.
setParam(prefix +
"ridge_factor", ridge_factor);
459 handler.
setParam(prefix +
"use_pseudo_inverse", use_pseudo_inverse);
460 handler.
setParam(prefix +
"pseudo_inverse_ridge_factor", pseudo_inverse_ridge_factor);
461 handler.
setParam(prefix +
"animate_endeffector", animate_endeffector);
462 handler.
setParam(prefix +
"animate_endeffector_segment", animate_endeffector_segment);
463 handler.
setParam(prefix +
"joint_update_limit", joint_update_limit);
464 handler.
setParam(prefix +
"collision_clearence", collision_clearence);
465 handler.
setParam(prefix +
"collision_threshold", collision_threshold);
466 handler.
setParam(prefix +
"random_jump_amount", random_jump_amount);
467 handler.
setParam(prefix +
"use_stochastic_descent", use_stochastic_descent);
468 handler.
setParam(prefix +
"enable_failure_recovery", enable_failure_recovery);
469 handler.
setParam(prefix +
"max_recovery_attempts", max_recovery_attempts);
470 handler.
setParam(prefix +
"trajectory_initialization_method", trajectory_initialization_method);
471 handler.
setParam(prefix +
"start_state_max_bounds_error", start_state_max_bounds_error);
481 {
"default_planner_request_adapters/FixWorkspaceBounds",
482 "default_planner_request_adapters/FixStartStateBounds",
483 "default_planner_request_adapters/FixStartStateCollision",
484 "default_planner_request_adapters/FixStartStatePathConstraints",
486 "default_planner_request_adapters/AddTimeParameterization"});
497 return finishInitialize(plugin, adapters);
506 return finishInitialize(plugin, adapters);
512 configs_.emplace_back(
"chomp");
513 handler_.setParam(
"planning_plugin", plugin);
519 if (i < adapters.size() - 1)
523 handler_.setParam(
"request_adapters", ss.
str());
524 pipeline_.reset(
new planning_pipeline::PlanningPipeline(robot_->getModelConst(), handler_.getHandle(),
525 "planning_plugin",
"request_adapters"));
542 {
"default_planner_request_adapters/AddTimeParameterization",
543 "default_planner_request_adapters/FixWorkspaceBounds",
544 "default_planner_request_adapters/FixStartStateBounds",
545 "default_planner_request_adapters/FixStartStateCollision",
546 "default_planner_request_adapters/FixStartStatePathConstraints"});
559 handler_.setParam(
"planning_plugin", plugin);
565 if (i < adapters.size() - 1)
569 handler_.setParam(
"request_adapters", ss.
str());
571 pipeline_.reset(
new planning_pipeline::PlanningPipeline(robot_->getModelConst(), handler_.getHandle(),
572 "planning_plugin",
"request_adapters"));
ROS parameter server handler to handle namespacing and automatic parameter deletion.
void setParam(const std::string &key, const T &value)
Sets a parameter on the parameter server.
void loadYAMLtoROS(const YAML::Node &node, const std::string &prefix="")
Loads the contents of a YAML node to the parameter server under a prefix.
OMPLPipelinePlanner(const RobotPtr &robot, const std::string &name="")
static const std::string DEFAULT_PLUGIN
The default OMPL plugin.
static const std::vector< std::string > DEFAULT_ADAPTERS
The default planning adapters.
std::vector< std::string > getPlannerConfigs() const override
Return all planner configurations offered by this planner. Any of the configurations returned can be ...
bool initialize(const std::string &config_file="", const Settings &settings=Settings(), const std::string &plugin=DEFAULT_PLUGIN, const std::vector< std::string > &adapters=DEFAULT_ADAPTERS)
Initialize planning pipeline. Loads OMPL planning plugin plugin with the planning adapters adapters....
Settings descriptor for settings provided by the default MoveIt! OMPL planning pipeline.
void setParam(IO::Handler &handler) const
Sets member variables on the parameter server using handler.
Settings()
Constructor. Initialized here so an empty class can be used as default arguments in a function.
A motion planner that uses the MoveIt! planning pipeline to load a planner plugin.
PipelinePlanner(const RobotPtr &robot, const std::string &name="")
Constructor.
planning_pipeline::PlanningPipelinePtr pipeline_
Loaded planning pipeline plugin.
planning_interface::MotionPlanResponse plan(const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) override
Plan a motion given a request and a scene. Uses the planning pipeline's generatePlan() method,...
An abstract interface to a motion planning algorithm.
const RobotPtr getRobot() const
Return the robot for this planner.
const std::string & getName() const
Get the name of the planner.
const std::string name_
Namespace for the planner.
RobotPtr robot_
The robot to plan for.
virtual void preRun(const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request)
This function is called before benchmarking.
virtual std::map< std::string, ProgressProperty > getProgressProperties(const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) const
Retrieve the planner progress property map for this planner given a specific request.
Planner(const RobotPtr &robot, const std::string &name="")
Constructor. Takes in a robot description and an optional namespace name. If name is specified,...
std::shared_ptr< Pool::Job< planning_interface::MotionPlanResponse > > submit(const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request)
Submit a motion planning request job to the queue.
std::mutex mutex_
Planner mutex.
planning_interface::MotionPlanResponse plan(const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) override
Plan a motion given a request and a scene. Forwards the planning request onto the thread pool to be e...
std::condition_variable cv_
Planner condition variable.
std::queue< PlannerPtr > planners_
Motion planners.
std::vector< std::string > getPlannerConfigs() const override
Return all planner configurations offered by this planner. Any of the configurations returned can be ...
PoolPlanner(const RobotPtr &robot, unsigned int n=std::thread::hardware_concurrency(), const std::string &name="")
Constructor. Takes in a robot description and an optional namespace name. If name is specified,...
std::shared_ptr< Job< RT > > submit(const std::function< RT(Args...)> &&function, Args &&... args) const
Submit a function with arguments to be processed by the thread pool. Submitted functions must be wrap...
A shared pointer wrapper for robowflex::Robot.
A const shared pointer wrapper for robowflex::Scene.
double jump_threshold_pri_
planning_interface::MotionPlanResponse plan(const robot_state::RobotState &start, const Robot::IKQuery &request)
Plan a Cartesian motion (interpolation) given a request and a scene from a start configuration....
void setJumpThreshold(double prismatic, double revolute)
Set the maximum difference in joint configurations allowed by the planner between output waypoints.
SimpleCartesianPlanner(const RobotPtr &robot, const std::string &name="")
Constructor.
std::vector< std::string > getPlannerConfigs() const override
Return all planner configurations offered by this planner. Any of the configurations returned can be ...
double jump_threshold_rev_
double max_step_rot_
Max EE step size for rotation in radians.
double max_step_pos_
Max EE step size for position in meters.
void setMaxStep(double position, double rotation)
Set the maximum step size allowed by the planner between output waypoints.
The Trajectory class is a wrapper around MoveIt!'s robot_trajectory::RobotTrajectory,...
bool computeTimeParameterization(double max_velocity=1., double max_acceleration=1.)
Computes the time parameterization of a path according to a desired max velocity or acceleration.
void addSuffixWaypoint(const robot_state::RobotState &state, double dt=1.)
Add a waypoint at the end of the trajectory.
robot_trajectory::RobotTrajectoryPtr & getTrajectory()
Get a reference to the trajectory.
static const std::string DEFAULT_PLUGIN
The default CHOMP plugin.
CHOMPPipelinePlanner(const RobotPtr &robot, const std::string &name="")
bool initialize(const std::string &config_file, const std::string &plugin=DEFAULT_PLUGIN, const std::vector< std::string > &adapters=DEFAULT_ADAPTERS)
Initialize planning pipeline. Loads CHOMP planning plugin plugin with the planning adapters adapters....
static const std::vector< std::string > DEFAULT_ADAPTERS
The default planning adapters.
std::vector< std::string > getPlannerConfigs() const override
Return all planner configurations offered by this planner. Any of the configurations returned can be ...
bool finishInitialize(const std::string &plugin, const std::vector< std::string > &adapters)
Finalize the initialization process after parameters are set.
Settings descriptor for settings provided by the default MoveIt! CHOMP planning pipeline.
void setParam(IO::Handler &handler) const
Sets member variables on the parameter server using handler.
CHOMPSettings()
Constructor. Initialized here so an empty class can be used as default arguments in a function.
TrajOptPipelinePlanner(const RobotPtr &robot, const std::string &name="")
bool initialize(const std::string &config_file="", const std::string &plugin=DEFAULT_PLUGIN, const std::vector< std::string > &adapters=DEFAULT_ADAPTERS)
Initialize planning pipeline. Loads TrajOpt planning plugin plugin with the planning adapters adapter...
static const std::vector< std::string > DEFAULT_ADAPTERS
The default planning adapters.
static const std::string DEFAULT_PLUGIN
The default TrajOpt plugin.
#define RBX_ERROR(fmt,...)
Output a error logging message.
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
boost::function< bool(RobotState *robot_state, const JointModelGroup *joint_group, const double *joint_group_variable_values)> GroupStateValidityCallbackFn
moveit_msgs::MotionPlanRequest MotionPlanRequest
Functions for loading and animating robots in Blender.
std::pair< bool, YAML::Node > loadFileToYAML(const std::string &path)
Loads a file to a YAML node.
bool loadOMPLConfig(IO::Handler &handler, const std::string &config_file, std::vector< std::string > &configs)
Loads an OMPL configuration YAML file onto the parameter server.
bool loadConfig(IO::Handler &handler, const std::string &config_file)
Loads configuration YAML file onto the parameter server.
Main namespace. Contains all library classes and functions.
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.
Functions for loading and animating scenes in Blender.
const std::vector< std::string > tips
moveit_msgs::MoveItErrorCodes error_code_
robot_trajectory::RobotTrajectoryPtr trajectory_
Robot IK Query options. IK queries in Robowflex consist of: a) A position specified by some geometric...
std::string group
Target joint group to do IK for.
bool sampleRegion(RobotPose &pose, std::size_t index) const
Sample desired end-effector pose for region at index.
double timeout
Timeout for each query.
SceneConstPtr scene
If provided, use this scene for collision checking.
std::size_t attempts
IK attempts (samples within regions).
std::vector< std::string > tips
List of end-effectors.