All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
OpenDEStateSpace.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2010, 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: Ioan Sucan */
36 
37 #ifndef OMPL_EXTENSION_OPENDE_STATE_SPACE_
38 #define OMPL_EXTENSION_OPENDE_STATE_SPACE_
39 
40 #include "ompl/base/StateSpace.h"
41 #include "ompl/base/spaces/RealVectorStateSpace.h"
42 #include "ompl/base/spaces/SO3StateSpace.h"
43 #include "ompl/extensions/opende/OpenDEEnvironment.h"
44 
45 namespace ompl
46 {
47  namespace control
48  {
49 
52  {
53  public:
54 
55  enum
56  {
65  };
66 
69  {
70  public:
72  {
73  }
74 
76  const double* getBodyPosition(unsigned int body) const
77  {
78  return as<base::RealVectorStateSpace::StateType>(body * 4)->values;
79  }
80 
82  double* getBodyPosition(unsigned int body)
83  {
84  return as<base::RealVectorStateSpace::StateType>(body * 4)->values;
85  }
86 
88  const base::SO3StateSpace::StateType& getBodyRotation(unsigned int body) const
89  {
90  return *as<base::SO3StateSpace::StateType>(body * 4 + 3);
91  }
92 
95  {
96  return *as<base::SO3StateSpace::StateType>(body * 4 + 3);
97  }
98 
100  const double* getBodyLinearVelocity(unsigned int body) const
101  {
102  return as<base::RealVectorStateSpace::StateType>(body * 4 + 1)->values;
103  }
104 
106  double* getBodyLinearVelocity(unsigned int body)
107  {
108  return as<base::RealVectorStateSpace::StateType>(body * 4 + 1)->values;
109  }
110 
112  const double* getBodyAngularVelocity(unsigned int body) const
113  {
114  return as<base::RealVectorStateSpace::StateType>(body * 4 + 2)->values;
115  }
116 
118  double* getBodyAngularVelocity(unsigned int body)
119  {
120  return as<base::RealVectorStateSpace::StateType>(body * 4 + 2)->values;
121  }
122 
129  mutable int collision;
130 
131  };
132 
149  double positionWeight = 1.0, double linVelWeight = 0.5,
150  double angVelWeight = 0.5, double orientationWeight = 1.0);
151 
152  virtual ~OpenDEStateSpace(void)
153  {
154  }
155 
158  {
159  return env_;
160  }
161 
163  unsigned int getNrBodies(void) const
164  {
165  return env_->stateBodies_.size();
166  }
167 
173  void setDefaultBounds(void);
174 
176  void setVolumeBounds(const base::RealVectorBounds &bounds);
177 
180 
183 
186  virtual void readState(base::State *state) const;
187 
192  virtual void writeState(const base::State *state) const;
193 
201  bool satisfiesBoundsExceptRotation(const StateType *state) const;
202 
203  virtual base::State* allocState(void) const;
204  virtual void freeState(base::State *state) const;
205  virtual void copyState(base::State *destination, const base::State *source) const;
206  virtual void interpolate(const base::State *from, const base::State *to, const double t, base::State *state) const;
207 
209  virtual base::StateSamplerPtr allocStateSampler(void) const;
210 
213  virtual bool evaluateCollision(const base::State *source) const;
214 
215  protected:
216 
219  };
220  }
221 }
222 
223 
224 #endif