00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef OMPL_EXTENSION_ODE_STATE_SPACE_
00038 #define OMPL_EXTENSION_ODE_STATE_SPACE_
00039
00040 #include "ompl/base/StateSpace.h"
00041 #include "ompl/base/spaces/RealVectorStateSpace.h"
00042 #include "ompl/base/spaces/SO3StateSpace.h"
00043 #include "ompl/extensions/ode/ODEEnvironment.h"
00044
00045 namespace ompl
00046 {
00047 namespace control
00048 {
00049
00051 class ODEStateSpace : public base::CompoundStateSpace
00052 {
00053 public:
00054
00055 enum
00056 {
00058 STATE_COLLISION_KNOWN_BIT = 0,
00060 STATE_COLLISION_VALUE_BIT = 1,
00062 STATE_VALIDITY_KNOWN_BIT = 2,
00064 STATE_VALIDITY_VALUE_BIT = 3,
00065 };
00066
00068 class StateType : public base::CompoundStateSpace::StateType
00069 {
00070 public:
00071 StateType(void) : base::CompoundStateSpace::StateType(), collision(0)
00072 {
00073 }
00074
00076 const double* getBodyPosition(unsigned int body) const
00077 {
00078 return as<base::RealVectorStateSpace::StateType>(body * 4)->values;
00079 }
00080
00082 double* getBodyPosition(unsigned int body)
00083 {
00084 return as<base::RealVectorStateSpace::StateType>(body * 4)->values;
00085 }
00086
00088 const base::SO3StateSpace::StateType& getBodyRotation(unsigned int body) const
00089 {
00090 return *as<base::SO3StateSpace::StateType>(body * 4 + 3);
00091 }
00092
00094 base::SO3StateSpace::StateType& getBodyRotation(unsigned int body)
00095 {
00096 return *as<base::SO3StateSpace::StateType>(body * 4 + 3);
00097 }
00098
00100 const double* getBodyLinearVelocity(unsigned int body) const
00101 {
00102 return as<base::RealVectorStateSpace::StateType>(body * 4 + 1)->values;
00103 }
00104
00106 double* getBodyLinearVelocity(unsigned int body)
00107 {
00108 return as<base::RealVectorStateSpace::StateType>(body * 4 + 1)->values;
00109 }
00110
00112 const double* getBodyAngularVelocity(unsigned int body) const
00113 {
00114 return as<base::RealVectorStateSpace::StateType>(body * 4 + 2)->values;
00115 }
00116
00118 double* getBodyAngularVelocity(unsigned int body)
00119 {
00120 return as<base::RealVectorStateSpace::StateType>(body * 4 + 2)->values;
00121 }
00122
00129 mutable int collision;
00130
00131 };
00132
00148 ODEStateSpace(const ODEEnvironmentPtr &env,
00149 double positionWeight = 1.0, double linVelWeight = 0.5,
00150 double angVelWeight = 0.5, double orientationWeight = 1.0);
00151
00152 virtual ~ODEStateSpace(void)
00153 {
00154 }
00155
00157 const ODEEnvironmentPtr& getEnvironment(void) const
00158 {
00159 return env_;
00160 }
00161
00163 unsigned int getNrBodies(void) const
00164 {
00165 return env_->stateBodies_.size();
00166 }
00167
00173 void setDefaultBounds(void);
00174
00176 void setVolumeBounds(const base::RealVectorBounds &bounds);
00177
00179 void setLinearVelocityBounds(const base::RealVectorBounds &bounds);
00180
00182 void setAngularVelocityBounds(const base::RealVectorBounds &bounds);
00183
00186 virtual void readState(base::State *state) const;
00187
00192 virtual void writeState(const base::State *state) const;
00193
00201 bool satisfiesBoundsExceptRotation(const StateType *state) const;
00202
00203 virtual base::State* allocState(void) const;
00204 virtual void freeState(base::State *state) const;
00205 virtual void copyState(base::State *destination, const base::State *source) const;
00206
00209 virtual bool evaluateCollision(const base::State *source) const;
00210
00211 protected:
00212
00214 ODEEnvironmentPtr env_;
00215 };
00216 }
00217 }
00218
00219
00220 #endif