Robowflex  v0.1
Making MoveIt Easy
robowflex_dart/src/planning.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #include <chrono>
4 #include <thread>
5 #include <utility>
6 
7 #include <ompl/base/ConstrainedSpaceInformation.h>
8 #include <ompl/base/spaces/constraint/ProjectedStateSpace.h>
9 
10 #include <moveit_msgs/MotionPlanRequest.h>
11 
12 #include <robowflex_library/log.h>
13 #include <robowflex_library/tf.h>
14 
16 #include <robowflex_dart/tsr.h>
17 #include <robowflex_dart/world.h>
18 
19 using namespace robowflex::darts;
20 
21 ///
22 /// ConstraintExtractor
23 ///
24 ConstraintExtractor::ConstraintExtractor(const ompl::base::SpaceInformationPtr &si)
25 {
27 }
28 
29 void ConstraintExtractor::setSpaceInformation(const ompl::base::SpaceInformationPtr &si)
30 {
31  space_info_ = si;
32  is_constrained_ = std::dynamic_pointer_cast<ompl::base::ConstrainedSpaceInformation>(si) != nullptr;
33 }
34 
35 StateSpace::StateType *ConstraintExtractor::toState(ompl::base::State *state) const
36 {
37  if (is_constrained_)
38  return fromConstrainedState(state);
39 
40  return fromUnconstrainedState(state);
41 }
42 
43 const StateSpace::StateType *ConstraintExtractor::toStateConst(const ompl::base::State *state) const
44 {
45  return toState(const_cast<ompl::base::State *>(state));
46 }
47 
49 {
50  return state->as<ompl::base::ConstrainedStateSpace::StateType>()->getState()->as<StateSpace::StateType>();
51 }
52 
54 ConstraintExtractor::fromConstrainedStateConst(const ompl::base::State *state) const
55 {
56  return fromConstrainedState(const_cast<ompl::base::State *>(state));
57 }
58 
60 {
61  return state->as<StateSpace::StateType>();
62 }
63 
65 ConstraintExtractor::fromUnconstrainedStateConst(const ompl::base::State *state) const
66 {
67  return fromUnconstrainedState(const_cast<ompl::base::State *>(state));
68 }
69 
71 {
72  return (is_constrained_ ?
73  space_info_->getStateSpace()->as<ompl::base::ConstrainedStateSpace>()->getSpace() :
74  space_info_->getStateSpace())
75  ->as<StateSpace>();
76 }
77 
78 ///
79 /// TSRGoal
80 ///
81 
82 TSRGoal::TSRGoal(const ompl::base::SpaceInformationPtr &si, const WorldPtr &world,
83  const std::vector<TSRPtr> &tsrs)
84  : ompl::base::GoalLazySamples(
85  si, std::bind(&TSRGoal::sample, this, std::placeholders::_1, std::placeholders::_2), false, 1e-3)
87  , world_(world->clone())
88  , tsr_(std::make_shared<TSRSet>(world_, tsrs))
89  // Have to allocate our own sampler from scratch since the constrained sampler might use the underlying
90  // world used by the planner (e.g., in project)
91  , sampler_(std::make_shared<StateSpace::StateSampler>(getSpace()))
92 {
93  tsr_->useWorldIndices(getSpace()->getIndices());
94  tsr_->setWorldIndices(getSpace()->getIndices());
95 
96  tsr_->setWorldLowerLimits(getSpace()->getLowerBound());
97  tsr_->setWorldUpperLimits(getSpace()->getUpperBound());
98 
99  tsr_->initialize();
100 }
101 
102 TSRGoal::TSRGoal(const ompl::base::SpaceInformationPtr &si, const WorldPtr &world, const TSRPtr tsr)
103  : TSRGoal(si, world, std::vector<TSRPtr>{tsr})
104 {
105 }
106 
107 TSRGoal::TSRGoal(const PlanBuilder &builder, TSRPtr tsr)
108  : TSRGoal(builder, std::vector<TSRPtr>{std::move(tsr)})
109 {
110 }
111 
113  : TSRGoal(builder.info, builder.world, [&] {
114  std::vector<TSRPtr> temp = builder.path_constraints;
115  temp.insert(temp.end(), tsrs.begin(), tsrs.end());
116  return temp;
117  }())
118 {
119 }
120 
122 {
123  stopSampling();
124 }
125 
126 bool TSRGoal::sample(const ompl::base::GoalLazySamples * /*gls*/, ompl::base::State *state)
127 {
128  if (getStateCount() >= options.max_samples)
129  return false;
130 
131  bool success = false;
132  while (not terminateSamplingThread_ and not success)
133  {
134  auto &&as = toState(state);
135  sampler_->sampleUniform(as);
136 
137  auto &&x = Eigen::Map<Eigen::VectorXd>(as->values, si_->getStateDimension());
138 
139  if (tsr_->numTSRs() == 1 or not options.use_gradient)
140  success = tsr_->solveWorldState(x);
141 
142  else if (options.use_gradient)
143  success = tsr_->solveGradientWorldState(x);
144 
145  success &= si_->satisfiesBounds(state);
146  si_->enforceBounds(state);
147  }
148 
149  return true;
150 }
151 
152 double TSRGoal::distanceGoal(const ompl::base::State *state) const
153 {
154  auto &&as = toStateConst(state);
155  auto &&x = Eigen::Map<const Eigen::VectorXd>(as->values, si_->getStateDimension());
156  return tsr_->distanceWorldState(x);
157 }
158 
160 {
161  return tsr_;
162 }
163 
164 ///
165 /// JointRegionGoal
166 ///
167 
168 JointRegionGoal::JointRegionGoal(const PlanBuilder &builder, const Eigen::Ref<const Eigen::VectorXd> &state,
169  double tolerance)
170  : JointRegionGoal(builder, //
171  state - Eigen::VectorXd::Constant(state.size(), tolerance), //
172  state + Eigen::VectorXd::Constant(state.size(), tolerance))
173 {
174 }
175 
176 JointRegionGoal::JointRegionGoal(const PlanBuilder &builder, const Eigen::Ref<const Eigen::VectorXd> &lower,
177  const Eigen::Ref<const Eigen::VectorXd> &upper)
178  : ompl::base::GoalSampleableRegion(builder.info)
179  , ConstraintExtractor(builder.info)
180  , lower_(si_->allocState())
181  , upper_(si_->allocState())
182 {
183  if (lower.size() != upper.size())
184  throw std::runtime_error("Bound size mismatch!");
185 
186  if (builder.space->getDimension() != lower.size())
187  throw std::runtime_error("Bound size mismatch!");
188 
189  toState(lower_)->data = lower;
190  toState(upper_)->data = upper;
191 }
192 
194 {
195  si_->freeState(lower_);
196  si_->freeState(upper_);
197 }
198 
199 void JointRegionGoal::sampleGoal(ompl::base::State *state) const
200 {
201  auto &s = toState(state)->data;
202  const auto &l = toStateConst(lower_)->data;
203  const auto &u = toStateConst(upper_)->data;
204 
205  for (int i = 0; i < l.size(); ++i)
206  s[i] = rng_.uniformReal(l[i], u[i]);
207 }
208 
210 {
212 }
213 
214 double JointRegionGoal::distanceGoal(const ompl::base::State *state) const
215 {
216  const auto &s = toStateConst(state)->data;
217  const auto &l = toStateConst(lower_)->data;
218  const auto &u = toStateConst(upper_)->data;
219 
220  const auto &ss = std::dynamic_pointer_cast<StateSpace>(si_->getStateSpace());
221 
222  double d = 0.;
223  for (int i = 0; i < l.size(); ++i)
224  {
225  const auto &joint = ss->getJoint(i);
226  const auto &sv = joint->getSpaceVarsConst(s);
227  const auto &lv = joint->getSpaceVarsConst(l);
228  const auto &uv = joint->getSpaceVarsConst(u);
229 
230  if (sv[0] < lv[0])
231  d += joint->distance(sv, lv);
232  if (sv[0] > uv[0])
233  d += joint->distance(sv, uv);
234  }
235 
236  return d;
237 }
238 
239 ///
240 /// PlanBuilder
241 ///
242 
243 PlanBuilder::PlanBuilder(WorldPtr world) : rspace(std::make_shared<StateSpace>(world)), world(world)
244 {
245 }
246 
247 void PlanBuilder::getWorkspaceBoundsFromMessage(const moveit_msgs::MotionPlanRequest &msg)
248 {
249  const auto &mic = msg.workspace_parameters.min_corner;
250  world->getWorkspaceLow()[0] = mic.x;
251  world->getWorkspaceLow()[1] = mic.y;
252  world->getWorkspaceLow()[2] = mic.z;
253 
254  const auto &mac = msg.workspace_parameters.max_corner;
255  world->getWorkspaceHigh()[0] = mac.x;
256  world->getWorkspaceHigh()[1] = mac.y;
257  world->getWorkspaceHigh()[2] = mac.z;
258 }
259 
261  const moveit_msgs::MotionPlanRequest &msg)
262 {
263  bool cyclic = false;
264  if (not msg.path_constraints.position_constraints.empty() or
265  not msg.path_constraints.orientation_constraints.empty())
266  cyclic = true;
267 
268  addGroup(robot_name, msg.group_name, cyclic ? 2 : 0);
269 }
270 
272  const moveit_msgs::MotionPlanRequest &msg)
273 {
274  auto robot = world->getRobot(robot_name);
275  for (std::size_t i = 0; i < msg.start_state.joint_state.name.size(); ++i)
276  {
277  std::string name = msg.start_state.joint_state.name[i];
278  double value = msg.start_state.joint_state.position[i];
279 
280  robot->setJoint(name, value);
281  }
282 
284 }
285 
288 {
289  std::size_t n = rspace->getDimension();
290  Eigen::VectorXd lower(n);
291  Eigen::VectorXd upper(n);
292 
293  for (const auto &msg : msgs)
294  {
295  const auto &joint = rspace->getJoint(msg.joint_name);
296  joint->getSpaceVars(lower)[0] = msg.position - msg.tolerance_below;
297  joint->getSpaceVars(upper)[0] = msg.position + msg.tolerance_above;
298  }
299 
300  return std::make_shared<JointRegionGoal>(*this, lower, upper);
301 }
302 
304  const moveit_msgs::PositionConstraint &msg) const
305 {
306  TSR::Specification spec;
307  spec.setFrame(robot_name, msg.link_name);
308  if (not msg.header.frame_id.empty() and msg.header.frame_id != "world")
309  spec.setBase(robot_name, msg.header.frame_id);
310 
311  if (not msg.constraint_region.meshes.empty())
312  {
313  RBX_ERROR("Invalid Position Constraint");
314  return nullptr;
315  }
316 
317  if (msg.constraint_region.primitives.size() != 1)
318  {
319  RBX_ERROR("Invalid Position Constraint");
320  return nullptr;
321  }
322 
323  spec.setNoRotTolerance();
324 
325  // get pose
326  spec.setPose(TF::poseMsgToEigen(msg.constraint_region.primitive_poses[0]));
327  spec.setPosition(spec.getPosition() + TF::vectorMsgToEigen(msg.target_point_offset));
328 
329  auto &&primitive = msg.constraint_region.primitives[0];
330  if (primitive.type == shape_msgs::SolidPrimitive::BOX)
331  {
332  spec.setXPosTolerance(primitive.dimensions[0]);
333  spec.setYPosTolerance(primitive.dimensions[1]);
334  spec.setZPosTolerance(primitive.dimensions[2]);
335  }
336  else if (primitive.type == shape_msgs::SolidPrimitive::SPHERE)
337  {
338  spec.setXPosTolerance(primitive.dimensions[0]);
339  spec.setYPosTolerance(primitive.dimensions[0]);
340  spec.setZPosTolerance(primitive.dimensions[0]);
341  }
342 
343  return std::make_shared<TSR>(world, spec);
344 }
345 
347  const moveit_msgs::OrientationConstraint &msg) const
348 {
349  TSR::Specification spec;
350  spec.setFrame(robot_name, msg.link_name);
351  if (not msg.header.frame_id.empty() and msg.header.frame_id != "world")
352  spec.setBase(robot_name, msg.header.frame_id);
353 
354  spec.setRotation(TF::quaternionMsgToEigen(msg.orientation));
355  spec.setNoPosTolerance();
356  spec.setXRotTolerance(msg.absolute_x_axis_tolerance);
357  spec.setYRotTolerance(msg.absolute_y_axis_tolerance);
358  spec.setZRotTolerance(msg.absolute_z_axis_tolerance);
359 
360  return std::make_shared<TSR>(world, spec);
361 }
362 
364  const moveit_msgs::MotionPlanRequest &msg)
365 {
366  for (const auto &constraint : msg.path_constraints.position_constraints)
368  for (const auto &constraint : msg.path_constraints.orientation_constraints)
370 }
371 
372 ompl::base::GoalPtr PlanBuilder::getGoalFromMessage(const std::string &robot_name,
373  const moveit_msgs::MotionPlanRequest &msg)
374 {
375  // TODO get other goals as well
376  std::vector<TSRPtr> tsrs;
377  for (const auto &constraint : msg.goal_constraints[0].position_constraints)
379  for (const auto &constraint : msg.goal_constraints[0].orientation_constraints)
381 
382  if (tsrs.empty())
383  return fromJointConstraints(msg.goal_constraints[0].joint_constraints);
384 
385  return getGoalTSR(tsrs);
386 }
387 
388 ompl::base::GoalPtr PlanBuilder::fromMessage(const std::string &robot_name,
389  const moveit_msgs::MotionPlanRequest &msg)
390 {
392  getGroupFromMessage(robot_name, msg);
393  getStartFromMessage(robot_name, msg);
394  getPathConstraintsFromMessage(robot_name, msg);
395  initialize();
396 
397  auto goal = getGoalFromMessage(robot_name, msg);
398  setGoal(goal);
399 
400  return goal;
401 }
402 
403 void PlanBuilder::addGroup(const std::string &skeleton, const std::string &name, std::size_t cyclic)
404 {
405  rspace->addGroup(skeleton, name, cyclic);
406 }
407 
409 {
410  path_constraints.emplace_back(tsr);
411 }
412 
414 {
415  start = Eigen::VectorXd::Zero(rspace->getDimension());
416  rspace->getWorldState(world, start);
417 }
418 
419 void PlanBuilder::setStartConfiguration(const Eigen::Ref<const Eigen::VectorXd> &q)
420 {
421  start = q;
422 }
423 
425 {
426  setStartConfiguration(Eigen::Map<const Eigen::VectorXd>(q.data(), rspace->getDimension()));
427 }
428 
430 {
431  if (space)
432  {
433  auto *state = sampleState();
434  setStartConfiguration(toState(state)->data);
435  space->freeState(state);
436  }
437 }
438 
440 {
441  Eigen::VectorXd goal = Eigen::VectorXd::Zero(rspace->getDimension());
442  rspace->getWorldState(world, goal);
443  return getGoalConfiguration(goal);
444 }
445 
447 PlanBuilder::getGoalConfiguration(const Eigen::Ref<const Eigen::VectorXd> &q)
448 {
449  if (not space)
450  throw std::runtime_error("Builder must be initialized before creating goal!");
451 
452  ompl::base::ScopedState<> goal_state(space);
453  toState(goal_state.get())->data = q;
454 
455  auto goal = std::make_shared<ompl::base::GoalStates>(info);
456  goal->addState(goal_state);
457 
458  return goal;
459 }
460 
462 {
463  return getGoalConfiguration(Eigen::Map<const Eigen::VectorXd>(q.data(), rspace->getDimension()));
464 }
465 
467 {
468  return getGoalTSR(std::vector<TSRPtr>{tsr});
469 }
470 
472 {
473  if (not info)
474  throw std::runtime_error("Builder must be initialized before creating goal!");
475 
476  return std::make_shared<TSRGoal>(*this, tsrs);
477 }
478 
480 {
481  if (space)
482  {
483  auto *state = sampleState();
484  auto goal = getGoalConfiguration(toState(state)->data);
485  space->freeState(state);
486 
487  return goal;
488  }
489 
490  return nullptr;
491 }
492 
493 void PlanBuilder::setGoal(const ompl::base::GoalPtr &goal)
494 {
495  goal_ = goal;
496 
497  if (ss)
498  ss->setGoal(goal_);
499 }
500 
502 {
503  if (path_constraints.empty())
505  else
507 
509 }
510 
512 {
513  ompl::base::ScopedState<> start_state(space);
514  toState(start_state.get())->data = start;
515  ss->setStartState(start_state);
516  if (not goal_)
517  throw std::runtime_error("No goal setup in PlanBuilder!");
518  ss->setGoal(goal_);
519 
520  ss->setup();
521 }
522 
524 {
525  world->clearIKModules();
526  rspace->setMetricSpace(false);
527 
528  rinfo = std::make_shared<ompl::base::SpaceInformation>(rspace);
529  rinfo->setStateValidityChecker(getSVCUnconstrained());
530 
531  constraint = std::make_shared<TSRConstraint>(rspace, path_constraints);
532 
533  auto pss = std::make_shared<ompl::base::ProjectedStateSpace>(rspace, constraint);
534  space = pss;
535  info = std::make_shared<ompl::base::ConstrainedSpaceInformation>(pss);
536 
537  ss = std::make_shared<ompl::geometric::SimpleSetup>(info);
539 
540  pss->setDelta(options.constraints.delta);
541  pss->setLambda(options.constraints.lambda);
542 }
543 
545 {
546  space = rspace;
547  ss = std::make_shared<ompl::geometric::SimpleSetup>(space);
549 
550  rinfo = info = ss->getSpaceInformation();
551 }
552 
553 ompl::base::State *PlanBuilder::sampleState() const
554 {
555  if (space)
556  {
557  auto sampler = space->allocStateSampler();
558  auto *state = space->allocState();
559 
560  bool valid = false;
561  bool constrained = false;
562  do
563  {
564  sampler->sampleUniform(state);
565  space->enforceBounds(state);
566 
567  valid = info->isValid(state);
568  if (constraint)
569  constrained = constraint->isSatisfied(state);
570  else
571  constrained = true;
572  } while (not valid or not constrained);
573 
574  return state;
575  }
576 
577  return nullptr;
578 }
579 
581 {
582  if (ss)
583  {
584  // ss->setStateValidityChecker(std::make_shared<WorldValidityChecker>(info, 1));
585  ss->setStateValidityChecker([&](const ompl::base::State *state) -> bool {
586  const auto &as = toStateConst(state);
587 
588  world->lock();
589  rspace->setWorldState(world, as);
590  bool r = not world->inCollision();
591  world->unlock();
592  return r;
593  });
594  }
595 }
596 
597 ompl::base::StateValidityCheckerFn PlanBuilder::getSVCUnconstrained()
598 {
599  return [&](const ompl::base::State *state) -> bool {
600  const auto &as = fromUnconstrainedStateConst(state);
601 
602  world->lock();
603  rspace->setWorldState(world, as);
604  bool r = not world->inCollision();
605  world->unlock();
606  return r;
607  };
608 }
609 
610 ompl::base::StateValidityCheckerFn PlanBuilder::getSVCConstrained()
611 {
612  return [&](const ompl::base::State *state) -> bool {
613  const auto &as = fromConstrainedStateConst(state);
614 
615  world->lock();
616  rspace->setWorldState(world, as);
617  bool r = not world->inCollision();
618  world->unlock();
619  return r;
620  };
621 }
622 
623 ompl::geometric::PathGeometric PlanBuilder::getSolutionPath(bool simplify, bool interpolate) const
624 {
625  if (simplify)
626  ss->simplifySolution();
627 
628  auto path = ss->getSolutionPath();
629  if (interpolate)
630  path.interpolate();
631 
632  return path;
633 }
T begin(T... args)
Helper class to manage extracting states from a possibly constrained state space.
ompl::base::SpaceInformationPtr space_info_
Space Information.
const StateSpace::StateType * toStateConst(const ompl::base::State *state) const
Extract underlying state from a base state.
const StateSpace::StateType * fromConstrainedStateConst(const ompl::base::State *state) const
Access the underlying state from a constrained OMPL state.
StateSpace::StateType * fromConstrainedState(ompl::base::State *state) const
Access the underlying state from a constrained OMPL state.
void setSpaceInformation(const ompl::base::SpaceInformationPtr &si)
Set space information used for constraint extraction.
const StateSpace * getSpace() const
Gets the underlying state space from the space information.
StateSpace::StateType * fromUnconstrainedState(ompl::base::State *state) const
Access the underlying state from an unconstrained OMPL state.
const StateSpace::StateType * fromUnconstrainedStateConst(const ompl::base::State *state) const
Access the underlying state from an unconstrained OMPL state.
StateSpace::StateType * toState(ompl::base::State *state) const
Extract underlying state from a base state.
ConstraintExtractor()=default
Constructor.
A shared pointer wrapper for robowflex::darts::JointRegionGoal.
JointRegionGoal(const PlanBuilder &builder, const Eigen::Ref< const Eigen::VectorXd > &state, double tolerance=0.)
unsigned int maxSampleCount() const override
void sampleGoal(ompl::base::State *state) const override
double distanceGoal(const ompl::base::State *state) const override
A helper class to setup common OMPL structures for planning.
void setGoal(const ompl::base::GoalPtr &goal)
Set the goal for the problem.
void setStartConfigurationFromWorld()
Set the start configuration from the current state of the world.
TSRPtr fromOrientationConstraint(const std::string &robot_name, const moveit_msgs::OrientationConstraint &msg) const
Get a TSR from an orientation constraint.
std::shared_ptr< ompl::base::GoalStates > sampleGoalConfiguration()
Sample a valid goal configuration.
void addConstraint(const TSRPtr &tsr)
Adds a TSR as a path constraint to the problem.
void setup()
Calls setup routines on OMPL structures. Call after all setup is done and builder is initialized.
void setStartConfiguration(const Eigen::Ref< const Eigen::VectorXd > &q)
Set the start configuration from a configuration.
void getPathConstraintsFromMessage(const std::string &robot_name, const moveit_msgs::MotionPlanRequest &msg)
Get the set of path constraints from the request message.
void initialize()
Initialize OMPL structures. Only call this once all constraints, groups, and other parameters have be...
void initializeConstrained()
Initialize when path constraints are present.
ompl::base::SpaceInformationPtr info
Actual Space Information.
ompl::base::StateValidityCheckerFn getSVCUnconstrained()
Get a state validity checker for the unconstrained space.
TSRConstraintPtr constraint
OMPL Constraint for Path Constraints.
TSRGoalPtr getGoalTSR(const TSRPtr &tsr)
Set a TSR as the goal for the planning problem (will create a TSRGoal)
ompl::geometric::PathGeometric getSolutionPath(bool simplify=true, bool interpolate=true) const
Get the solution path from a successful plan.
ompl::geometric::SimpleSetupPtr ss
Simple Setup.
StateSpacePtr rspace
Underlying Robot State Space.
void addGroup(const std::string &robot, const std::string &name, std::size_t cyclic=0)
Add a robot's planning group to the controlled DoF in the state space.
void getWorkspaceBoundsFromMessage(const moveit_msgs::MotionPlanRequest &msg)
Get workspace bounds from a planning request.
void setStateValidityChecker()
Set the state validity checker on the simple setup.
void sampleStartConfiguration()
Sample a valid start configuration.
std::vector< TSRPtr > path_constraints
Path Constraints.
struct robowflex::darts::PlanBuilder::@1 options
Hyperparameter options.
void getStartFromMessage(const std::string &robot_name, const moveit_msgs::MotionPlanRequest &msg)
Get the start state from the request message.
std::shared_ptr< ompl::base::GoalStates > getGoalConfigurationFromWorld()
Set the goal configuration from the current state of the world.
ompl::base::GoalPtr fromMessage(const std::string &robot_name, const moveit_msgs::MotionPlanRequest &msg)
Use all of the planning request message to setup motion planning.
TSRPtr fromPositionConstraint(const std::string &robot_name, const moveit_msgs::PositionConstraint &msg) const
Get a TSR from an position constraint.
ompl::base::StateSpacePtr space
Actual OMPL State Space (might be constrained).
void initializeUnconstrained()
Initialize when no path constraints are present.
ompl::base::State * sampleState() const
Sample a valid state.
ompl::base::StateValidityCheckerFn getSVCConstrained()
Get a state validity checker for the unconstrained space.
JointRegionGoalPtr fromJointConstraints(const std::vector< moveit_msgs::JointConstraint > &msgs) const
Get a joint region goal from a message.
ompl::base::GoalPtr getGoalFromMessage(const std::string &robot_name, const moveit_msgs::MotionPlanRequest &msg)
Get the goal constraints from the planning request message.
ompl::base::SpaceInformationPtr rinfo
Underlying Space Information.
std::shared_ptr< ompl::base::GoalStates > getGoalConfiguration(const Eigen::Ref< const Eigen::VectorXd > &q)
Set the goal configuration from a configuration.
void getGroupFromMessage(const std::string &robot_name, const moveit_msgs::MotionPlanRequest &msg)
Set group for planning from message.
State type for the robowflex::darts::StateSpace.
Definition: space.h:69
Eigen::VectorXd data
Vector for configuration.
Definition: space.h:76
An OMPL state space for robowflex::darts::World. Can do motion planning for any of the robots or stru...
Definition: space.h:31
A shared pointer wrapper for robowflex::darts::TSRGoal.
A sampleable goal region for OMPL for a set of TSRs. Samples goals in a separate thread using a clone...
struct robowflex::darts::TSRGoal::@0 options
Public options.
ompl::base::StateSamplerPtr sampler_
State sampler.
double distanceGoal(const ompl::base::State *state) const override
Distance to the goal.
~TSRGoal()
Destructor. Stops sampling thread.
TSRSetPtr getTSRSet()
Get the TSR set of this goal region.
bool sample(const ompl::base::GoalLazySamples *gls, ompl::base::State *state)
Sampling routine. Generates IK samples from the TSR goal.
TSRGoal(const ompl::base::SpaceInformationPtr &si, const WorldPtr &world, const std::vector< TSRPtr > &tsrs)
Constructor.
A shared pointer wrapper for robowflex::darts::TSR.
A shared pointer wrapper for robowflex::darts::TSRSet.
Manager for a set of TSR constraints. Attempts to reduce redundancy and combines errors and Jacobians...
Definition: tsr.h:726
The specification of a TSR.
Definition: tsr.h:70
void setBase(const std::string &structure, const std::string &frame)
Set the base frame.
Definition: tsr.cpp:42
void setZRotTolerance(double bound)
Set the Z orientation tolerance to (-bound, bound).
Definition: tsr.cpp:183
void setRotation(const Eigen::Quaterniond &orientation)
Set the rotation of the TSR.
Definition: tsr.cpp:74
void setPose(const RobotPose &other)
Set the pose of the TSR.
Definition: tsr.cpp:93
void setFrame(const std::string &structure, const std::string &target, const std::string &base=magic::ROOT_FRAME)
Set the base and target frame.
Definition: tsr.cpp:48
void setYPosTolerance(double bound)
Set the Y position tolerance to (-bound, bound).
Definition: tsr.cpp:133
void setNoPosTolerance()
Set no position tolerance at all.
Definition: tsr.cpp:233
void setYRotTolerance(double bound)
Set the Y orientation tolerance to (-bound, bound).
Definition: tsr.cpp:178
void setXPosTolerance(double bound)
Setting Position Tolerances.
Definition: tsr.cpp:128
void setZPosTolerance(double bound)
Set the Z position tolerance to (-bound, bound).
Definition: tsr.cpp:138
void setXRotTolerance(double bound)
Setting Orientation Tolerances.
Definition: tsr.cpp:173
Eigen::Vector3d getPosition() const
Getters and Informative Methods.
Definition: tsr.cpp:311
void setPosition(const Eigen::Ref< const Eigen::Vector3d > &position)
Setting TSR Pose.
Definition: tsr.cpp:64
void setNoRotTolerance()
Set no orientation tolerance at all.
Definition: tsr.cpp:255
A shared pointer wrapper for robowflex::darts::World.
T data(T... args)
T emplace_back(T... args)
T empty(T... args)
T end(T... args)
T insert(T... args)
#define RBX_ERROR(fmt,...)
Output a error logging message.
Definition: log.h:102
T max(T... args)
T move(T... args)
Functions for loading and animating robots in Blender.
Eigen::Vector3d vectorMsgToEigen(const geometry_msgs::Vector3 &msg)
Converts a vector message to an Eigen::Vector3d.
Definition: tf.cpp:94
RobotPose poseMsgToEigen(const geometry_msgs::Pose &msg)
Converts a pose message to RobotPose.
Definition: tf.cpp:114
Eigen::Quaterniond quaternionMsgToEigen(const geometry_msgs::Quaternion &msg)
Converts a quaternion message to Eigen::Quaterniond.
Definition: tf.cpp:135
DART-based robot modeling and planning.
Definition: acm.h:16