Loading...
Searching...
No Matches
TypedSpaceInformation.h
1/*********************************************************************
2* Software License Agreement (BSD License)
3*
4* Copyright (c) 2015, 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: Neil T. Dantam */
36
37#ifndef OMPL_BASE_TYPED_SPACE_INFORMATION_
38#define OMPL_BASE_TYPED_SPACE_INFORMATION_
39
40#include "ompl/base/SpaceInformation.h"
41#include "ompl/base/ScopedState.h"
42
43namespace ompl
44{
45 namespace base
46 {
47 template <typename SpaceType_>
48 class TypedSpaceInformation : public SpaceInformation
49 {
50 public:
51 /*--- Type Definitions ---*/
52
54 using SpaceType = SpaceType_;
55
57 using StateType = typename SpaceType::StateType;
58
61
63 using SpacePtr = std::shared_ptr<SpaceType>;
64
66 using Ptr = std::shared_ptr<TypedSpaceInformation<SpaceType>>;
67
68 /*--- Constructor ---*/
69
71 TypedSpaceInformation(const SpacePtr &space) : SpaceInformation(space)
72 {
73 }
74
75 /*--- Space Accessors ---*/
76
79 {
80 return getStateSpace()->template as<SpaceType>();
81 }
82
85 {
86 return getStateSpace()->template as<SpaceType>();
87 }
88
89 /*--- State Memory Management ---*/
90
93 {
94 return this->allocState()->template as<StateType>();
95 }
96
98 void allocTypedStates(std::vector<StateType *> &states) const
99 {
100 allocStates(states);
101 }
102
104 void freeTypedState(StateType *state) const
105 {
106 freeState(state);
107 }
108
110 void freeTypedStates(std::vector<StateType *> &states) const
111 {
112 freeStates(states);
113 }
114
116 void copyTypedState(StateType *destination, const StateType *source) const
117 {
118 copyState(destination, source);
119 }
120
122 StateType *cloneTypedState(const StateType *source) const
123 {
124 return this->cloneState(source)->template as<StateType>();
125 }
126
127 static StateType *state_as(ompl::base::State *s)
128 {
129 return s->template as<StateType>();
130 }
131
132 static const StateType *state_as(const ompl::base::State *s)
133 {
134 return s->template as<StateType>();
135 }
136 };
137 }
138}
139
140#endif
Definition of a scoped state.
Definition ScopedState.h:57
void freeState(State *state) const
Free the memory of a state.
void freeStates(std::vector< State * > &states) const
Free the memory of an array of states.
void allocStates(std::vector< State * > &states) const
Allocate memory for each element of the array states.
void copyState(State *destination, const State *source) const
Copy a state to another.
State * cloneState(const State *source) const
Clone a state.
const StateSpacePtr & getStateSpace() const
Return the instance of the used state space.
State * allocState() const
Allocate memory for a state.
Definition of an abstract state.
Definition State.h:50
typename SpaceType::StateType StateType
void freeTypedState(StateType *state) const
std::shared_ptr< SpaceType > SpacePtr
std::shared_ptr< TypedSpaceInformation< SpaceType > > Ptr
StateType * cloneTypedState(const StateType *source) const
void allocTypedStates(std::vector< StateType * > &states) const
TypedSpaceInformation(const SpacePtr &space)
void copyTypedState(StateType *destination, const StateType *source) const
ScopedState< SpaceType > ScopedStateType
const SpaceType * getTypedStateSpace() const
void freeTypedStates(std::vector< StateType * > &states) const
This namespace contains sampling based planning routines shared by both planning under geometric cons...
Main namespace. Contains everything in this library.