Robowflex  v0.1
Making MoveIt Easy
robowflex::SimpleCartesianPlanner Class Reference

A simple motion planner that uses interpolation of the end-effector in Cartesian space to find a path. Valid configurations are found using IK. This planner is not complete and typically only works for small movements of the end-effector. More...

#include <planning.h>

+ Inheritance diagram for robowflex::SimpleCartesianPlanner:

Public Member Functions

 SimpleCartesianPlanner (const RobotPtr &robot, const std::string &name="")
 Constructor. More...
 
 SimpleCartesianPlanner (SimpleCartesianPlanner const &)=delete
 
void operator= (SimpleCartesianPlanner const &)=delete
 
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. The scene, attempts, and timeout are used from request. More...
 
planning_interface::MotionPlanResponse plan (const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) override
 Plan a motion given a request and a scene. More...
 
void setMaxStep (double position, double rotation)
 Set the maximum step size allowed by the planner between output waypoints. More...
 
void setJumpThreshold (double prismatic, double revolute)
 Set the maximum difference in joint configurations allowed by the planner between output waypoints. More...
 
std::vector< std::stringgetPlannerConfigs () const override
 Return all planner configurations offered by this planner. Any of the configurations returned can be set as the planner for a motion planning query sent to plan(). More...
 
- Public Member Functions inherited from robowflex::Planner
 Planner (const RobotPtr &robot, const std::string &name="")
 Constructor. Takes in a robot description and an optional namespace name. If name is specified, planner parameters are namespaced under the namespace of robot. More...
 
 Planner (Planner const &)=delete
 
void operator= (Planner const &)=delete
 
virtual std::map< std::string, ProgressPropertygetProgressProperties (const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) const
 Retrieve the planner progress property map for this planner given a specific request. More...
 
const RobotPtr getRobot () const
 Return the robot for this planner. More...
 
const std::stringgetName () const
 Get the name of the planner. More...
 
virtual void preRun (const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request)
 This function is called before benchmarking. More...
 

Private Attributes

double max_step_pos_ {constants::cart_pos_step_size}
 Max EE step size for position in meters. More...
 
double max_step_rot_ {constants::cart_rot_step_size}
 Max EE step size for rotation in radians. More...
 
double jump_threshold_pri_ {constants::cart_pos_jump_tol}
 
double jump_threshold_rev_ {constants::cart_rot_jump_tol}
 

Additional Inherited Members

- Public Types inherited from robowflex::Planner
using ProgressProperty = std::function< std::string()>
 A function that returns the value of a planner property over the course of a run. More...
 
- Protected Attributes inherited from robowflex::Planner
RobotPtr robot_
 The robot to plan for. More...
 
IO::Handler handler_
 The parameter handler for the planner. More...
 
const std::string name_
 Namespace for the planner. More...
 

Detailed Description

A simple motion planner that uses interpolation of the end-effector in Cartesian space to find a path. Valid configurations are found using IK. This planner is not complete and typically only works for small movements of the end-effector.

Definition at line 184 of file robowflex_library/include/robowflex_library/planning.h.

Constructor & Destructor Documentation

◆ SimpleCartesianPlanner() [1/2]

SimpleCartesianPlanner::SimpleCartesianPlanner ( const RobotPtr robot,
const std::string name = "" 
)

Constructor.

SimpleCartesianPlanner

Definition at line 100 of file robowflex_library/src/planning.cpp.

101  : Planner(robot, name)
102 {
103 }
Planner(const RobotPtr &robot, const std::string &name="")
Constructor. Takes in a robot description and an optional namespace name. If name is specified,...
Functions for loading and animating robots in Blender.

◆ SimpleCartesianPlanner() [2/2]

robowflex::SimpleCartesianPlanner::SimpleCartesianPlanner ( SimpleCartesianPlanner const &  )
delete

Member Function Documentation

◆ getPlannerConfigs()

std::vector< std::string > SimpleCartesianPlanner::getPlannerConfigs ( ) const
overridevirtual

