46 Eigen::VectorXd q(
prob_->N);
48 #if ROS_VERSION_MINIMUM(1, 12, 0) // if ROS version >= ROS_KINETIC 49 std::static_pointer_cast<
OMPLStateSpace>(si_->getStateSpace())->OMPLToExoticaState(state, q);
51 boost::static_pointer_cast<OMPLStateSpace>(si_->getStateSpace())->OMPLToExoticaState(state, q);
54 if (!
prob_->IsStateValid(q))
64 setName(
"OMPLRNStateSpace");
69 return CompoundStateSpace::allocDefaultStateSampler();
74 unsigned int dim = prob->N;
75 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::RealVectorStateSpace(dim)), 1.0);
76 ompl::base::RealVectorBounds ompl_bounds(dim);
77 auto bounds = prob->GetBounds();
78 for (
unsigned int i = 0; i < dim; ++i)
80 ompl_bounds.setHigh(i, bounds[i + dim]);
81 ompl_bounds.setLow(i, bounds[i]);
83 getSubspace(0)->as<ompl::base::RealVectorStateSpace>()->setBounds(ompl_bounds);
84 setLongestValidSegmentFraction(
init_.LongestValidSegmentFraction);
94 if (q.rows() != (int)getDimension())
96 ThrowPretty(
"State vector (" << q.rows() <<
") and internal state (" << (int)getDimension() <<
") dimension disagree");
107 if (q.rows() != (int)getDimension())
108 q.resize((
int)getDimension());
119 setName(
"OMPLSE3RNStateSpace");
124 return CompoundStateSpace::allocDefaultStateSampler();
130 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::SE3StateSpace()), 1.0);
134 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::RealVectorStateSpace(
dim_ - 6)), 1.0);
137 auto bounds = prob->GetBounds();
138 if (bounds.size() == 2 *
dim_)
141 ompl::base::RealVectorBounds SE3bounds(3);
142 for (
int i = 0; i < 3; ++i)
144 SE3bounds.setHigh(i, bounds[i +
dim_]);
145 SE3bounds.setLow(i, bounds[i]);
147 getSubspace(0)->as<ompl::base::SE3StateSpace>()->setBounds(SE3bounds);
148 WARNING_NAMED(
"OMPLSE3RNStateSpace::SetBounds",
"Orientation bounds on SE(3) component ignored.");
152 ompl::base::RealVectorBounds RNbounds(
dim_ - 6);
153 for (
unsigned int i = 6; i <
dim_; ++i)
155 RNbounds.setHigh(i - 6, bounds[i + dim_]);
156 RNbounds.setLow(i - 6, bounds[i]);
158 getSubspace(1)->as<ompl::base::RealVectorStateSpace>()->setBounds(RNbounds);
163 ERROR(
"State space bounds were not specified!\n" 164 << bounds.size() <<
" " <<
dim_);
166 setLongestValidSegmentFraction(
init_.LongestValidSegmentFraction);
183 memcpy(statetype->
RealVectorStateSpace().values, q.segment(6, q.rows() - 6).data(),
sizeof(double) * (q.rows() - 6));
189 q.setZero(getDimension());
196 tmp.
GetRPY(q(3), q(4), q(5));
200 memcpy(q.segment(6, q.rows() - 6).data(), statetype->
RealVectorStateSpace().values,
sizeof(double) * (q.rows() - 6));
206 setName(
"OMPLSE2RNStateSpace");
211 return CompoundStateSpace::allocDefaultStateSampler();
217 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::SE2StateSpace()), 1.0);
220 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::RealVectorStateSpace(
dim_ - 3)), 1.0);
223 auto bounds = prob->GetBounds();
224 if (bounds.size() == 2 *
dim_)
226 ompl::base::RealVectorBounds SE2bounds(2);
227 for (
int i = 0; i < 3; ++i)
229 SE2bounds.setHigh(i, bounds[i +
dim_]);
230 SE2bounds.setLow(i, bounds[i]);
232 getSubspace(0)->as<ompl::base::SE2StateSpace>()->setBounds(SE2bounds);
233 WARNING_NAMED(
"OMPLSE2RNStateSpace::SetBounds",
"Yaw bounds on SE(2) component ignored.");
237 ompl::base::RealVectorBounds RNbounds(
dim_ - 3);
238 for (
unsigned int i = 3; i <
dim_; ++i)
240 RNbounds.setHigh(i - 3, prob->GetBounds()[i +
dim_]);
241 RNbounds.setLow(i - 3, prob->GetBounds()[i]);
243 getSubspace(1)->as<ompl::base::RealVectorStateSpace>()->setBounds(RNbounds);
248 ERROR(
"State space bounds were not specified!" << std::endl
249 << bounds.size() <<
" " <<
dim_);
251 setLongestValidSegmentFraction(
init_.LongestValidSegmentFraction);
267 memcpy(statetype->
RealVectorStateSpace().values, q.segment(3, q.rows() - 3).data(),
sizeof(double) * (q.rows() - 3));
273 q.setZero(getDimension());
281 memcpy(q.segment(3, q.rows() - 3).data(), statetype->
RealVectorStateSpace().values,
sizeof(double) * (q.rows() - 3));
287 setName(
"OMPLDubinsRNStateSpace");
292 return CompoundStateSpace::allocDefaultStateSampler();
298 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::DubinsStateSpace(
init_.DubinsStateSpaceTurningRadius,
init_.DubinsStateSpaceIsSymmetric)), 1.0);
301 addSubspace(ompl::base::StateSpacePtr(
new ompl::base::RealVectorStateSpace(
dim_ - 3)), 1.0);
304 auto bounds = prob->GetBounds();
305 if (bounds.size() == 2 *
dim_)
307 ompl::base::RealVectorBounds Dubinsbounds(2);
308 for (
int i = 0; i < 3; ++i)
310 Dubinsbounds.setHigh(i, bounds[i +
dim_]);
311 Dubinsbounds.setLow(i, bounds[i]);
313 getSubspace(0)->as<ompl::base::DubinsStateSpace>()->setBounds(Dubinsbounds);
314 WARNING_NAMED(
"OMPLDubinsRNStateSpace::SetBounds",
"Yaw bounds on SE(2) component ignored.");
318 ompl::base::RealVectorBounds RNbounds(
dim_ - 3);
319 for (
unsigned int i = 3; i <
dim_; ++i)
321 RNbounds.setHigh(i - 3, prob->GetBounds()[i +
dim_]);
322 RNbounds.setLow(i - 3, prob->GetBounds()[i]);
324 getSubspace(1)->as<ompl::base::RealVectorStateSpace>()->setBounds(RNbounds);
329 ERROR(
"State space bounds were not specified!" << std::endl
330 << bounds.size() <<
" " <<
dim_);
332 setLongestValidSegmentFraction(
init_.LongestValidSegmentFraction);
348 memcpy(statetype->
RealVectorStateSpace().values, q.segment(3, q.rows() - 3).data(),
sizeof(double) * (q.rows() - 3));
354 q.setZero(getDimension());
362 memcpy(q.segment(3, q.rows() - 3).data(), statetype->
RealVectorStateSpace().values,
sizeof(double) * (q.rows() - 3));
void ExoticaToOMPLState(const Eigen::VectorXd &q, ompl::base::State *state) const override
void StateDebug(const Eigen::VectorXd &q) const override
void ExoticaToOMPLState(const Eigen::VectorXd &q, ompl::base::State *state) const override
const ompl::base::SE3StateSpace::StateType & SE3StateSpace() const
void SetBounds(SamplingProblemPtr &prob) override
#define WARNING_NAMED(name, x)
void OMPLToExoticaState(const ompl::base::State *state, Eigen::VectorXd &q) const override
void ExoticaToOMPLState(const Eigen::VectorXd &q, ompl::base::State *state) const override
void OMPLToExoticaState(const ompl::base::State *state, Eigen::VectorXd &q) const override
static Rotation Quaternion(double x, double y, double z, double w)
const ompl::base::RealVectorStateSpace::StateType & RealVectorStateSpace() const
bool isValid(const ompl::base::State *state) const override
const ompl::base::SE2StateSpace::StateType & SE2StateSpace() const
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override
void GetQuaternion(double &x, double &y, double &z, double &w) const
OMPLDubinsRNStateSpace(OMPLSolverInitializer init)
const ompl::base::DubinsStateSpace::StateType & DubinsStateSpace() const
void OMPLToExoticaState(const ompl::base::State *state, Eigen::VectorXd &q) const override
void OMPLToExoticaState(const ompl::base::State *state, Eigen::VectorXd &q) const override
void SetBounds(SamplingProblemPtr &prob) override
static Rotation RPY(double roll, double pitch, double yaw)
const ompl::base::RealVectorStateSpace::StateType & RealVectorStateSpace() const
void ExoticaToOMPLState(const Eigen::VectorXd &q, ompl::base::State *state) const override
void StateDebug(const Eigen::VectorXd &q) const override
std::shared_ptr< exotica::SamplingProblem > SamplingProblemPtr
void GetRPY(double &roll, double &pitch, double &yaw) const
void StateDebug(const Eigen::VectorXd &q) const override
const ompl::base::RealVectorStateSpace::StateType & getRNSpace() const
void SetBounds(SamplingProblemPtr &prob) override
OMPLSE3RNStateSpace(OMPLSolverInitializer init)
OMPLStateValidityChecker(const ompl::base::SpaceInformationPtr &si, const SamplingProblemPtr &prob)
const ompl::base::RealVectorStateSpace::StateType & RealVectorStateSpace() const
OMPLSolverInitializer init_
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override
void StateDebug(const Eigen::VectorXd &q) const override
void SetBounds(SamplingProblemPtr &prob) override
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override
OMPLRNStateSpace(OMPLSolverInitializer init)
OMPLSE2RNStateSpace(OMPLSolverInitializer init)
ompl::base::StateSamplerPtr allocDefaultStateSampler() const override