Class CompoundStateSpace

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class CompoundStateSpace : public ompl::base::StateSpace

A space to allow the composition of state spaces.

Subclassed by ompl::base::HybridStateSpace, ompl::base::KleinBottleStateSpace, ompl::base::MobiusStateSpace, ompl::base::OwenStateSpace, ompl::base::SE2StateSpace, ompl::base::SE3StateSpace, ompl::base::SpaceTimeStateSpace, ompl::base::SphereStateSpace, ompl::base::TorusStateSpace, ompl::base::VanaOwenStateSpace, ompl::base::VanaStateSpace

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(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(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(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 override

Allocate a sampler that actually samples only components that are part of subspace.

Functionality specific to the state space

virtual unsigned int getDimension() const override

Get the dimension of the space (not the dimension of the surrounding ambient space)

virtual double getMaximumExtent() const override

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.

virtual double getMeasure() const override

Get a measure of the space (this can be thought of as a generalization of volume)

virtual void enforceBounds(State *state) const override

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 override

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 override

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.

virtual unsigned int getSerializationLength() const override

Get the number of chars in the serialization of a state in this space.

virtual void serialize(void *serialization, const State *state) const override

Write the binary representation of state to serialization.

virtual void deserialize(State *state, const void *serialization) const override

Read the binary representation of a state from serialization and write it to state.

virtual double distance(const State *state1, const State *state2) const override

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) override

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 override

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 override

Checks whether two states are equal.

virtual void interpolate(const State *from, const State *to, double t, State *state) const override

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 override

Allocate an instance of the default uniform state sampler for this space.

virtual State *allocState() const override

Allocate a state that can store a point in the described space.

virtual void freeState(State *state) const override

Free the memory of the allocated state.

virtual double *getValueAddressAtIndex(State *state, unsigned int index) const override

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 nullptr.

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.

Public Types

using StateType = ompl::base::CompoundState

Define the type of state allocated by this state space.

Public 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)

~CompoundStateSpace() override = default
template<class T>
inline T *as(const unsigned int index) const

Cast a component of this instance to a desired type.

template<class T>
inline T *as(const std::string &name) const

Cast a component of this instance to a desired type.

virtual bool isCompound() const override

Check if the state space is compound.

virtual bool isHybrid() const override

Check if this is a hybrid state space (i.e., both discrete and continuous components exist)

virtual bool isMetricSpace() const override

Return true if the distance function associated with the space is a metric.

virtual void printState(const State *state, std::ostream &out) const override

Print a state to a stream.

virtual void printSettings(std::ostream &out) const override

Print the settings for this state space to a stream.

virtual void computeLocations() override

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() override

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.

Protected 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_ = {0u}

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_ = {0.0}

The sum of all the weights in weights_.

bool locked_ = {false}

Flag indicating whether adding further components is allowed or not.