Return all planner configurations offered by this planner. Any of the configurations returned can be set as the planner for a motion planning query sent to plan().

Returns
A vector of strings of planner configuration names.

Implements robowflex::Planner.

Definition at line 244 of file robowflex_library/src/planning.cpp.

245 {
246  return std::vector<std::string>{"cartesian"};
247 }

◆ operator=()

void robowflex::SimpleCartesianPlanner::operator= ( SimpleCartesianPlanner const &  )
delete

◆ plan() [1/2]

planning_interface::MotionPlanResponse SimpleCartesianPlanner::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. The scene, attempts, and timeout are used from request.

Parameters
[in]startStarting state.
[in]requestThe desired end-effector pose.
Returns
The motion planning response generated by the planner.

Definition at line 146 of file robowflex_library/src/planning.cpp.

148 {
150  if (request.tips.size() > 1)
151  {
152  RBX_ERROR("SimpleCartesianPlanner only supports queries with a single goal!");
153  response.error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
154  return response;
155  }
156 
157  std::string tip = request.tips[0];
158  if (tip.empty())
159  {
160  const auto &tips = robot_->getSolverTipFrames(request.group);
161  if (tips.size() == 1)
162  tip = tips[0];
163  else
164  {
165  RBX_ERROR("Request needs tip frame name!");
166  response.error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
167  return response;
168  }
169  }
170 
171  // Get JMG, link model, and GSVCF
172  const auto &model = robot_->getModelConst();
173  const auto &jmg = model->getJointModelGroup(request.group);
174  const auto &lm = model->getLinkModel(tip);
175 
177  if (request.scene)
178  gsvcf = request.scene->getGSVCF(false);
179 
181 
184 
185  double time = 0;
186  bool success = false;
187  ros::WallTime start_time = ros::WallTime::now();
188 
189  for (std::size_t i = 0; //
190  not success //
191  and ((request.attempts) ? i < request.attempts : true) //
192  and ((request.timeout > 0.) ? time < request.timeout : true); //
193  ++i)
194  {
195  auto state = start;
196 
197  RobotPose pose;
198  request.sampleRegion(pose, 0);
199 
200 #if ROBOWFLEX_HAS_CARTESIAN_INTERPOLATOR
201  double percentage = //
202  moveit::core::CartesianInterpolator::computeCartesianPath( //
203  &state, jmg, traj, lm, pose, true, step, jump, gsvcf);
204 #else
205  double percentage = //
206  state.computeCartesianPath( //
207  jmg, traj, lm, pose, true, step, jump, gsvcf);
208 #endif
209 
210  // Check if successful, output is percent of path computed.
211  success = std::fabs(percentage - 1.) < constants::eps;
212  time = (ros::WallTime::now() - start_time).toSec();
213  }
214 
215  Trajectory output(robot_, request.group);
216  for (const auto &state : traj)
217  output.addSuffixWaypoint(*state);
218 
219  output.computeTimeParameterization();
220 
221  response.trajectory_ = output.getTrajectory();
222  response.planning_time_ = time;
223 
224  if (success)
225  response.error_code_.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
226  else
227  response.error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
228 
229  return response;
230 }
double max_step_rot_
Max EE step size for rotation in radians.
double max_step_pos_
Max EE step size for position in meters.
The Trajectory class is a wrapper around MoveIt!'s robot_trajectory::RobotTrajectory,...
Definition: trajectory.h:43
T empty(T... args)
T fabs(T... args)
#define RBX_ERROR(fmt,...)
Output a error logging message.
Definition: log.h:102
boost::function< bool(RobotState *robot_state, const JointModelGroup *joint_group, const double *joint_group_variable_values)> GroupStateValidityCallbackFn
static const double eps
Definition: constants.h:16
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.
Definition: adapter.h:24
const std::vector< std::string > tips
T size(T... args)
moveit_msgs::MoveItErrorCodes error_code_
robot_trajectory::RobotTrajectoryPtr trajectory_
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.
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.
T time(T... args)

◆ plan() [2/2]

