nd.h
1 
2 /*************************************************************************************/
3 /* */
4 /* File: nd.h */
5 /* Author: Javier Minguez */
6 /* Modified: 20/10/2005 */
7 /* */
8 /* This library implements a mixture between: */
9 /* */
10 /* J. Minguez, L. Montano. */
11 /* Nearness Diagram Navigation (ND): Collision Avoidance in Troublesome Scenarios. */
12 /* IEEE Transactions on Robotics and Automation, pp 154, 2004. */
13 /* */
14 /* */
15 /* J. Minguez, J. Osuna, L. Montano. */
16 /* A Divide and Conquer Strategy based on Situations */
17 /* to Achieve Reactive Collision Avoidance in Troublesome Scenarios. */
18 /* IEEE International Conference on Robotics and Automation (ICRA 2004), */
19 /* 2004. New Orleans, USA. */
20 /* */
21 /*************************************************************************************/
22 /*
23  * This program is free software; you can redistribute it and/or modify
24  * it under the terms of the GNU General Public License as published by
25  * the Free Software Foundation; either version 2 of the License, or
26  * (at your option) any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU General Public License
34  * along with this program; if not, write to the Free Software
35  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36  *
37  */
38 
39 /*****************************************************************************/
40 //
41 // EVERYTHING IN THE INTERNATIONAL SYSTEM (METERS AND RADIANS)
42 //
43 /*****************************************************************************/
44 
45 
46 #ifndef nd_h
47 #define nd_h
48 
49 // ----------------------------------------------------------------------------
50 // GENERIC TYPES
51 // ----------------------------------------------------------------------------
52 
53 // Cartesian coordinates.
54 
55 typedef struct {
56  float x;
57  float y;
58 } TCoordenadas;
59 
60 // System of reference
61 
62 typedef struct {
63  TCoordenadas posicion;
64  float orientacion;
65 } TSR;
66 
67 
68 
69 // ----------------------------------------------------------------------------
70 // SPECIFIC TYPES.
71 // ----------------------------------------------------------------------------
72 
73 
74 
75 // ************************
76 
77 // TParametrosND (information of the robot and laser for the ND)
78 
79 typedef struct {
80 
81  // GEOMETRY
82  // The vehicle is considered to be symetric at both sides of the X axis.
83  // The flag is 1 if the robot is resctangular, 0 if it is circular
84  short int geometryRect;
85 
86  // --- RECTANGULAR ---
87  // distance (m) from the wheels to the:
88  // front: frontal part
89  // back: back part
90  // left: left side. Notice that the vehicle is symetric
91  float front,back,left;
92 
93  // --- CIRCULAR ---
94  // radius of the robot is is circular
95  float R;
96 
97  // MOTION
98  // The falg is 1 if the robot is holonomous, or 0 is diff-drive or syncro
99  short int holonomic;
100 
101  // Maximum linear and angular velocities
102  float vlmax,vamax;
103 
104  // Maximum linear and angular acelerations
105  float almax,aamax;
106 
107  // OTHER STUFF
108 
109  // -- SECURITY DISTANCE ---
110  // Distance to consider an obstacle dangerous (i.e. to start the avoidance maneouvre)
111  // dsmax: Distance from the frontal robot bounds.
112  // dsmin: Distance from the back robot bounds.
113  // engorde: Inner value. The suggestion is 20% of the dsmin (i.e. 0.2*dsmin)
114  float dsmax,dsmin,enlarge;
115 
116  // -- DISCONTINUITY --
117  // Minimum space where the robot fits. I suggest same value than "izquierda" value.
118  float discontinuity;
119 
120  // -- SAMPLING PERIOD --
121  float T;
122 
123  // LASER
124  // Distance from the wheels axis to the laser, X axis.
125  //float laser;
126 
127 } TParametersND;
128 
129 // **************************************
130 
131 
132 
133 
134 
135 
136 // ************************
137 
138 // TVelocities (information of linear v, and angular velocities w)
139 
140 typedef struct {
141  float v; // linear velocity
142  float w; // angular velocity
143  float v_theta; // velocity angle (just if holonomous vehicle)
144 } TVelocities;
145 
146 // **************************************
147 
148 
149 
150 
151 
152 // ************************
153 
154 // TInfoMovimiento (information of the robot)
155 
156 typedef struct {
157  TSR SR1; // Current vehicle location in GLOBAL coordinates
158  TVelocities velocidades; // Current vehicle velocities
160 
161 // **************************************
162 
163 
164 
165 
166 // ************************
167 
168 // TInfoEntorno (list of obstacle points)
169 
170 // Maximum number of points of the environment
171 // This number depends on the maximum number of obstacle points that
172 // you want to give to the ND
173 
174 //#define MAX_POINTS_SCENARIO 1440
175 #define MAX_POINTS_SCENARIO 10000
176 
177 typedef struct {
178  int longitud;
179  TCoordenadas punto[MAX_POINTS_SCENARIO];
180 } TInfoEntorno;
181 
182 // **************************************
183 
184 
185 
186 
187 
188 // ----------------------------------------------------------------------------
189 // FUNCTIONS
190 // ----------------------------------------------------------------------------
191 
192 
193 
194 
195 // **********************************
196 // This function initialites the ND
197 // Input--
198 // parametros:: information of the robot and laser used by the ND
199 // Ouput--
200 
201 void InicializarND(TParametersND *parametros);
202 
203 // **********************************
204 
205 
206 
207 
208 
209 
210 // **********************************
211 // This runs the ND. The input is the current obstacle list and the goal location
212 // and the output the motion command.
213 // Input--
214 // objetivo:: current objective in GLOBAL coordinates. Notice that this
215 // location can change each time you call ND.
216 // movimiento:: this is the current velocity of the robot.
217 // mapa:: this is a list of the obstacle points in global coordinates.
218 // You can use the current sensor reading or implement a kind of memory
219 // to remember last scans. Whatever, ND wants a list of points in GLOBAL coordinates.
220 // information:: variable for debug.
221 //
222 // Ouput--
223 // movimiento:: this is the output of the ND.
224 // * Linear and angular velocities (and direction if holonomic).
225 // * NULL an emergency stop is required
226 // * pointer to (0,0) goal reached.
227 
228 extern TVelocities *IterarND(TCoordenadas objetivo,
229  float goal_tol,
230  TInfoMovimiento *movimiento,
231  TInfoEntorno *mapa,
232  void *informacion);
233  // if you do not want to see the internal information in nh2.h informacion = NULL
234 
235 // **********************************
236 
237 
238 #endif
239 
Definition: nd2.h:60
Definition: geometria.h:75
Definition: nd.h:55
Definition: nd.h:177
Definition: nd.h:79
Definition: nd2.h:104
Definition: nd.h:140
Definition: nd.h:62
Definition: nd.h:156
Definition: nd2.h:125