3 #include <ompl/base/spaces/RealVectorStateProjections.h> 
   21   : ompl::base::RealVectorStateSampler(space), joints_(space->joints_)
 
   29     for (
const auto &joint : 
joints_)
 
   30         joint->sample(joint->getSpaceVars(as->data));
 
   39     for (
const auto &joint : 
joints_)
 
   40         joint->sampleNear(joint->getSpaceVars(as->data), joint->getSpaceVarsConst(an->
data), 
distance);
 
   70         RBX_ERROR(
"Robot %1% does not exist in world.", name);
 
   74     auto joints = 
robot->getGroupJoints(group);
 
   84     for (
auto *joint : joints)
 
   94         const auto &type = joint->getType();
 
   95         if (type == 
"RevoluteJoint")
 
   97             auto *revolute = 
static_cast<dart::dynamics::RevoluteJoint *
>(joint);
 
   99             if (revolute->isCyclic(0))
 
  105                     addJoint(group_name, std::make_shared<RnJoint>(
this, revolute, low, high));
 
  108                     addJoint(group_name, std::make_shared<SO2Joint>(
this, revolute));
 
  112                 auto *dof = joint->getDof(0);
 
  113                 auto limits = dof->getPositionLimits();
 
  114                 addJoint(group_name, std::make_shared<RnJoint>(
this, revolute, limits.first, limits.second));
 
  117         else if (type == 
"PrismaticJoint")
 
  119             auto *prismatic = 
static_cast<dart::dynamics::PrismaticJoint *
>(joint);
 
  120             auto *dof = joint->getDof(0);
 
  121             auto limits = dof->getPositionLimits();
 
  122             addJoint(group_name, std::make_shared<RnJoint>(
this, prismatic, limits.first, limits.second));
 
  124         else if (type == 
"PlanarJoint")
 
  127             auto *planar = 
static_cast<dart::dynamics::PlanarJoint *
>(joint);
 
  131                 Eigen::Vector3d high;
 
  136                     low[i] = 
world_->getWorkspaceLowConst()[i];
 
  137                     high[i] = 
world_->getWorkspaceHighConst()[i];
 
  143                 addJoint(group_name, std::make_shared<RnJoint>(
this, planar, 3, 0, low, high));
 
  148                 Eigen::Vector2d high;
 
  152                     low[i] = 
world_->getWorkspaceLowConst()[i];
 
  153                     high[i] = 
world_->getWorkspaceHighConst()[i];
 
  156                 addJoint(group_name, std::make_shared<RnJoint>(
this, planar, 2, 0, low, high));
 
  157                 addJoint(group_name, std::make_shared<SO2Joint>(
this, planar, 2));
 
  160         else if (type == 
"FreeJoint")
 
  162             auto *free = 
