A space to allow the composition of state spaces. More...
#include <ompl/base/StateSpace.h>

Public Types | |
typedef CompoundState | StateType |
Define the type of state allocated by this state space. | |
Public Member Functions | |
CompoundStateSpace () | |
Construct an empty compound state space. | |
CompoundStateSpace (const std::vector< StateSpacePtr > &components, const std::vector< double > &weights) | |
Construct a compound state space from a list of subspaces (components) and their corresponding weights (weights) | |
template<class T > | |
T * | as (const unsigned int index) const |
Cast a component of this instance to a desired type. | |
template<class T > | |
T * | as (const std::string &name) const |
Cast a component of this instance to a desired type. | |
virtual bool | isCompound () const |
Check if the state space is compound. | |
virtual bool | isHybrid () const |
Check if this is a hybrid state space (i.e., both discrete and continuous components exist) | |
virtual void | printState (const State *state, std::ostream &out) const |
Print a state to a stream. | |
virtual void | printSettings (std::ostream &out) const |
Print the settings for this state space to a stream. | |
virtual void | computeLocations () |
Compute the location information for various components of the state space. Either this function or setup() must be called before any calls to getValueAddressAtName(), getValueAddressAtLocation() (and other functions where those are used). | |
virtual void | setup () |
Perform final setup steps. This function is automatically called by the SpaceInformation. If any default projections are to be registered, this call will set them and call their setup() functions. It is safe to call this function multiple times. At a subsequent call, projections that have been previously user configured are not re-instantiated, but their setup() method is still called. | |
Management of contained subspaces | |
void | addSubspace (const StateSpacePtr &component, double weight) |
Adds a new state space as part of the compound state space. For computing distances within the compound state space, the weight of the component also needs to be specified. | |
unsigned int | getSubspaceCount () const |
Get the number of state spaces that make up the compound state space. | |
const StateSpacePtr & | getSubspace (const unsigned int index) const |
Get a specific subspace from the compound state space. | |
const StateSpacePtr & | getSubspace (const std::string &name) const |
Get a specific subspace from the compound state space. | |
unsigned int | getSubspaceIndex (const std::string &name) const |
Get the index of a specific subspace from the compound state space. | |
bool | hasSubspace (const std::string &name) const |
Check if a specific subspace is contained in this state space. | |
double | getSubspaceWeight (const unsigned int index) const |
Get the weight of a subspace from the compound state space (used in distance computation) | |
double | getSubspaceWeight (const std::string &name) const |
Get the weight of a subspace from the compound state space (used in distance computation) | |
void | setSubspaceWeight (const unsigned int index, double weight) |
Set the weight of a subspace in the compound state space (used in distance computation) | |
void | setSubspaceWeight (const std::string &name, double weight) |
Set the weight of a subspace in the compound state space (used in distance computation) | |
const std::vector < StateSpacePtr > & | getSubspaces () const |
Get the list of components. | |
const std::vector< double > & | getSubspaceWeights () const |
Get the list of component weights. | |
bool | isLocked () const |
Return true if the state space is locked. A value of true means that no further spaces can be added as components. | |
void | lock () |
Lock this state space. This means no further spaces can be added as components. This function can be for instance called from the constructor of a state space that inherits from CompoundStateSpace to prevent the user to add further components. | |
Operations with substates | |
virtual StateSamplerPtr | allocSubspaceStateSampler (const StateSpace *subspace) const |
Allocate a sampler that actually samples only components that are part of subspace. | |
Functionality specific to the state space | |
virtual unsigned int | getDimension () const |
Get the dimension of the space (not the dimension of the surrounding ambient space) | |
virtual double | getMaximumExtent () const |
Get the maximum value a call to distance() can return (or an upper bound). For unbounded state spaces, this function can return infinity. | |
virtual double | getMeasure () const |
Get a measure of the space (this can be thought of as a generalization of volume) | |
virtual void | enforceBounds (State *state) const |
Bring the state within the bounds of the state space. For unbounded spaces this function can be a no-op. | |
virtual bool | satisfiesBounds (const State *state) const |
Check if a state is inside the bounding box. For unbounded spaces this function can always return true. | |
virtual void | copyState (State *destination, const State *source) const |
Copy a state to another. The memory of source and destination should NOT overlap. | |
virtual unsigned int | getSerializationLength () const |
Get the number of chars in the serialization of a state in this space. | |
virtual void | serialize (void *serialization, const State *state) const |
Write the binary representation of state to serialization. | |
virtual void | deserialize (State *state, const void *serialization) const |
Read the binary representation of a state from serialization and write it to state. | |
virtual double | distance (const State *state1, const State *state2) const |
Computes distance between two states. This function satisfies the properties of a metric if isMetricSpace() is true, and its return value will always be between 0 and getMaximumExtent() | |
virtual void | setLongestValidSegmentFraction (double segmentFraction) |
When performing discrete validation of motions, the length of the longest segment that does not require state validation needs to be specified. This function sets this length as a fraction of the space's maximum extent. The call is passed to all contained subspaces. | |
virtual unsigned int | validSegmentCount (const State *state1, const State *state2) const |
Count how many segments of the "longest valid length" fit on the motion from state1 to state2. This is the max() of the counts returned by contained subspaces. | |
virtual bool | equalStates (const State *state1, const State *state2) const |
Checks whether two states are equal. | |
virtual void | interpolate (const State *from, const State *to, const double t, State *state) const |
Computes the state that lies at time t in [0, 1] on the segment that connects from state to to state. The memory location of state is not required to be different from the memory of either from or to. | |
virtual StateSamplerPtr | allocDefaultStateSampler () const |
Allocate an instance of the default uniform state sampler for this space. | |
virtual State * | allocState () const |
Allocate a state that can store a point in the described space. | |
virtual void | freeState (State *state) const |
Free the memory of the allocated state. | |
virtual double * | getValueAddressAtIndex (State *state, const unsigned int index) const |
Many states contain a number of double values. This function provides a means to get the memory address of a double value from state state located at position index. The first double value is returned for index = 0. If index is too large (does not point to any double values in the state), the return value is NULL. | |
Protected Member Functions | |
void | allocStateComponents (CompoundState *state) const |
Allocate the state components. Called by allocState(). Usually called by derived state spaces. | |
Protected Attributes | |
std::vector< StateSpacePtr > | components_ |
The state spaces that make up the compound state space. | |
unsigned int | componentCount_ |
The number of components. | |
std::vector< double > | weights_ |
The weight assigned to each component of the state space when computing the compound distance. | |
double | weightSum_ |
The sum of all the weights in weights_. | |
bool | locked_ |
Flag indicating whether adding further components is allowed or not. |
Detailed Description
A space to allow the composition of state spaces.
Definition at line 544 of file StateSpace.h.
Member Function Documentation
T* base::CompoundStateSpace::as | ( | const unsigned int | index | ) | const [inline] |
Cast a component of this instance to a desired type.
Make sure the type we are casting to is indeed a state space
Definition at line 563 of file StateSpace.h.
T* base::CompoundStateSpace::as | ( | const std::string & | name | ) | const [inline] |
Cast a component of this instance to a desired type.
Make sure the type we are casting to is indeed a state space
Definition at line 573 of file StateSpace.h.
void base::CompoundStateSpace::copyState | ( | State * | destination, |
const State * | source | ||
) | const [virtual] |
Copy a state to another. The memory of source and destination should NOT overlap.
- Note:
- For more advanced state copying methods (partial copy, for example), see Advanced methods for copying states.
Implements base::StateSpace.
Reimplemented in ompl::control::OpenDEStateSpace.
Definition at line 1014 of file StateSpace.cpp.
double base::CompoundStateSpace::getMaximumExtent | ( | ) | const [virtual] |
Get the maximum value a call to distance() can return (or an upper bound). For unbounded state spaces, this function can return infinity.
- Note:
- Tight upper bounds are preferred because the value of the extent is used in the automatic computation of parameters for planning. If the bounds are less tight, the automatically computed parameters will be less useful.
Implements base::StateSpace.
Definition at line 980 of file StateSpace.cpp.
double * base::CompoundStateSpace::getValueAddressAtIndex | ( | State * | state, |
const unsigned int | index | ||
) | const [virtual] |
Many states contain a number of double values. This function provides a means to get the memory address of a double value from state state located at position index. The first double value is returned for index = 0. If index is too large (does not point to any double values in the state), the return value is NULL.
- Note:
- This function does not map a state to an array of doubles. There may be components of a state that do not correspond to double values and they are 'invisible' to this function. Furthermore, this function is slow and is not intended for use in the implementation of planners. Ideally, state values should not be accessed by index. If accessing of individual state elements is however needed, getValueAddressAtLocation() provides a faster implementation.
Reimplemented from base::StateSpace.
Definition at line 1156 of file StateSpace.cpp.
The documentation for this class was generated from the following files:
- ompl/base/StateSpace.h
- ompl/base/src/StateSpace.cpp