se2ez
constraint.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #include <algorithm>
4 
5 #include <se2ez/core/log.h>
6 #include <se2ez/core/robot.h>
7 #include <se2ez/core/state.h>
8 
9 #include <se2ez/plan/space.h>
10 #include <se2ez/plan/constraint.h>
11 
12 #include <ompl/base/spaces/constraint/ConstrainedStateSpace.h>
13 
14 const int debugJ = 0;
15 const int debugF = 0;
16 const int debugP = 0;
17 const int debugL = 0;
18 
19 using namespace se2ez;
20 
22  const std::string &frame, const std::string &base,
23  unsigned int dimension, unsigned int leaf)
24  : ompl::base::Foliation(robot->getNumJoints(), dimension, leaf)
25  , name_(name)
26  , robot_(robot)
27  , frame_(frame)
28  , base_(base)
29  , state_(std::make_shared<State>(robot))
30 {
31  // setTolerance(1e-3);
32  setMaxIterations(15);
33 
34  if (!robot->getFrame(frame_))
35  {
36  SE2EZ_ERROR("%1% is not a frame in the robot!", frame_);
37  throw std::invalid_argument(log::format("%1% is not a frame in the robot!", frame_));
38  }
39 
40  if (!robot->getFrame(base_))
41  {
42  SE2EZ_ERROR("%1% is not a frame in the robot!", base_);
43  throw std::invalid_argument(log::format("%1% is not a frame in the robot!", base_));
44  }
45 }
46 
48 plan::FrameConstraint::getPose(const ompl::base::State *state) const
49 {
50  const auto &as = state->as<ompl::base::ConstrainedStateSpace::StateType>()
51  ->getState()
53  ->state;
54 
55  // as->fk(robot_);
56  return std::make_pair(as->getPose(robot_, frame_), as->getPose(robot_, base_));
57 }
58 
60 plan::FrameConstraint::getPose(const Eigen::Ref<const Eigen::VectorXd> &x) const
61 {
63 
64  state_->data = x;
65  state_->dirty = true;
66  // state_->fk(robot_);
67 
68  return std::make_pair(state_->getPose(robot_, frame_), state_->getPose(robot_, base_));
69 }
70 
71 void plan::FrameConstraint::function(const ompl::base::State *state, Eigen::Ref<Eigen::VectorXd> out) const
72 {
73  Eigen::Isometry2d frame, base;
74  std::tie(frame, base) = getPose(state);
75  functionInternal(frame, base, out);
76 
77  if (debugF)
78  {
79  const auto &as = state->as<ompl::base::ConstrainedStateSpace::StateType>()
80  ->getState()
82  ->state;
83 
84  SE2EZ_DEBUG("CONSTRAINT FUNCTION DEBUG");
85  SE2EZ_DEBUG("STATE\n %1%", tf::printVector(as->data));
86  SE2EZ_DEBUG("BASE\n %1%", tf::printFrame(base));
87  SE2EZ_DEBUG("POSE\n %1%", tf::printFrame(frame));
88  SE2EZ_DEBUG("VALUE\n %1%\n", tf::printVector(out));
89  }
90 }
91 
92 void plan::FrameConstraint::function(const Eigen::Ref<const Eigen::VectorXd> &x,
93  Eigen::Ref<Eigen::VectorXd> out) const
94 {
96 
97  Eigen::Isometry2d frame, base;
98  std::tie(frame, base) = getPose(x);
99  functionInternal(frame, base, out);
100 }
101 
102 void plan::FrameConstraint::jacobian(const ompl::base::State *state, Eigen::Ref<Eigen::MatrixXd> out) const
103 {
104  const auto &as = state->as<ompl::base::ConstrainedStateSpace::StateType>()
105  ->getState()
107  ->state;
108 
109  Eigen::Isometry2d frame, base;
110  std::tie(frame, base) = getPose(state);
111 
112  jacobianInternal(frame, base, as->getJacobian(robot_, frame_), out);
113 
114  if (debugJ)
115  {
116  SE2EZ_DEBUG("CONSTRAINT JACOBIAN DEBUG");
117  SE2EZ_DEBUG("ANALYTIC\n %1%", tf::printMatrix(out));
118  Eigen::MatrixXd copy = out;
119 
120  ompl::base::Constraint::jacobian(state, out);
121  SE2EZ_DEBUG("NUMERIC\n %1%", tf::printMatrix(out));
122 
123  Eigen::MatrixXd diff = copy - out;
124  SE2EZ_DEBUG("DIFFERENCE\n %1%", tf::printMatrix(diff));
125  SE2EZ_DEBUG("NORM\n %1%\n", diff.norm());
126  }
127 }
128 
129 void plan::FrameConstraint::jacobian(const Eigen::Ref<const Eigen::VectorXd> &x,
130  Eigen::Ref<Eigen::MatrixXd> out) const
131 {
133 
134  Eigen::Isometry2d frame, base;
135  std::tie(frame, base) = getPose(x);
136 
137  jacobianInternal(frame, base, state_->getJacobian(robot_, frame_), out);
138 
139  if (debugJ)
140  {
141  SE2EZ_DEBUG("CONSTRAINT JACOBIAN DEBUG");
142  SE2EZ_DEBUG("ANALYTIC\n %1%", tf::printMatrix(out));
143  Eigen::MatrixXd copy = out;
144 
145  ompl::base::Constraint::jacobian(x, out);
146  SE2EZ_DEBUG("NUMERIC\n %1%", tf::printMatrix(out));
147 
148  Eigen::MatrixXd diff = copy - out;
149  SE2EZ_DEBUG("DIFFERENCE\n %1%", tf::printMatrix(diff));
150  SE2EZ_DEBUG("NORM\n %1%\n", diff.norm());
151  }
152 }
153 
154 bool plan::FrameConstraint::project(ompl::base::State *state) const
155 {
156  const auto &as = state->as<ompl::base::ConstrainedStateSpace::StateType>()
157  ->getState()
159  ->state;
160 
161  unsigned int iter = 0;
162  double norm = 0;
163  Eigen::VectorXd f(getCoDimension());
164  Eigen::MatrixXd j(getCoDimension(), n_);
165 
166  // const double squaredTolerance = tolerance_ * tolerance_;
167  const double squaredTolerance = tolerance_;
168 
169  function(state, f);
170  while ((norm = f.lpNorm<Eigen::Infinity>()) > squaredTolerance && iter++ < maxIterations_)
171  {
172  jacobian(state, j);
173  as->data -= j.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(f);
174  // as->data -= j.colPivHouseholderQr().solve(f);
175  as->dirty = true;
176 
177  function(state, f);
178  }
179 
180  return norm < squaredTolerance;
181 }
182 
183 bool plan::FrameConstraint::project(Eigen::Ref<Eigen::VectorXd> x) const
184 {
186 
187  // Newton's method
188  unsigned int iter = 0;
189  double norm = 0;
190 
191  Eigen::VectorXd f(getCoDimension());
192  Eigen::MatrixXd j(getCoDimension(), n_);
193 
194  const double squaredTolerance = tolerance_;
195 
196  function(x, f);
197  while ((norm = f.lpNorm<Eigen::Infinity>()) > squaredTolerance && iter++ < maxIterations_)
198  {
199  jacobian(x, j);
200  x -= j.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(f);
201  // x -= j.colPivHouseholderQr().solve(f);
202  function(x, f);
203  }
204 
205  return norm < squaredTolerance;
206 }
207 
208 double plan::FrameConstraint::distance(const ompl::base::State *state) const
209 {
210  Eigen::VectorXd f(getCoDimension());
211  function(state, f);
212  return f.norm();
213 }
214 
215 bool plan::FrameConstraint::isSatisfied(const ompl::base::State *state) const
216 {
217  Eigen::VectorXd f(getCoDimension());
218  function(state, f);
219  return f.allFinite() && f.squaredNorm() <= tolerance_ * tolerance_;
220 }
221 
222 void plan::FrameConstraint::setDrawOffset(const Eigen::Ref<const Eigen::Vector2d> &v)
223 {
224  draw_ = v;
225 }
226 
227 const Eigen::Vector2d &plan::FrameConstraint::getDrawOffset() const
228 {
229  return draw_;
230 }
231 
232 ///
233 /// LineConstraint
234 ///
235 
237  const std::string &base, const Eigen::Vector2d &a,
238  const Eigen::Vector2d &b)
239  : FrameConstraint(name, robot, frame, base)
240  , a_(a)
241  , b_(b)
242  , v_((b_ - a_).normalized())
243  , abn_((b_ - a_).norm())
244 {
245 }
246 
247 ompl::base::FoliationPtr plan::LineConstraint::copy() const
248 {
249  return std::make_shared<LineConstraint>(name_, robot_, frame_, base_, a_, b_);
250 }
251 
252 Eigen::VectorXd plan::LineConstraint::getTransversal(const Eigen::Ref<const Eigen::VectorXd> &state) const
253 {
254  Eigen::Isometry2d frame, base;
255  std::tie(frame, base) = getPose(state);
256 
257  Result r;
258  getPlace(frame, base, r);
259 
260  if (debugL)
261  {
262  SE2EZ_DEBUG("CONSTRAINT %1%", name_);
263  SE2EZ_DEBUG("STATE\n %1%", tf::printVector(state));
264  SE2EZ_DEBUG("BASE\n %1%: %2%", base_, tf::printFrame(base));
265  SE2EZ_DEBUG("POSE\n %1%: %2%", frame_, tf::printFrame(frame));
266 
267  std::string p = "LINE";
268  if (r.place == A)
269  p = "A";
270  if (r.place == B)
271  p = "B";
272 
273  SE2EZ_INFORM(" A: %1%, AT: %2%", tf::printVector(a_), tf::printVector(r.at));
274  SE2EZ_INFORM(" B: %1%, BT: %2%", tf::printVector(b_), tf::printVector(r.bt));
275  SE2EZ_INFORM(" V: %1%, VT: %2%", tf::printVector(v_), tf::printVector(r.vt));
276  SE2EZ_INFORM("CA: %1%", tf::printVector(r.ca));
277  SE2EZ_INFORM("CV: %1%", r.cv);
278  SE2EZ_INFORM(" P: %1%", p);
279  }
280 
281  return math::toVector(math::clamp(r.cv / abn_, 0., 1.));
282 }
283 
284 ompl::base::ConstraintPtr
285 plan::LineConstraint::getLeaf(const Eigen::Ref<const Eigen::VectorXd> &transversal) const
286 {
287  double cv = transversal[0] * abn_;
288 
289  Eigen::Vector2d point;
290  if (cv < 0)
291  point = a_;
292  else if (cv > abn_)
293  point = b_;
294  else
295  point = a_ + cv * v_;
296 
297  if (debugL)
298  {
299  SE2EZ_INFORM("TRANSV: %1%", tf::printVector(transversal));
300  SE2EZ_INFORM("LEAF: %1%", tf::printVector(point));
301  }
302 
303  return std::make_shared<PointConstraint>(name_ + log::format("_leaf[%1%]", cv), robot_, frame_, base_,
304  point);
305 }
306 
307 ompl::base::FoliationPtr plan::LineConstraint::getFrond(const Eigen::Ref<const Eigen::VectorXd> &a,
308  const Eigen::Ref<const Eigen::VectorXd> &b) const
309 {
310  double acv = a[0] * abn_, bcv = b[0] * abn_;
311 
312  Eigen::Vector2d pointA, pointB;
313  if (acv < 0)
314  pointA = a_;
315  else if (acv > abn_)
316  pointA = b_;
317  else
318  pointA = a_ + acv * v_;
319 
320  if (bcv < 0)
321  pointB = a_;
322  else if (bcv > abn_)
323  pointB = b_;
324  else
325  pointB = a_ + bcv * v_;
326 
327  if (debugL)
328  {
329  SE2EZ_INFORM("TRANSVA: %1%", tf::printVector(a));
330  SE2EZ_INFORM("TRANSVB: %1%", tf::printVector(b));
331  SE2EZ_INFORM("LEAFA: %1%", tf::printVector(pointA));
332  SE2EZ_INFORM("LEAFB: %1%", tf::printVector(pointB));
333  }
334 
335  return std::make_shared<LineConstraint>(name_ + log::format("_frond[%1%,%2%]", acv, bcv), robot_, frame_,
336  base_, pointA, pointB);
337 }
338 
339 void plan::LineConstraint::functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
340  Eigen::Ref<Eigen::VectorXd> out) const
341 {
342  Result r;
343  getPlace(pose, base, r);
344 
345  switch (r.place)
346  {
347  case A:
348  out[0] = r.ca.squaredNorm();
349  break;
350  case B:
351  out[0] = r.cb.squaredNorm();
352  break;
353  case LINE:
354  out[0] = r.ca.squaredNorm() - pow(r.cv, 2);
355  break;
356  }
357 }
358 
359 void plan::LineConstraint::jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
360  const Eigen::MatrixXd &jac, Eigen::Ref<Eigen::MatrixXd> out) const
361 {
362  Result r;
363  getPlace(pose, base, r);
364 
365  switch (r.place)
366  {
367  case A:
368  out = 2 * r.ca.transpose() * jac.block(0, 0, 2, n_);
369  break;
370  case B:
371  out = 2 * r.cb.transpose() * jac.block(0, 0, 2, n_);
372  break;
373  case LINE:
374  out = 2 * (r.ca - r.cv * r.vt).transpose() * jac.block(0, 0, 2, n_);
375  break;
376  }
377 }
378 
379 void plan::LineConstraint::getPlace(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
380  Result &r) const
381 {
382  r.at = base * a_;
383  r.bt = base * b_;
384  r.vt = base.rotation() * v_;
385 
386  r.ca = pose.translation() - r.at;
387  r.cb = pose.translation() - r.bt;
388  r.cv = r.ca.dot(r.vt);
389  if (r.cv < 0)
390  r.place = A;
391  else if (r.cv > abn_)
392  r.place = B;
393  else
394  r.place = LINE;
395 
396  if (debugP)
397  {
398  std::string p = "LINE";
399  if (r.place == A)
400  p = "A";
401  if (r.place == B)
402  p = "B";
403 
404  SE2EZ_INFORM(" A: %1% %2%", tf::printVector(a_), tf::printVector(r.at));
405  SE2EZ_INFORM(" B: %1% %2%", tf::printVector(b_), tf::printVector(r.bt));
406  SE2EZ_INFORM(" V: %1% %2%", tf::printVector(v_), tf::printVector(r.vt));
407  SE2EZ_INFORM("CA: %1%", tf::printVector(r.ca));
408  SE2EZ_INFORM("CV: %1%", r.cv);
409  SE2EZ_INFORM(" P: %1%", p);
410  }
411 }
412 
413 void plan::LineConstraint::getEndpoints(Eigen::Ref<Eigen::VectorXd> a, Eigen::Ref<Eigen::VectorXd> b,
414  const StatePtr &state) const
415 {
416  auto base = state->getPose(robot_, base_);
417 
418  a = base * a_;
419  b = base * b_;
420 }
421 
422 ///
423 /// PointConstraint
424 ///
425 
427  const std::string &frame, const std::string &base,
428  const Eigen::Vector2d &p)
429  : FrameConstraint(name, robot, frame, base), p_(p)
430 {
431 }
432 
433 ompl::base::FoliationPtr plan::PointConstraint::copy() const
434 {
435  return std::make_shared<PointConstraint>(name_, robot_, frame_, base_, p_);
436 }
437 
438 Eigen::VectorXd plan::PointConstraint::getTransversal(const Eigen::Ref<const Eigen::VectorXd> &) const
439 {
440  return math::toVector(0);
441 }
442 
443 ompl::base::ConstraintPtr plan::PointConstraint::getLeaf(const Eigen::Ref<const Eigen::VectorXd> &) const
444 {
445  // copy baby!
446  return copy();
447 }
448 
449 ompl::base::FoliationPtr plan::PointConstraint::getFrond(const Eigen::Ref<const Eigen::VectorXd> &,
450  const Eigen::Ref<const Eigen::VectorXd> &) const
451 {
452  // copy baby!
453  return copy();
454 }
455 
456 void plan::PointConstraint::functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
457  Eigen::Ref<Eigen::VectorXd> out) const
458 {
459  const auto &p = base * p_;
460 
461  const auto &ca = pose.translation() - p;
462  out[0] = ca.squaredNorm();
463 }
464 
465 void plan::PointConstraint::jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
466  const Eigen::MatrixXd &jac,
467  Eigen::Ref<Eigen::MatrixXd> out) const
468 {
469  const auto &p = base * p_;
470 
471  const auto &ca = pose.translation() - p;
472  out = 2 * ca.transpose() * jac.block(0, 0, 2, n_);
473 }
474 
475 void plan::PointConstraint::getPoint(Eigen::Ref<Eigen::VectorXd> a, const StatePtr &state) const
476 {
477  auto base = state->getPose(robot_, base_);
478  a = base * p_;
479 }
480 
481 ///
482 /// CircleConstraint
483 ///
484 
486  const std::string &frame, const std::string &base,
487  const Eigen::Vector2d &p, const Eigen::Vector2d &r,
488  unsigned int exponent)
489  : FrameConstraint(name, robot, frame, base), p_(p), r_(r), exp_(exponent)
490 {
491  SE2EZ_ERROR("CircleConstraint is currently under development! Use at your own risk.");
492 }
493 
494 double plan::CircleConstraint::getAngle(const Eigen::Isometry2d &frame, const Eigen::Isometry2d &base) const
495 {
496  auto p = base * p_;
497  double theta = std::atan2(frame.translation()[1] / r_[1] - p[1], frame.translation()[0] / r_[0] - p[0]);
498  return math::angleNormalize(theta - tf::getRotation(base));
499 }
500 
501 ompl::base::FoliationPtr plan::CircleConstraint::copy() const
502 {
503  return std::make_shared<CircleConstraint>(name_, robot_, frame_, base_, p_, r_, exp_);
504 }
505 
506 Eigen::VectorXd plan::CircleConstraint::getTransversal(const Eigen::Ref<const Eigen::VectorXd> &x) const
507 {
508  Eigen::Isometry2d frame, base;
509  std::tie(frame, base) = getPose(x);
510 
511  double v = getAngle(frame, base);
512  return math::toVector(math::remap(-math::pi, math::pi, v, 0, 1));
513 }
514 
515 ompl::base::ConstraintPtr plan::CircleConstraint::getLeaf(const Eigen::Ref<const Eigen::VectorXd> &x) const
516 {
517  Eigen::Isometry2d frame, base;
518  std::tie(frame, base) = getPose(x);
519  auto p = frame.translation() - base.translation();
520 
521  return std::make_shared<PointConstraint>(name_, robot_, frame_, base_, p);
522 }
523 
524 ompl::base::FoliationPtr plan::CircleConstraint::getFrond(
525  const Eigen::Ref<const Eigen::VectorXd> & /*a*/, const Eigen::Ref<const Eigen::VectorXd> & /*b*/) const
526 {
527  // copy baby!
528  return copy();
529 }
530 
531 void plan::CircleConstraint::functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
532  Eigen::Ref<Eigen::VectorXd> out) const
533 {
534  const auto &p = base * p_;
535 
536  Eigen::Vector2d ca = (pose.translation() - p).cwiseQuotient(r_).cwiseAbs();
537  for (unsigned int i = 1; i < exp_; ++i)
538  ca = ca.cwiseProduct(ca);
539  out[0] = ca.sum() - 1;
540 }
541 
542 void plan::CircleConstraint::jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base,
543  const Eigen::MatrixXd &jac,
544  Eigen::Ref<Eigen::MatrixXd> out) const
545 {
546  const auto &p = base * p_;
547 
548  Eigen::Vector2d ca = (pose.translation() - p).cwiseQuotient(r_).cwiseAbs();
549  for (unsigned int i = 1; i < exp_ - 1; ++i)
550  ca = ca.cwiseProduct(ca);
551  out = exp_ * ca.transpose() * jac.block(0, 0, 2, n_);
552 }
553 
554 void plan::CircleConstraint::getCircle(Eigen::Ref<Eigen::VectorXd> p, Eigen::Ref<Eigen::VectorXd> r,
555  double &v, const StatePtr &state) const
556 {
557  auto base = state->getPose(robot_, base_);
558  p = base * p_;
559  r = r_;
560  v = tf::getRotation(base);
561 }
562 
563 ///
564 /// OrientationConstraint
565 ///
566 
567 // plan::OrientationConstraint::OrientationConstraint(const RobotPtr &robot, const std::string &frame,
568 // const double v)
569 // : FrameConstraint(robot, frame), v_(v)
570 // {
571 // }
572 
573 // void plan::OrientationConstraint::functionInternal(const Eigen::Isometry2d &pose,
574 // Eigen::Ref<Eigen::VectorXd> out) const
575 // {
576 // out[0] = math::angleDistance(tf::getRotation(pose), v_);
577 // }
578 
579 // void plan::OrientationConstraint::jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::MatrixXd
580 // &jac,
581 // Eigen::Ref<Eigen::MatrixXd> out) const
582 // {
583 // // const auto &ca = pose.translation() - p_;
584 // // out = 2 * ca.transpose() * jac.block(0, 0, 2, n_);
585 // }
Eigen::VectorXd getTransversal(const Eigen::Ref< const Eigen::VectorXd > &state) const override
Definition: constraint.cpp:506
ompl::base::ConstraintPtr getLeaf(const Eigen::Ref< const Eigen::VectorXd > &tv) const override
Definition: constraint.cpp:515
const Eigen::Vector2d r_
Definition: constraint.h:180
ompl::base::ConstraintPtr getLeaf(const Eigen::Ref< const Eigen::VectorXd > &tv) const override
Definition: constraint.cpp:285
A shared pointer wrapper for se2ez::State.
ompl::base::ConstraintPtr getLeaf(const Eigen::Ref< const Eigen::VectorXd > &tv) const override
Definition: constraint.cpp:443
T tie(T... args)
void getEndpoints(Eigen::Ref< Eigen::VectorXd > a, Eigen::Ref< Eigen::VectorXd > b, const StatePtr &state) const
Definition: constraint.cpp:413
static const double pi
Definition: math.h:32
PointConstraint(const std::string &name, const RobotPtr &robot, const std::string &frame, const std::string &base, const Eigen::Vector2d &p)
Definition: constraint.cpp:426
std::string printFrame(const Eigen::Isometry2d &frame)
Returns a string "[x, y, t]" of the translation (x, y) and rotation (t) component of a transform...
Definition: math.cpp:79
A representation of a state of a Robot.
Definition: state.h:28
std::recursive_mutex mutex_
Definition: constraint.h:73
double getRotation(const Eigen::Isometry2d &frame)
Gets rotation from a frame from the X-axis (t)
Definition: math.cpp:25
virtual void functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, Eigen::Ref< Eigen::VectorXd > out) const =0
double clamp(double v, double a, double b)
Clamp a value v between a range [a, b].
Definition: math.cpp:179
std::string printMatrix(const Eigen::MatrixXd &v, unsigned int precision=4)
Returns a string of a matrix&#39;s contents.
Definition: math.cpp:109
const Eigen::Vector2d v_
Definition: constraint.h:125
void getPlace(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, Result &r) const
Definition: constraint.cpp:379
ompl::base::FoliationPtr getFrond(const Eigen::Ref< const Eigen::VectorXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b) const override
Definition: constraint.cpp:524
T atan2(T... args)
void functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, Eigen::Ref< Eigen::VectorXd > out) const override
Definition: constraint.cpp:531
#define SE2EZ_INFORM(fmt,...)
Definition: log.h:43
void jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, const Eigen::MatrixXd &jac, Eigen::Ref< Eigen::MatrixXd > out) const override
Definition: constraint.cpp:359
const Eigen::Vector2d & getDrawOffset() const
Definition: constraint.cpp:227
void getPoint(Eigen::Ref< Eigen::VectorXd > a, const StatePtr &state) const
Definition: constraint.cpp:475
void function(const ompl::base::State *state, Eigen::Ref< Eigen::VectorXd > out) const override
Definition: constraint.cpp:71
Definition: goals.h:10
virtual FoliationPtr copy() const =0
ompl::base::FoliationPtr copy() const override
Definition: constraint.cpp:247
const std::string base_
Definition: constraint.h:71
const Eigen::Vector2d a_
Definition: constraint.h:123
FrameConstraint(const std::string &name, const RobotPtr &robot, const std::string &frame, const std::string &base, unsigned int dimension=1, unsigned int leaf=0)
Definition: constraint.cpp:21
ompl::base::FoliationPtr getFrond(const Eigen::Ref< const Eigen::VectorXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b) const override
Definition: constraint.cpp:449
double distance(const ompl::base::State *state) const override
Definition: constraint.cpp:208
LineConstraint(const std::string &name, const RobotPtr &robot, const std::string &frame, const std::string &base, const Eigen::Vector2d &a, const Eigen::Vector2d &b)
Definition: constraint.cpp:236
double getAngle(const Eigen::Isometry2d &frame, const Eigen::Isometry2d &base) const
Definition: constraint.cpp:494
T make_pair(T... args)
ompl::base::FoliationPtr copy() const override
Definition: constraint.cpp:433
Eigen::VectorXd toVector(double x)
Converts a single double value into a 1 x 1 matrix.
Definition: math.cpp:134
const std::string name_
Definition: constraint.h:68
void functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, Eigen::Ref< Eigen::VectorXd > out) const override
Definition: constraint.cpp:339
void functionInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, Eigen::Ref< Eigen::VectorXd > out) const override
Definition: constraint.cpp:456
virtual void jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, const Eigen::MatrixXd &jac, Eigen::Ref< Eigen::MatrixXd > out) const =0
double angleNormalize(double v)
Normalize an angle between -pi to pi.
Definition: math.cpp:189
const int debugF
Definition: constraint.cpp:15
ompl::base::FoliationPtr getFrond(const Eigen::Ref< const Eigen::VectorXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b) const override
Definition: constraint.cpp:307
const int debugJ
Definition: constraint.cpp:14
bool isSatisfied(const ompl::base::State *state) const override
Definition: constraint.cpp:215
void jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, const Eigen::MatrixXd &jac, Eigen::Ref< Eigen::MatrixXd > out) const override
Definition: constraint.cpp:542
const unsigned int exp_
Definition: constraint.h:181
unsigned int p_
Leaf dimension.
Definition: goals.h:72
CircleConstraint(const std::string &name, const RobotPtr &robot, const std::string &frame, const std::string &base, const Eigen::Vector2d &p, const Eigen::Vector2d &r, unsigned int exponent=2)
Definition: constraint.cpp:485
const std::pair< Eigen::Isometry2d, Eigen::Isometry2d > getPose(const ompl::base::State *state) const
Definition: constraint.cpp:48
const std::string frame_
Definition: constraint.h:70
const Eigen::Vector2d p_
Definition: constraint.h:152
A shared pointer wrapper for se2ez::Robot.
std::string printVector(const Eigen::VectorXd &v, unsigned int precision=4)
Returns a string of a vector&#39;s contents.
Definition: math.cpp:90
std::string format(const std::string &fmt, Args &&... args)
Definition: log.h:25
void setDrawOffset(const Eigen::Ref< const Eigen::Vector2d > &v)
Definition: constraint.cpp:222
#define SE2EZ_DEBUG(fmt,...)
Definition: log.h:45
Eigen::VectorXd getTransversal(const Eigen::Ref< const Eigen::VectorXd > &state) const override
Definition: constraint.cpp:438
bool project(ompl::base::State *state) const override
Definition: constraint.cpp:154
const Eigen::Vector2d p_
Definition: constraint.h:179
Main namespace.
Definition: collision.h:11
#define SE2EZ_ERROR(fmt,...)
Definition: log.h:39
Eigen::VectorXd getTransversal(const Eigen::Ref< const Eigen::VectorXd > &state) const override
Definition: constraint.cpp:252
double remap(double a1, double a2, double av, double b1, double b2)
Remap a value av in the interval a1, a2 to the interval b1, b2.
Definition: math.cpp:160
ompl::base::FoliationPtr copy() const override
Definition: constraint.cpp:501
const Eigen::Vector2d b_
Definition: constraint.h:124
const int debugL
Definition: constraint.cpp:17
void getCircle(Eigen::Ref< Eigen::VectorXd > p, Eigen::Ref< Eigen::VectorXd > r, double &v, const StatePtr &state) const
Definition: constraint.cpp:554
const int debugP
Definition: constraint.cpp:16
void jacobianInternal(const Eigen::Isometry2d &pose, const Eigen::Isometry2d &base, const Eigen::MatrixXd &jac, Eigen::Ref< Eigen::MatrixXd > out) const override
Definition: constraint.cpp:465
void jacobian(const ompl::base::State *state, Eigen::Ref< Eigen::MatrixXd > out) const override
Definition: constraint.cpp:102