Loading...
Searching...
No Matches
WrapperStateSpace.cpp
1/*********************************************************************
2* Software License Agreement (BSD License)
3*
4* Copyright (c) 2017, Rice University
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions
9* are met:
10*
11* * Redistributions of source code must retain the above copyright
12* notice, this list of conditions and the following disclaimer.
13* * Redistributions in binary form must reproduce the above
14* copyright notice, this list of conditions and the following
15* disclaimer in the documentation and/or other materials provided
16* with the distribution.
17* * Neither the name of the Rice University nor the names of its
18* contributors may be used to endorse or promote products derived
19* from this software without specific prior written permission.
20*
21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32* POSSIBILITY OF SUCH DAMAGE.
33*********************************************************************/
34
35/* Author: Zachary Kingston */
36
37#include "ompl/base/spaces/WrapperStateSpace.h"
38
43
44void ompl::base::WrapperStateSampler::sampleUniformNear(State *state, const State *near, double distance)
45{
46 sampler_->sampleUniformNear(state->as<ompl::base::WrapperStateSpace::StateType>()->getState(),
48}
49
50void ompl::base::WrapperStateSampler::sampleGaussian(State *state, const State *mean, double stdDev)
51{
54}
55
56ompl::base::WrapperProjectionEvaluator::WrapperProjectionEvaluator(const ompl::base::WrapperStateSpace *space)
57 : ompl::base::ProjectionEvaluator(space), projection_(space->getSpace()->getDefaultProjection())
58{
59}
60
62{
63 cellSizes_ = projection_->getCellSizes();
65}
66
68{
69 return projection_->getDimension();
70}
71
72void ompl::base::WrapperProjectionEvaluator::project(const State *state, Eigen::Ref<Eigen::VectorXd> projection) const
73{
74 projection_->project(state->as<ompl::base::WrapperStateSpace::StateType>()->getState(), projection);
75}
76
78{
79 space_->setup();
80 maxExtent_ = space_->getMaximumExtent();
81 longestValidSegmentFraction_ = space_->getLongestValidSegmentFraction();
82 longestValidSegmentCountFactor_ = space_->getValidSegmentCountFactor();
83 longestValidSegment_ = space_->getLongestValidSegmentLength();
84 projections_ = space_->getRegisteredProjections();
85 params_ = space_->params();
86
87 valueLocationsInOrder_ = space_->getValueLocations();
88 valueLocationsByName_ = space_->getValueLocationsByName();
89 substateLocationsByName_ = space_->getSubstateLocationsByName();
90
91 registerDefaultProjection(std::make_shared<WrapperProjectionEvaluator>(this));
92}
Abstract definition for a class computing projections to Rn. Implicit integer grids are imposed on th...
virtual void setup()
Perform configuration steps, if needed.
std::vector< double > cellSizes_
The size of a cell, in every dimension of the projected space, in the implicitly defined integer grid...
ParamSet params_
The set of parameters for this space.
Definition StateSpace.h:553
std::map< std::string, SubstateLocation > substateLocationsByName_
All the known substat locations, by name.
Definition StateSpace.h:565
double longestValidSegment_
The longest valid segment at the time setup() was called.
Definition StateSpace.h:543
unsigned int longestValidSegmentCountFactor_
The factor to multiply the value returned by validSegmentCount(). Rarely used but useful for things l...
Definition StateSpace.h:547
std::map< std::string, ProjectionEvaluatorPtr > projections_
List of available projections.
Definition StateSpace.h:550
std::vector< ValueLocation > valueLocationsInOrder_
The value locations for all varliables of type double contained in a state; The locations point to va...
Definition StateSpace.h:557
std::map< std::string, ValueLocation > valueLocationsByName_
All the known value locations, by name. The names of state spaces access the first element of a state...
Definition StateSpace.h:562
void registerDefaultProjection(const ProjectionEvaluatorPtr &projection)
Register the default projection for this state space.
double longestValidSegmentFraction_
The fraction of the longest valid segment.
Definition StateSpace.h:540
double maxExtent_
The extent of this space at the time setup() was called.
Definition StateSpace.h:537
Definition of an abstract state.
Definition State.h:50
const T * as() const
Cast this instance to a desired type.
Definition State.h:66
unsigned int getDimension() const override
Return the dimension of the projection defined by this evaluator.
void project(const State *state, Eigen::Ref< Eigen::VectorXd > projection) const override
Compute the projection as an array of double values.
void setup() override
Perform configuration steps, if needed.
void sampleUniformNear(State *state, const State *near, double distance) override
Sample a nearby state using underlying sampler.
StateSamplerPtr sampler_
Underlying state sampler.
void sampleUniform(State *state) override
Sample a state using underlying sampler.
void sampleGaussian(State *state, const State *mean, double stdDev) override
Sample a state within a Gaussian distribution using underlying sampler.
Wrapper state type. Contains a reference to an underlying state.
const State * getState() const
Get a const pointer to the underlying state.
State space wrapper that transparently passes state space operations through to the underlying space....
void setup() override
Perform final setup steps. This function is automatically called by the SpaceInformation....
This namespace contains sampling based planning routines shared by both planning under geometric cons...
Main namespace. Contains everything in this library.