static_cast<dart::dynamics::FreeJoint *
>(joint);
 
  170                 Eigen::Vector6d high;
 
  177                         std::max({free->getPositionLowerLimit(3 + i), 
world_->getWorkspaceLowConst()[i]});
 
  179                         std::min({free->getPositionUpperLimit(3 + i), 
world_->getWorkspaceHighConst()[i]});
 
  181                 auto j = std::make_shared<RnJoint>(
this, free, 6, 0, low, high);
 
  187                 Eigen::Vector3d high;
 
  192                         std::max({free->getPositionLowerLimit(3 + i), 
world_->getWorkspaceLowConst()[i]});
 
  194                         std::min({free->getPositionUpperLimit(3 + i), 
world_->getWorkspaceHighConst()[i]});
 
  197                 addJoint(group_name, std::make_shared<RnJoint>(
this, free, 3, 3, low, high));
 
  198                 addJoint(group_name, std::make_shared<SO3Joint>(
this, free));
 
  202             RBX_WARN(
"Unknown joint type %1%, skipping.", type);
 
  205     registerDefaultProjection(
 
  206         std::make_shared<ompl::base::RealVectorRandomLinearProjectionEvaluator>(
this, 2));
 
  214     if (not std::dynamic_pointer_cast<RnJoint>(joint))
 
  232     for (
const auto &joint : 
joints_)
 
  234         const auto &v = joint->getSpaceVarsConst(x);
 
  235         joint->setJointState(world, v);
 
  238     world->forceUpdate();
 
  249     for (
const auto &joint : 
joints_)
 
  251         const auto &v = joint->getSpaceVars(x);
 
  252         joint->getJointState(world, v);
 
  257                                     const Eigen::Ref<const Eigen::VectorXd> &x)
 const 
  262     for (
const auto &joint : joints)
 
  265         joint->setJointState(world, x.segment(index, n));
 
  269     world->forceUpdate();
 
  273                                     Eigen::Ref<Eigen::VectorXd> x)
 const 
  278     for (
const auto &joint : joints)
 
  281         joint->getJointState(world, x.segment(index, n));
 
  289     for (
const auto &joint : 
joints_)
 
  291         auto v = joint->getSpaceVars(as->data);
 
  292         joint->enforceBounds(v);
 
  299     for (
const auto &joint : 
joints_)
 
  301         const auto &v = joint->getSpaceVarsConst(as->data);
 
  302         if (not joint->satisfiesBounds(v))
 
  311     const auto &as1 = state1->as<
StateType>();
 
  312     const auto &as2 = state2->as<
StateType>();
 
  315     for (
const auto &joint : 
joints_)
 
  317         const auto &v1 = joint->getSpaceVarsConst(as1->data);
 
  318         const auto &v2 = joint->getSpaceVarsConst(as2->
data);
 
  320         d += joint->distance(v1, v2);
 
  329     for (
const auto &joint : 
joints_)
 
  330         d += joint->getMaximumExtent();
 
  337     return distance(state1, state2) <= 1e-8;
 
  341                              ompl::base::State *state)
 const 
  347     for (
const auto &joint : 
joints_)
 
  349         const auto &vf = joint->getSpaceVarsConst(af->data);
 
  350         const auto &vt = joint->getSpaceVarsConst(at->
data);
 
  351         auto vs = joint->getSpaceVars(as->
data);
 
  353         joint->interpolate(vf, vt, t, vs);
 
  359     return std::make_shared<StateSampler>(
this);
 
  386     for (
const auto &joint : 
joints_)
 
  388         auto skelx = joint->getSkeletonIndex();
 
  389         auto add = joint->getIndices();
 
  390         for (
const auto &index : add)
 
  405                            [&](
const JointPtr &j) { return j->getJoint(world_)->getName() == name; });
 
  417                                Eigen::Ref<Eigen::VectorXd> v)
 const 
  423     for (
const auto &joint : joints)
 
  426         v.segment(index, n) = joint->getSpaceVarsConst(as->data);
 
  432                                const Eigen::Ref<const Eigen::VectorXd> &v)
 const 
  438     for (
const auto &joint : joints)
 
  441         joint->getSpaceVars(as->data) = v.segment(index, n);
 
  465     for (
const auto &joint : joints)
 
  467         const auto &jdofs = joint->getDofs();
 
  468         dofs.
insert(dofs.
end(), jdofs.begin(), jdofs.end());
 
  476     const auto &bounds = getBounds();
 
  477     return Eigen::Map<const Eigen::VectorXd>(bounds.low.data(), bounds.low.size());
 
  482     const auto &bounds = getBounds();
 
  483     return Eigen::Map<const Eigen::VectorXd>(bounds.high.data(), bounds.high.size());
 
A shared pointer wrapper for robowflex::darts::Joint.
 
void sampleUniform(ompl::base::State *state) override
 
void sampleUniformNear(ompl::base::State *state, const ompl::base::State *near, double distance) override
 
StateSampler(const StateSpace *space)
Constructor.
 
State type for the robowflex::darts::StateSpace.
 
Eigen::VectorXd data
Vector for configuration.
 
