12 #include <ompl/base/spaces/RealVectorStateProjections.h> 14 using namespace se2ez;
23 values =
state->data.data();
31 :
ompl::base::RealVectorStateSpace(robot->getNumJoints()),
robot_(robot),
frames_(robot->getJoints())
33 const auto &upper =
robot_->getUpperLimits();
34 const auto &lower =
robot_->getLowerLimits();
35 for (
unsigned int i = 0; i < dimension_; ++i)
37 bounds_.setLow(i, lower[i]);
38 bounds_.setHigh(i, upper[i]);
42 setLongestValidSegmentFraction(0.01 / robot->getNumJoints() / 2);
48 robot_->enforceLimits(as->state);
54 return robot_->inLimits(as->state);
59 const auto *as1 = state1->as<
StateType>();
60 const auto *as2 = state2->as<
StateType>();
71 ompl::base::State *state)
const 110 for (
const auto &pair :
frames_)
112 const auto &frame = pair.second;
113 out << frame->frame->getName() <<
tf::printVector(frame->getValuesConst(as->state->data))
123 as->
state->dirty =
true;
124 return index < dimension_ ? &as->state->data[index] :
nullptr;
131 return std::make_shared<plan::StateSampler>(
this);
136 const auto &ees =
robot_->getEEs();
137 for (
const auto &ee : ees)
139 registerProjection(ee +
":R2", std::make_shared<R2Projection>(
this, ee));
140 registerProjection(ee +
":SE2", std::make_shared<SE2Projection>(
this, ee));
147 int p =
std::max(2, (
int)ceil(log((
double)dimension_)));
148 registerDefaultProjection(
149 std::make_shared<ompl::base::RealVectorRandomLinearProjectionEvaluator>(
this, p));
152 registerDefaultProjection(
153 std::make_shared<ompl::base::RealVectorIdentityProjectionEvaluator>(
this));
156 registerDefaultProjection(getRegisteredProjections().find(ees.front() +
":R2")->second);
StateType(const RobotPtr &robot)
A shared pointer wrapper for se2ez::State.
A representation of a state of a Robot.
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::string, Robot::FrameDataPtr > > frames_
void printState(const ompl::base::State *state, std::ostream &out) const override
bool satisfiesBounds(const ompl::base::State *state) const override
void copyState(ompl::base::State *destination, const ompl::base::State *source) const override
void enforceBounds(ompl::base::State *state) const override
bool equalStates(const ompl::base::State *state1, const ompl::base::State *state2) const override
StateSpace(const RobotPtr &robot)
void freeState(ompl::base::State *state) const override
ompl::base::State * allocState() const override
double * getValueAddressAtIndex(ompl::base::State *state, unsigned int index) const override
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override
double distance(const ompl::base::State *state1, const ompl::base::State *state2) const override
A shared pointer wrapper for se2ez::Robot.
std::string printVector(const Eigen::VectorXd &v, unsigned int precision=4)
Returns a string of a vector's contents.
const RobotPtr getRobot() const
void registerProjections() override