3 #include <boost/format.hpp>
5 #include <dart/dynamics/InverseKinematics.hpp>
6 #include <dart/dynamics/SimpleFrame.hpp>
26 const Eigen::Ref<const Eigen::Vector3d> &position,
27 const Eigen::Quaterniond &rotation)
35 target.structure = structure;
38 if (base.structure.empty())
39 base.structure = structure;
44 base.structure = structure;
51 target.structure = structure;
52 base.structure = structure;
54 target.frame = target_frame;
55 base.frame = base_frame;
60 target.structure = target.structure + suffix;
61 base.structure = base.structure + suffix;
66 pose.translation() = position;
71 setPosition(Eigen::Vector3d(x, y, z));
76 pose.linear() = orientation.toRotationMatrix();
81 setRotation(Eigen::Quaterniond(w, x, y, z));
86 auto n = Eigen::AngleAxisd(x, Eigen::Vector3d::UnitX()) *
87 Eigen::AngleAxisd(y, Eigen::Vector3d::UnitY()) *
88 Eigen::AngleAxisd(z, Eigen::Vector3d::UnitZ());
99 const Eigen::Quaterniond &rotation)
106 setPosition(xp, yp, zp);
107 setRotation(wr, xr, yr, zr);
112 const auto &sim = world->getSim();
114 const auto &tskl = sim->getSkeleton(target.structure);
115 const auto &tbn = tskl->getBodyNode(target.frame);
119 const auto &bskl = sim->getSkeleton(base.structure);
120 const auto &bbn = bskl->getBodyNode(base.frame);
122 pose = tbn->getTransform(bbn);
125 pose = tbn->getTransform();
130 setXPosTolerance(-bound, bound);
135 setYPosTolerance(-bound, bound);
140 setZPosTolerance(-bound, bound);
145 position.lower[0] = lower;
146 position.upper[0] = upper;
149 indices[3] = isPosConstrained(lower, upper);
155 position.lower[1] = lower;
156 position.upper[1] = upper;
159 indices[4] = isPosConstrained(lower, upper);
165 position.lower[2] = lower;
166 position.upper[2] = upper;
169 indices[5] = isPosConstrained(lower, upper);
175 setXRotTolerance(-bound, bound);
180 setYRotTolerance(-bound, bound);
185 setZRotTolerance(-bound, bound);
190 orientation.lower[0] = lower;
191 orientation.upper[0] = upper;
194 indices[0] = isRotConstrained(lower, upper);
200 orientation.lower[1] = lower;
201 orientation.upper[1] = upper;
204 indices[1] = isRotConstrained(lower, upper);
210 orientation.lower[2] = lower;
211 orientation.upper[2] = upper;
214 indices[2] = isRotConstrained(lower, upper);
235 setNoXPosTolerance();
236 setNoYPosTolerance();
237 setNoZPosTolerance();
257 setNoXRotTolerance();
258 setNoYRotTolerance();
259 setNoZRotTolerance();
265 Eigen::Vector3d u, l;
268 u[i] =
std::max(position.lower[i], position.upper[i]);
269 l[i] =
std::min(position.lower[i], position.upper[i]);
277 Eigen::Vector3d u, l;
284 orientation.lower = l;
285 orientation.upper = u;
292 for (
const auto &idx : indices)
313 return pose.translation();
323 return getRotation().toRotationMatrix().eulerAngles(0, 1, 2);
339 Eigen::Vector3d p = getPosition();
345 double pi = p[i], piu = position.upper[i], pil = position.lower[i];
354 if ((
pi + piu) < (opi + opil))
363 if ((
pi + pil) > (opi + opiu))
369 if (not isRotationConstrained())
380 double pi = p[i], piu = position.upper[i], pil = position.lower[i];
386 np[i] = (high + low) / 2.;
389 position.upper[i] = v;
390 position.lower[i] = -v;
392 indices[i] = isRotConstrained(orientation.lower[i], orientation.upper[i]);
393 indices[3 + i] = isPosConstrained(-v, v);
411 value |= isPosConstrained(position.lower[i], position.upper[i]);
420 value |= isRotConstrained(orientation.lower[i], orientation.upper[i]);
429 % base.frame % base.structure % target.frame % target.structure;
432 % target.frame % target.structure;
435 out <<
"Position Orientation" <<
std::endl;
437 auto p = getPosition();
438 auto o = getRotation();
440 " x:%1$+07.4f (%2$+07.4f, %3$+07.4f) [%7%] x:%4$+07.4f (%5$+07.4f, %6$+07.4f) [%8%]")
441 % p[0] % position.lower[0] % position.upper[0]
442 % o.x() % orientation.lower[0] % orientation.upper[0]
443 % indices[3] % indices[0];
446 " y:%1$+07.4f (%2$+07.4f, %3$+07.4f) [%7%] y:%4$+07.4f (%5$+07.4f, %6$+07.4f) [%8%]")
447 % p[1] % position.lower[1] % position.upper[1]
448 % o.y() % orientation.lower[1] % orientation.upper[1]
449 % indices[4] % indices[1];
452 " z:%1$+07.4f (%2$+07.4f, %3$+07.4f) [%7%] z:%4$+07.4f (%5$+07.4f, %6$+07.4f) [%8%]")
453 % p[2] % position.lower[2] % position.upper[2]
454 % o.z() % orientation.lower[2] % orientation.upper[2]
455 % indices[5] % indices[2];
516 for (
const auto &index : indices)
575 const auto &sim =
world_->getSim();
582 return tnd_->getTransform(bnd);
588 error =
tsr_->computeError();
596 auto tsr_error =
tsr_->computeError();
602 error[j++] = tsr_error[i];
609 Eigen::Ref<Eigen::VectorXd> error)
const
621 void TSR::getError(
const Eigen::Ref<const Eigen::VectorXd> &state, Eigen::Ref<Eigen::VectorXd> error)
const
631 auto tjac =
ik_->computeJacobian();
637 jacobian.row(j++) = tjac.row(i);
644 Eigen::Ref<Eigen::MatrixXd> jacobian)
const
663 Eigen::Ref<Eigen::MatrixXd> jacobian)
const
696 RBX_ERROR(
"TSR: Solve called before initialize!");
701 bool r =
ik_->solveAndApply();
713 bool r =
solve(state);
734 Eigen::VectorXd state =
ik_->getPositions();
758 unsigned int iter = 0;
768 while ((norm = f.norm()) > squared_tolerance && iter++ <
spec_.
maxIter)
771 state -= j.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(f);
779 return norm < squared_tolerance;
792 ik_->setPositions(state);
806 state =
ik_->getPositions();
841 const auto &sim =
world_->getSim();
863 tsr_ = &
ik_->setErrorMethod<dart::dynamics::InverseKinematics::TaskSpaceRegion>();
864 tsr_->setComputeFromCenter(
false);
876 void TSR::toBijection(Eigen::Ref<Eigen::VectorXd> world,
const Eigen::Ref<const Eigen::VectorXd> &state)
const
887 const Eigen::Ref<const Eigen::VectorXd> &world)
const
935 for (
const auto &tsr : tsrs)
945 for (
auto &etsr :
tsrs_)
947 if (etsr->getSpecification().intersect(spec))
950 for (
auto &tsr :
tsrs_)
956 ntsr = std::make_shared<TSR>(
world_, spec);
957 ntsr->useIndices(tsr->getIndices());
958 ntsr->setWorldIndices(tsr->getWorldIndices());
966 tsrs_.emplace_back(ntsr);
985 for (
auto &tsr :
tsrs_)
986 tsr->setWorld(world);
994 for (
auto &tsr :
tsrs_)
995 tsr->getSpecification().addSuffix(suffix);
1000 for (
auto &tsr :
tsrs_)
1001 tsr->useGroup(name);
1006 for (
auto &tsr :
tsrs_)
1007 tsr->useIndices(indices);
1012 for (
auto &tsr :
tsrs_)
1013 tsr->useWorldIndices(indices);
1018 for (
auto &tsr :
tsrs_)
1019 tsr->setWorldIndices(indices);
1034 const auto &tsr =
tsrs_[j];
1035 tsr->getErrorWorld(error.segment(i, tsr->getDimension()));
1036 error.segment(i, tsr->getDimension()) *=
weights_[j];
1038 i += tsr->getDimension();
1045 Eigen::Ref<Eigen::VectorXd> error)
const
1052 const auto &tsr =
tsrs_[j];
1053 tsr->getErrorWorldState(world, error.segment(i, tsr->getDimension()));
1054 error.segment(i, tsr->getDimension()) *=
weights_[j];
1056 i += tsr->getDimension();
1063 Eigen::Ref<Eigen::MatrixXd> jacobian)
const
1071 const auto &tsr =
tsrs_[j];
1072 tsr->getJacobianWorldState(world, jacobian.block(i, 0, tsr->getDimension(), n));
1073 jacobian.block(i, 0, tsr->getDimension(), n) *=
weights_[j];
1075 i += tsr->getDimension();
1099 if (
tsrs_.size() == 1)
1101 bool r =
tsrs_[0]->solveWorld();
1106 auto sim =
world_->getSim();
1111 auto skel = sim->getSkeleton(skidx);
1112 auto ik = skel->getIK(
true);
1113 r &= ik->solveAndApply(
true);
1123 for (
auto &tsr :
tsrs_)
1124 tsr->setPositionsWorldState(world);
1128 for (
auto &tsr :
tsrs_)
1129 tsr->getPositionsWorldState(world);
1137 unsigned int iter = 0;
1143 const Eigen::VectorXd limit = Eigen::VectorXd::Constant(world.size(),
limit_);
1148 while ((norm = f.norm()) > squared_tolerance and iter++ <
maxIter_)
1152 world -= (
step_ * j.colPivHouseholderQr().solve(f)).cwiseMin(limit).cwiseMax(-limit);
1157 auto svd = j.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV);
1158 auto lr = svd.rank();
1159 const auto &u = svd.matrixU().leftCols(lr);
1160 const auto &v = svd.matrixV().leftCols(lr);
1161 const auto &s = svd.singularValues().head(lr);
1162 const auto &d = Eigen::VectorXd::Constant(lr,
damping_);
1164 const auto &damped = s.cwiseQuotient(s.cwiseProduct(s) + d.cwiseProduct(d));
1166 Eigen::MatrixXd tmp;
1167 tmp.noalias() = u.adjoint() * f;
1168 tmp = damped.asDiagonal().inverse() * tmp;
1169 auto step = v * tmp;
1171 world -= (
step_ * step).cwiseMin(limit).cwiseMax(-limit);
1174 world -= (
step_ * j.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(f))
1187 return norm < squared_tolerance;
1192 auto sim =
world_->getSim();
1195 auto skel = sim->getSkeleton(skidx);
1196 auto ik = skel->getIK(
true);
1198 auto sv = ik->getSolver();
1217 for (
auto &tsr :
tsrs_)
1229 return tsrs_[0]->getWorldIndices();
1237 const auto &wii = wi[i];
1238 world[i] =
world_->getSim()->getSkeleton(wii.first)->getDof(wii.second)->getPosition();
1247 upper_ = Eigen::VectorXd::Zero(n);
1248 lower_ = Eigen::VectorXd::Zero(n);
1251 const auto &wii = wi[i];
1252 const auto &dof =
world_->getSim()->getSkeleton(wii.first)->getDof(wii.second);
1260 auto limits = dof->getPositionLimits();
1261 lower_[i] = limits.first;
1262 upper_[i] = limits.second;
1290 world = world.cwiseMin(
upper_);
1292 world = world.cwiseMax(
lower_);
1297 out <<
"TSRSet --------------------" <<
std::endl;
1298 for (
const auto &tsr :
tsrs_)
1299 tsr->getSpecification().print(out);
1300 out <<
"---------------------------" <<
std::endl;
1363 : ompl::base::Constraint(space->getDimension(), tsr->getDimension(), tsr->getTolerance())
1367 tsr_->useWorldIndices(space->getIndices());
1368 tsr_->setWorldIndices(space->getIndices());
1369 tsr_->setWorld(space->getWorld());
1371 tsr_->setWorldLowerLimits(space->getLowerBound());
1372 tsr_->setWorldUpperLimits(space->getUpperBound());
1377 Eigen::Ref<Eigen::VectorXd> out)
const
1379 tsr_->getErrorWorldState(x, out);
1383 Eigen::Ref<Eigen::MatrixXd> out)
const
1385 tsr_->getJacobianWorldState(x, out);
1393 if (
tsr_->numTSRs() == 1 or not
options.use_gradient)
1394 r =
tsr_->solveWorldState(x);
1396 else if (
options.use_gradient)
1397 r =
tsr_->solveGradientWorldState(x);
A shared pointer wrapper for robowflex::darts::StateSpace.
An OMPL constraint for TSRs. Under the hood, creates a TSRSet that is used for all computation....
bool project(Eigen::Ref< Eigen::VectorXd > x) const override
TSRSetPtr tsr_
Set of TSR constraints.
TSRSetPtr getSet()
Get TSR set for this constraint.
void jacobian(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::MatrixXd > out) const override
struct robowflex::darts::TSRConstraint::@7 options
Public options.
StateSpacePtr space_
Robot state space.
TSRConstraint(const StateSpacePtr &space, const TSRPtr &tsr)
Constructor for a single TSR.
void function(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > out) const override
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...
std::size_t getDimension() const
Get the error dimension of this set of TSRs.
void setStep(double step)
Set the step parameter in the solver.
double tolerance_
Tolerance for solving.
std::size_t getMaxIterations() const
Get the maximum iterations allowed.
void getJacobianWorldState(const Eigen::Ref< const Eigen::VectorXd > &world, Eigen::Ref< Eigen::MatrixXd > jacobian) const
Get the Jacobian given a provided world configuration.
void useWorldIndices(const std::vector< std::pair< std::size_t, std::size_t >> &indices)
Use World DoF indices for all TSRs computation. World indices are pairs of skeleton index and DoF ind...
void setWorldLowerLimits(const Eigen::Ref< const Eigen::VectorXd > &lower)
Set the lower limit on joints given their index in the world configuration.
void addSuffix(const std::string &suffix)
Add a suffix to the end of all structures in the TSRs in the set.
Eigen::VectorXd upper_
Upper bounds on world configuration.
void useIndices(const std::vector< std::size_t > &indices)
Use DoF indices for all TSRs computation.
double distanceWorldState(const Eigen::Ref< const Eigen::VectorXd > &world) const
Get the distance to satisfaction given a provided world configuration.
Eigen::VectorXd lower_
Lower bounds on world configuration.
bool damped_
If true, use damped SVD.
void useDamping(bool damping)
Set if damping is used in SVD solving.
void enforceBoundsWorld(Eigen::Ref< Eigen::VectorXd > world) const
Enforce upper and lower bounds on a world configuration.
void getErrorWorld(Eigen::Ref< Eigen::VectorXd > error) const
Get the current error given the world state.
WorldPtr world_
World to use.
std::size_t maxIter_
Maximum iterations to use for solving.
double getLimit() const
Get the solver limit parameter.
void setWorld(const WorldPtr &world)
Set the world used by this TSR set.
void setWorldUpperLimits(const Eigen::Ref< const Eigen::VectorXd > &upper)
Set the upper limit on joints given their index in the world configuration.
std::vector< double > weights_
Weights on TSRs.
void addTSR(const TSRPtr &tsr, bool intersect=true, double weight=1.0)
Add a TSR to the set.
void useQR()
Use QR for solving.
std::size_t dimension_
Total error dimension of set.
void initialize()
Initialize this set of TSRs.
bool solveWorldState(Eigen::Ref< Eigen::VectorXd > world)
Solve for a satisfying configuration given an initial world configuration.
void getPositionsWorldState(Eigen::Ref< Eigen::VectorXd > world) const
Get the current world state.
void print(std::ostream &out) const
Print out the TSRs in this set.
double limit_
Step size limit.
std::set< std::size_t > skel_indices_
All skeleton indices used by members of the set.
std::vector< TSRPtr > tsrs_
Set of TSRs.
std::size_t numTSRs() const
Get the number of TSRs in the set.
double getDamping() const
Get the solver damping parameter.
void setTolerance(double tolerance)
Set the maximum tolerance used for solving.
double distanceWorld() const
Get the current distance to satisfaction given the world state.
double getTolerance() const
Get the numerical tolerance for solving.
bool qr_
If true, use QR in gradient solve. Else, SVD.
TSRSet(const WorldPtr &world, const TSRPtr &tsr)
Constructor.
double step_
Step scaling in gradient.
const std::vector< TSRPtr > & getTSRs() const
Get the TSRs that form the set.
bool solveGradientWorldState(Eigen::Ref< Eigen::VectorXd > world)
Solve using gradient descent for a satisfying configuration given an initial world configuration.
const std::vector< std::pair< std::size_t, std::size_t > > & getWorldIndices() const
Get the world indices used.
void useSVD()
Use SVD for solving.
bool solveWorld()
Solve for a satisfying configuration given the current state of the world.
void useGroup(const std::string &name)
Use the joints in a robot's group. Robot used is the target frame's structure.
void setLimit(double limit)
Set the limit parameter in the solver.
void setDamping(double damping)
Set the damping parameter in the solver.
void computeLimits()
Compute the upper and lower limits from the skeleton.
double getStep() const
Get the solver step parameter.
void getErrorWorldState(const Eigen::Ref< const Eigen::VectorXd > &world, Eigen::Ref< Eigen::VectorXd > error) const
Get the error given a provided world configuration.
double damping_
Damping factor.
void setMaxIterations(std::size_t iterations)
Set the maximum iterations used for solving.
void updateSolver()
Update the solver information (iterations, tolerance, etc.)
void setWorldIndices(const std::vector< std::pair< std::size_t, std::size_t >> &indices)
Output world indices. TSR information for *WorldState methods uses this set of world indices....
The specification of a TSR.
void setNoZPosTolerance()
Set no position tolerance on the Z-axis.
Eigen::Vector3d lower
Lower position tolerance.
bool isPosConstrained(double lower, double upper) const
Checks if two values correspond to a position constraint.
std::string structure
Structure target frame is in.
bool isRotConstrained(double lower, double upper) const
Checks if two values correspond to a orientation constraint.
void setTarget(const std::string &structure, const std::string &frame)
Setting TSR Frame.
void addSuffix(const std::string &suffix)
Add a suffix to the structures for the target and base frame.
void setBase(const std::string &structure, const std::string &frame)
Set the base frame.
void setZRotTolerance(double bound)
Set the Z orientation tolerance to (-bound, bound).
void setRotation(const Eigen::Quaterniond &orientation)
Set the rotation of the TSR.
void setPose(const RobotPose &other)
Set the pose of the TSR.
void setFrame(const std::string &structure, const std::string &target, const std::string &base=magic::ROOT_FRAME)
Set the base and target frame.
std::string frame
Name of target frame.
void setYPosTolerance(double bound)
Set the Y position tolerance to (-bound, bound).
Eigen::Quaterniond getRotation() const
Get the current desired orientation.
void setNoPosTolerance()
Set no position tolerance at all.
std::size_t maxIter
Maximum iterations for solver.
bool isRotationConstrained() const
Returns true if TSR is orientation constrained.
void setNoXPosTolerance()
Set no position tolerance on the X-axis.
std::size_t getDimension() const
Compute and return constraint dimension of the TSR.
RobotPose pose
Pose of TSR.
void print(std::ostream &out) const
Print out this TSR information.
std::size_t dimension
Number of constrained dimensions.
void setNoXRotTolerance()
Set no orientation tolerance on the X-axis.
void setNoYPosTolerance()
Set no position tolerance on the Y-axis.
void setYRotTolerance(double bound)
Set the Y orientation tolerance to (-bound, bound).
Eigen::Vector3d getEulerRotation() const
Get the current desired orientation.
void setNoZRotTolerance()
Set no orientation tolerance on the Z-axis.
double tolerance
Tolerance on solution for solver.
struct robowflex::darts::TSR::Specification::@5 position
Position tolerances.
bool isPositionConstrained() const
Returns true if TSR is position constrained.
struct robowflex::darts::TSR::Specification::@6 orientation
Orientation tolerances.
ROBOWFLEX_EIGEN Eigen::Vector3d upper
Upper position tolerance.
void setXPosTolerance(double bound)
Setting Position Tolerances.
ROBOWFLEX_EIGEN struct robowflex::darts::TSR::Specification::@3 target
Target frame.
void setZPosTolerance(double bound)
Set the Z position tolerance to (-bound, bound).
void setXRotTolerance(double bound)
Setting Orientation Tolerances.
void setPoseFromWorld(const WorldPtr &world)
Set the pose of the TSR for the desired frame in a provided world. Uses world's current configuration...
void setNoYRotTolerance()
Set no orientation tolerance on the Y-axis.
Eigen::Vector3d getPosition() const
Getters and Informative Methods.
void setPosition(const Eigen::Ref< const Eigen::Vector3d > &position)
Setting TSR Pose.
struct robowflex::darts::TSR::Specification::@4 base
Base frame.
bool isRelative() const
Returns true if TSR is a relative reference frame (not the world).
bool intersect(const Specification &other)
Operations.
void setNoRotTolerance()
Set no orientation tolerance at all.
void fixBounds()
Fixes bounds so they are correct.
std::vector< bool > indices
Vector of active constraints. If an index is true, that constraint is active. Ordered by X-,...
Specification()=default
Default constructor.
dart::dynamics::InverseKinematics::TaskSpaceRegion * tsr_
TSR.
std::size_t getNumDofs() const
Get the number of controlled DoF for this TSR.
std::vector< std::size_t > indices_
Controlled indices.
void getErrorWorldRaw(Eigen::Ref< Eigen::VectorXd > error) const
Get the current error given the world state, with all values.
bool solveGradientWorld()
Solve using gradient descent for a satisfying configuration given the current state of the world.
std::vector< std::pair< std::size_t, std::size_t > > world_indices_
World indices.
const std::vector< std::pair< std::size_t, std::size_t > > & getWorldIndices() const
Get the set of output world indices used.
void fromBijection(Eigen::Ref< Eigen::VectorXd > state, const Eigen::Ref< const Eigen::VectorXd > &world) const
From a world configuration, map that configuration into a controlled DoF configuration....
std::vector< std::size_t > bijection_
void useWorldIndices(const std::vector< std::pair< std::size_t, std::size_t >> &indices)
Use World DoF indices for TSR computation. World indices are pairs of skeleton index and DoF index.
WorldPtr world_
Underlying world.
void updateBounds()
If the bounds of the specification are updated, call this to update underlying IK solver.
void getJacobianWorldState(const Eigen::Ref< const Eigen::VectorXd > &world, Eigen::Ref< Eigen::MatrixXd > jacobian) const
Get the Jacobian given a provided world configuration.
double distanceWorldState(const Eigen::Ref< const Eigen::VectorXd > &world) const
Get the distance to satisfaction given a provided world configuration.
std::shared_ptr< dart::dynamics::SimpleFrame > frame_
Target frame of TSR.
std::vector< std::pair< std::size_t, std::size_t > > computeWorldIndices() const
Compute the set of world indices used based on the underlying active indices.
void updateSolver()
If the solver parameters of the specification are updated, call this to update underlying IK solver.
void getPositionsWorldState(Eigen::Ref< Eigen::VectorXd > world) const
Get the positions of the world into a world configuration.
dart::dynamics::BodyNode * tnd_
Target body node.
void toBijection(Eigen::Ref< Eigen::VectorXd > world, const Eigen::Ref< const Eigen::VectorXd > &state) const
From a configuration of controlled indices, map that configuration into a world configuration....
void getErrorWorld(Eigen::Ref< Eigen::VectorXd > error) const
Get the current error given the world state.
void initialize()
Initialize this TSR. Creates IK node attached to body node in world.
double distanceWorld() const
Get the current distance to satisfaction given the world state.
void setWorldIndices(const std::vector< std::pair< std::size_t, std::size_t >> &indices)
Output world indices. TSR information for *WorldState methods uses this set of world indices....
void clear()
Clears the initialization of this TSR.
robowflex::RobotPose getTransformToFrame() const
Gets the transformation from the specification's base to the TSR's frame.
std::shared_ptr< dart::dynamics::InverseKinematics > ik_
Inverse kinematics module.
Specification & getSpecification()
Get the specification for this TSR.
void getJacobianWorld(Eigen::Ref< Eigen::MatrixXd > jacobian) const
Get the current Jacobian given the world state.
bool solve(Eigen::Ref< Eigen::VectorXd > state)
Solve for a satisfying configuration given an initial configuration of the controlled DoF.
void computeBijection()
Compute the mapping from world indices to controlled DoF indices.
std::size_t getDimension() const
Get the error dimension of this TSR.
~TSR()
Destructor. Disables IK on node if created.
void setPositions(const Eigen::Ref< const Eigen::VectorXd > &state) const
Set the positions of the world given a configuration.
void useIndices(const std::vector< std::size_t > &indices)
Use DoF indices for TSR computation.
bool solveWorldState(Eigen::Ref< Eigen::VectorXd > world)
Solve for a satisfying configuration given an initial world configuration.
void updatePose()
If the pose of the specification is updated, call this to update underlying IK solver.
TSR(const WorldPtr &world, const Specification &spec)
Constructor.
void getJacobian(const Eigen::Ref< const Eigen::VectorXd > &state, Eigen::Ref< Eigen::MatrixXd > jacobian) const
Get the Jacobian given a configuration of the controlled DoF.
double distance(const Eigen::Ref< const Eigen::VectorXd > &state) const
Get the distance to satisfaction given a configuration of the controlled DoF.
void getError(const Eigen::Ref< const Eigen::VectorXd > &state, Eigen::Ref< Eigen::VectorXd > error) const
Get the error given a configuration of the controlled DoF.
std::size_t skel_index_
Index of controlled skeleton.
void setPositionsWorldState(const Eigen::Ref< const Eigen::VectorXd > &world) const
Set the positions of the world given a world configuration.
void getPositions(Eigen::Ref< Eigen::VectorXd > state) const
Get the positions of the world given into a configuration.
void setWorld(const WorldPtr &world)
Set the world used by this TSR.
bool solveWorld()
Solve for a satisfying configuration given the current state of the world.
bool solveGradientWorldState(Eigen::Ref< Eigen::VectorXd > world)
Solve using gradient descent for a satisfying configuration given an initial world configuration.
void useGroup(const std::string &name)
Use the joints in a robot's group. Robot used is the target frame's structure.
Specification spec_
TSR specification.
bool solveGradient(Eigen::Ref< Eigen::VectorXd > state)
Solve using gradient descent for a satisfying configuration given an initial configuration of the con...
void getErrorWorldState(const Eigen::Ref< const Eigen::VectorXd > &world, Eigen::Ref< Eigen::VectorXd > error) const
Get the error given a provided world configuration.
std::size_t getSkeletonIndex()
Get the skeleton index for the target frame's structure.
const std::vector< std::size_t > & getIndices() const
Get the set of indices used for TSR computation.
std::size_t getNumWorldDofs() const
Get the number of world DoF for this TSR.
A shared pointer wrapper for robowflex::darts::World.
T emplace_back(T... args)
#define RBX_ERROR(fmt,...)
Output a error logging message.
#define RBX_INFO(fmt,...)
Output a info logging message.
Functions for loading and animating robots in Blender.
RobotPose createPoseQ(double x, double y, double z, double W, double X, double Y, double Z)
Creates a robot pose from a linear component and a Quaternion.
Eigen::Quaterniond getPoseRotation(const RobotPose &pose)
Get the rotational component of a robot pose.
static const double two_pi
static const std::string ROOT_FRAME
DART-based robot modeling and planning.
std::string format(const std::string &fmt, Args &&... args)
Recursion base case, return string form of formatted arguments.
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.