StateType(std::size_t n)
Constructor.
 
An OMPL state space for robowflex::darts::World. Can do motion planning for any of the robots or stru...
 
void addJointToGroup(const std::string &group_name, const JointPtr &joint)
 
void setWorldState(WorldPtr world, const ompl::base::State *state) const
Set the state of a world from an OMPL state.
 
bool metric_
Is this space all Rn?
 
void interpolate(const ompl::base::State *from, const ompl::base::State *to, double t, ompl::base::State *state) const override
 
std::vector< std::pair< std::size_t, std::size_t > > getIndices() const
Get the set of indices that is being planned for. Pairs of skeleton index and joint index.
 
void getGroupState(const std::string &group, const ompl::base::State *state, Eigen::Ref< Eigen::VectorXd > v) const
From a full state, get only the state of a group.
 
Eigen::VectorXd getLowerBound() const
Get a vector of the lower joint bounds for the space.
 
const WorldPtr & getWorldConst() const
Get underlying world.
 
ompl::base::State * allocState() const override
 
void getWorldState(WorldPtr world, ompl::base::State *state) const
Get the state of a world in an OMPL state.
 
const std::vector< JointPtr > & getJoints() const
Get a vector of the joints being planned for.
 
bool isMetricSpace() const override
 
bool satisfiesBounds(const ompl::base::State *state) const override
 
StateSpace(WorldPtr world)
Constructor.
 
Eigen::VectorXd getUpperBound() const
Get a vector of the upper joint bounds for the space.
 
void enforceBounds(ompl::base::State *state) const override
 
WorldPtr world_
World to use for planning.
 
std::vector< JointPtr > joints_
Vector of all joints used in planning.
 
double distance(const ompl::base::State *state1, const ompl::base::State *state2) const override
 
void setMetricSpace(bool metric)
 
void addJoint(const std::string &group_name, const JointPtr &joint)
 
std::set< dart::dynamics::Joint * > jointset_
Set of joints used in planning.
 
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override
 
double getMaximumExtent() const override
 
std::vector< std::string > getGroupDofNames(const std::string &group_name) const
Get the names of each of the dof controlled by a group.
 
void freeState(ompl::base::State *state) const override
 
void addGroupFromJoints(const std::string &group_name, const std::vector< dart::dynamics::Joint * > &joints, std::size_t cyclic=0)
Add a group to be planned for.
 
void addGroup(const std::string &name, const std::string &group, std::size_t cyclic=0)
Add a group to be planned for.
 
std::map< std::string, std::vector< JointPtr > > group_joints_
Joints belonging to a group.
 
std::map< std::string, std::size_t > group_dimension_
Dimension of the group.
 
bool equalStates(const ompl::base::State *state1, const ompl::base::State *state2) const override
 
WorldPtr getWorld()
Get underlying world.
 
void getWorldGroupState(WorldPtr world, const std::string &group_name, Eigen::Ref< Eigen::VectorXd > x) const
Get the group state of a world.
 
void setGroupState(const std::string &group, ompl::base::State *state, const Eigen::Ref< const Eigen::VectorXd > &v) const
Set a (sub)group state in a full state.
 
std::size_t getGroupDimension(const std::string &group) const
Get the dimension of joint variables for a subgroup.
 
JointPtr getJoint(std::size_t index) const
Get a joint that is being planned for.
 
void setWorldGroupState(WorldPtr world, const std::string &group_name, const Eigen::Ref< const Eigen::VectorXd > &x) const
Set the state of a world from a configuration of a group.
 
std::vector< std::string > getGroups() const
Get the names of all groups managed by this space.
 
A shared pointer wrapper for robowflex::darts::World.
 
T emplace_back(T... args)
 
#define RBX_WARN(fmt,...)
Output a warning logging message.
 
#define RBX_ERROR(fmt,...)
Output a error logging message.
 
Functions for loading and animating robots in Blender.
 
DART-based robot modeling and planning.