planning_interface::MotionPlanResponse SimpleCartesianPlanner::plan ( const SceneConstPtr scene,
const planning_interface::MotionPlanRequest request 
)
overridevirtual

Plan a motion given a request and a scene.

Parameters
[in]sceneA planning scene for the same robot_ to compute the plan in.
[in]requestThe motion planning request to solve.
Returns
The motion planning response generated by the planner.

Implements robowflex::Planner.

Definition at line 106 of file robowflex_library/src/planning.cpp.

107 {
109  if (request.goal_constraints.size() > 1)
110  {
111  RBX_ERROR("SimpleCartesianPlanner only supports queries with a single goal!");
112  temp.error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
113  return temp;
114  }
115 
116  const auto &goal = request.goal_constraints[0];
117  if (not goal.joint_constraints.empty() or not goal.visibility_constraints.empty())
118  {
119  RBX_ERROR("SimpleCartesianPlanner only supports pose goals!");
120  temp.error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
121  return temp;
122  }
123 
124  if (goal.position_constraints.size() != 1 and goal.orientation_constraints.size() != 1)
125  {
126  RBX_ERROR("SimpleCartesianPlanner requires single position and orientation constraint!");
127  temp.error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS;
128  return temp;
129  }
130 
131  // Get sampleable region through IK Query
132  const auto &pc = goal.position_constraints[0];
133  const auto &oc = goal.orientation_constraints[0];
134  Robot::IKQuery query(request.group_name, pc, oc);
135  query.attempts = request.num_planning_attempts;
136  query.timeout = request.allowed_planning_time;
137  query.scene = scene;
138 
139  // Get starting state
140  auto state = robot_->allocState();
141  moveit::core::robotStateMsgToRobotState(request.start_state, *state);
142 
143  return plan(*state, query);
144 }
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....
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
Robot IK Query options. IK queries in Robowflex consist of: a) A position specified by some geometric...

◆ setJumpThreshold()

void SimpleCartesianPlanner::setJumpThreshold ( double  prismatic,
double  revolute 
)

Set the maximum difference in joint configurations allowed by the planner between output waypoints.

Parameters
[in]prismaticThe new threshold for movement of prismatic joints.
[in]revoluteThe new threshold for movement of revolute joints.

Definition at line 238 of file robowflex_library/src/planning.cpp.

239 {
240  jump_threshold_pri_ = prismatic;
241  jump_threshold_rev_ = revolute;
242 }

◆ setMaxStep()

void SimpleCartesianPlanner::setMaxStep ( double  position,
double  rotation 
)

Set the maximum step size allowed by the planner between output waypoints.

Parameters
[in]positionThe new step size for the position of the end-effector.
[in]rotationThe new step size for the rotation of the end-effector.

Definition at line 232 of file robowflex_library/src/planning.cpp.

233 {
234  max_step_pos_ = position;
235  max_step_rot_ = rotation;
236 }

Member Data Documentation

◆ jump_threshold_pri_

double robowflex::SimpleCartesianPlanner::jump_threshold_pri_ {constants::cart_pos_jump_tol}
private

Max jump for prismatic joints in meters.

Definition at line 230 of file robowflex_library/include/robowflex_library/planning.h.

◆ jump_threshold_rev_

double robowflex::SimpleCartesianPlanner::jump_threshold_rev_ {constants::cart_rot_jump_tol}
private

Max jump for revolute joints in radians.

Definition at line 232 of file robowflex_library/include/robowflex_library/planning.h.

◆ max_step_pos_

double robowflex::SimpleCartesianPlanner::max_step_pos_ {constants::cart_pos_step_size}
private

Max EE step size for position in meters.

Definition at line 228 of file robowflex_library/include/robowflex_library/planning.h.

◆ max_step_rot_

double robowflex::SimpleCartesianPlanner::max_step_rot_ {constants::cart_rot_step_size}
private

Max EE step size for rotation in radians.

Definition at line 229 of file robowflex_library/include/robowflex_library/planning.h.


The documentation for this class was generated from the following files: