This program is for an autonomous robot for the competition at the Hochschule Luzern. http://cruisingcrepe.wordpress.com/ We are one of the 32 teams. http://cruisingcrepe.wordpress.com/ The postition control is based on this Documentation: Control of Wheeled Mobile Robots: An Experimental Overview from Alessandro De Luca, Giuseppe Oriolo, Marilena Vendittelli. For more information see here: http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf
Fork of autonomous Robot Android by
defines.h@25:e16f96fd7d21, 2013-05-19 (annotated)
- Committer:
- chrigelburri
- Date:
- Sun May 19 15:12:04 2013 +0000
- Revision:
- 25:e16f96fd7d21
- Parent:
- 22:bfec16575c91
- Child:
- 26:a201dcd4e618
ja soo epp? ????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chrigelburri | 0:31f7be68e52d | 1 | #ifndef _DEFINES_H_ |
chrigelburri | 0:31f7be68e52d | 2 | #define _DEFINES_H_ |
chrigelburri | 0:31f7be68e52d | 3 | |
chrigelburri | 10:09ddb819fdcb | 4 | /*! \file defines.h |
chrigelburri | 10:09ddb819fdcb | 5 | \brief All defines for the roboter you can see here. |
chrigelburri | 10:09ddb819fdcb | 6 | */ |
chrigelburri | 0:31f7be68e52d | 7 | #include "mbed.h" |
chrigelburri | 0:31f7be68e52d | 8 | |
chrigelburri | 10:09ddb819fdcb | 9 | /** |
chrigelburri | 11:775ebb69d5e1 | 10 | * @name Physical dimensions π; |
chrigelburri | 15:cb1337567ad4 | 11 | * @{ |
chrigelburri | 10:09ddb819fdcb | 12 | */ |
chrigelburri | 10:09ddb819fdcb | 13 | #define PI 3.141592654f |
chrigelburri | 11:775ebb69d5e1 | 14 | /*! @} */ |
chrigelburri | 10:09ddb819fdcb | 15 | |
chrigelburri | 10:09ddb819fdcb | 16 | /** |
chrigelburri | 10:09ddb819fdcb | 17 | * @name maxon motor #339282 EC 45 flat 30W |
chrigelburri | 10:09ddb819fdcb | 18 | * @{ |
chrigelburri | 10:09ddb819fdcb | 19 | */ |
chrigelburri | 10:09ddb819fdcb | 20 | |
chrigelburri | 10:09ddb819fdcb | 21 | /** |
chrigelburri | 11:775ebb69d5e1 | 22 | * @brief Number of of pole pairs |
chrigelburri | 10:09ddb819fdcb | 23 | */ |
chrigelburri | 10:09ddb819fdcb | 24 | #define POLE_PAIRS 8u |
chrigelburri | 0:31f7be68e52d | 25 | |
chrigelburri | 10:09ddb819fdcb | 26 | /** |
chrigelburri | 11:775ebb69d5e1 | 27 | * @brief Gear on the motor 1/11.6f |
chrigelburri | 10:09ddb819fdcb | 28 | */ |
chrigelburri | 10:09ddb819fdcb | 29 | #define GEAR 1/11.6f |
chrigelburri | 10:09ddb819fdcb | 30 | |
chrigelburri | 10:09ddb819fdcb | 31 | /** |
chrigelburri | 11:775ebb69d5e1 | 32 | * @brief Pulses per electrical step form the Hallsensor, have 6 steps |
chrigelburri | 10:09ddb819fdcb | 33 | */ |
chrigelburri | 10:09ddb819fdcb | 34 | #define PULSES_PER_STEP 6u |
chrigelburri | 10:09ddb819fdcb | 35 | /*! @} */ |
chrigelburri | 10:09ddb819fdcb | 36 | |
chrigelburri | 10:09ddb819fdcb | 37 | /** |
chrigelburri | 10:09ddb819fdcb | 38 | * @name Physical Dimension of the car |
chrigelburri | 10:09ddb819fdcb | 39 | * @{ |
chrigelburri | 10:09ddb819fdcb | 40 | */ |
chrigelburri | 10:09ddb819fdcb | 41 | |
chrigelburri | 10:09ddb819fdcb | 42 | /** |
chrigelburri | 11:775ebb69d5e1 | 43 | * @brief Value for the diffrerenz between left an right, given in [m] |
chrigelburri | 10:09ddb819fdcb | 44 | */ |
chrigelburri | 22:bfec16575c91 | 45 | #define WHEEL_RADIUS_DIFF 0.0001f |
chrigelburri | 0:31f7be68e52d | 46 | |
chrigelburri | 10:09ddb819fdcb | 47 | /** |
chrigelburri | 22:bfec16575c91 | 48 | * @brief Radius of the left wheel, given in [m] kleiner --> weiter |
chrigelburri | 10:09ddb819fdcb | 49 | */ |
chrigelburri | 25:e16f96fd7d21 | 50 | #define WHEEL_RADIUS_LEFT 0.040190f |
chrigelburri | 10:09ddb819fdcb | 51 | |
chrigelburri | 10:09ddb819fdcb | 52 | /** |
chrigelburri | 11:775ebb69d5e1 | 53 | * @brief Radius of the left wheel, given in [m] |
chrigelburri | 10:09ddb819fdcb | 54 | */ |
chrigelburri | 10:09ddb819fdcb | 55 | #define WHEEL_RADIUS_RIGHT (WHEEL_RADIUS_LEFT - WHEEL_RADIUS_DIFF) |
chrigelburri | 10:09ddb819fdcb | 56 | |
chrigelburri | 10:09ddb819fdcb | 57 | /** |
chrigelburri | 11:775ebb69d5e1 | 58 | * @brief Distance of the wheel, given in [m] Greater --> turn more |
chrigelburri | 10:09ddb819fdcb | 59 | */ |
chrigelburri | 25:e16f96fd7d21 | 60 | #define WHEEL_DISTANCE 0.1735f // 0.17500f |
chrigelburri | 11:775ebb69d5e1 | 61 | |
chrigelburri | 11:775ebb69d5e1 | 62 | /** |
chrigelburri | 11:775ebb69d5e1 | 63 | * @brief Sets the start X-point, given in [m] |
chrigelburri | 11:775ebb69d5e1 | 64 | */ |
chrigelburri | 11:775ebb69d5e1 | 65 | #define START_X_OFFSET -0.8f |
chrigelburri | 11:775ebb69d5e1 | 66 | |
chrigelburri | 11:775ebb69d5e1 | 67 | /** |
chrigelburri | 11:775ebb69d5e1 | 68 | * @brief Sets the start Y-point, given in [m] |
chrigelburri | 11:775ebb69d5e1 | 69 | */ |
chrigelburri | 11:775ebb69d5e1 | 70 | #define START_Y_OFFSET 0.8f |
chrigelburri | 10:09ddb819fdcb | 71 | /*! @} */ |
chrigelburri | 10:09ddb819fdcb | 72 | |
chrigelburri | 10:09ddb819fdcb | 73 | /** |
chrigelburri | 10:09ddb819fdcb | 74 | * @name State Bits of the car |
chrigelburri | 10:09ddb819fdcb | 75 | * @{ |
chrigelburri | 10:09ddb819fdcb | 76 | */ |
chrigelburri | 0:31f7be68e52d | 77 | |
chrigelburri | 10:09ddb819fdcb | 78 | /** |
chrigelburri | 11:775ebb69d5e1 | 79 | * @brief Bit0 = stop pressed |
chrigelburri | 10:09ddb819fdcb | 80 | */ |
chrigelburri | 10:09ddb819fdcb | 81 | #define STATE_STOP 1u |
chrigelburri | 10:09ddb819fdcb | 82 | |
chrigelburri | 10:09ddb819fdcb | 83 | /** |
chrigelburri | 11:775ebb69d5e1 | 84 | * @brief Bit1 = Undervoltage battery |
chrigelburri | 11:775ebb69d5e1 | 85 | */ |
chrigelburri | 11:775ebb69d5e1 | 86 | #define STATE_UNDER 2u |
chrigelburri | 10:09ddb819fdcb | 87 | |
chrigelburri | 10:09ddb819fdcb | 88 | /** |
chrigelburri | 11:775ebb69d5e1 | 89 | * @brief Bit2 = left ESCON in error state |
chrigelburri | 11:775ebb69d5e1 | 90 | */ |
chrigelburri | 10:09ddb819fdcb | 91 | #define STATE_LEFT 4u |
chrigelburri | 10:09ddb819fdcb | 92 | |
chrigelburri | 10:09ddb819fdcb | 93 | /** |
chrigelburri | 11:775ebb69d5e1 | 94 | * @brief Bit3 = right ESCON in error state |
chrigelburri | 10:09ddb819fdcb | 95 | */ |
chrigelburri | 10:09ddb819fdcb | 96 | #define STATE_RIGHT 8u |
chrigelburri | 11:775ebb69d5e1 | 97 | /*! @} */ |
chrigelburri | 11:775ebb69d5e1 | 98 | |
chrigelburri | 11:775ebb69d5e1 | 99 | /** |
chrigelburri | 11:775ebb69d5e1 | 100 | * @name ESCON Constands |
chrigelburri | 15:cb1337567ad4 | 101 | * |
chrigelburri | 11:775ebb69d5e1 | 102 | * @{ |
chrigelburri | 11:775ebb69d5e1 | 103 | */ |
chrigelburri | 0:31f7be68e52d | 104 | |
chrigelburri | 11:775ebb69d5e1 | 105 | /** |
chrigelburri | 11:775ebb69d5e1 | 106 | * @brief Speed Factor how set in the ESCON Studio |
chrigelburri | 11:775ebb69d5e1 | 107 | */ |
chrigelburri | 21:48248c5b8992 | 108 | #define ESCON_SET_FACTOR 2400.0f |
chrigelburri | 11:775ebb69d5e1 | 109 | |
chrigelburri | 11:775ebb69d5e1 | 110 | /** |
chrigelburri | 11:775ebb69d5e1 | 111 | * @brief Speed Factor how get in the ESCON Studio |
chrigelburri | 11:775ebb69d5e1 | 112 | */ |
chrigelburri | 22:bfec16575c91 | 113 | #define ESCON_GET_FACTOR 2500.0f |
chrigelburri | 8:696c2f9dfc62 | 114 | |
chrigelburri | 11:775ebb69d5e1 | 115 | /** |
chrigelburri | 11:775ebb69d5e1 | 116 | * @brief Error patch of the drift of Analog input and pwn output for set speed |
chrigelburri | 11:775ebb69d5e1 | 117 | */ |
chrigelburri | 11:775ebb69d5e1 | 118 | #define SET_SPEED_PATCH (1+0.00262f) |
chrigelburri | 0:31f7be68e52d | 119 | |
chrigelburri | 11:775ebb69d5e1 | 120 | /** |
chrigelburri | 11:775ebb69d5e1 | 121 | * @brief Error patch of the drift of Analog input and pwn output for get speed |
chrigelburri | 11:775ebb69d5e1 | 122 | */ |
chrigelburri | 11:775ebb69d5e1 | 123 | #define GET_SPEED_PATCH (1+0.0019f) |
chrigelburri | 11:775ebb69d5e1 | 124 | /*! @} */ |
chrigelburri | 0:31f7be68e52d | 125 | |
chrigelburri | 11:775ebb69d5e1 | 126 | /** |
chrigelburri | 11:775ebb69d5e1 | 127 | * @name position controller |
chrigelburri | 11:775ebb69d5e1 | 128 | * @{ |
chrigelburri | 11:775ebb69d5e1 | 129 | */ |
chrigelburri | 11:775ebb69d5e1 | 130 | |
chrigelburri | 11:775ebb69d5e1 | 131 | /** |
chrigelburri | 11:775ebb69d5e1 | 132 | * @brief Main Gain for k1, k2 and k3 |
chrigelburri | 11:775ebb69d5e1 | 133 | */ |
chrigelburri | 25:e16f96fd7d21 | 134 | #define GAIN 0.65f |
chrigelburri | 1:6cd533a712c6 | 135 | |
chrigelburri | 11:775ebb69d5e1 | 136 | /** |
chrigelburri | 11:775ebb69d5e1 | 137 | * @brief Gain k1 default 1.0f |
chrigelburri | 11:775ebb69d5e1 | 138 | */ |
chrigelburri | 25:e16f96fd7d21 | 139 | #define K1 1.45f * GAIN |
chrigelburri | 11:775ebb69d5e1 | 140 | |
chrigelburri | 11:775ebb69d5e1 | 141 | /** |
chrigelburri | 11:775ebb69d5e1 | 142 | * @brief Gain k2 default 3.0f |
chrigelburri | 11:775ebb69d5e1 | 143 | */ |
chrigelburri | 11:775ebb69d5e1 | 144 | #define K2 3.0f * GAIN |
chrigelburri | 11:775ebb69d5e1 | 145 | |
chrigelburri | 11:775ebb69d5e1 | 146 | /** |
chrigelburri | 11:775ebb69d5e1 | 147 | * @brief Gain k3 default 2.0f |
chrigelburri | 11:775ebb69d5e1 | 148 | */ |
chrigelburri | 11:775ebb69d5e1 | 149 | #define K3 2.0f * GAIN |
chrigelburri | 0:31f7be68e52d | 150 | |
chrigelburri | 11:775ebb69d5e1 | 151 | /** |
chrigelburri | 11:775ebb69d5e1 | 152 | * @brief Min. Distance to switch the position controller off. |
chrigelburri | 11:775ebb69d5e1 | 153 | * Because when Distance Error goes to zero the ATAN2 is not define, given in [m] |
chrigelburri | 11:775ebb69d5e1 | 154 | */ |
chrigelburri | 22:bfec16575c91 | 155 | #define MIN_DISTANCE_ERROR 0.001f |
chrigelburri | 11:775ebb69d5e1 | 156 | /*! @} */ |
chrigelburri | 2:d8e1613dc38b | 157 | |
chrigelburri | 11:775ebb69d5e1 | 158 | /** |
chrigelburri | 11:775ebb69d5e1 | 159 | * @name Batterie control Battery Type: 1SP1P LG-18650 |
chrigelburri | 13:a7c30ee09bae | 160 | * nominal voltage 3.6V |
chrigelburri | 13:a7c30ee09bae | 161 | * 5 batterys ==> 5 * 3.5V = 17.5V |
chrigelburri | 11:775ebb69d5e1 | 162 | * @{ |
chrigelburri | 11:775ebb69d5e1 | 163 | */ |
chrigelburri | 0:31f7be68e52d | 164 | |
chrigelburri | 11:775ebb69d5e1 | 165 | /** |
chrigelburri | 11:775ebb69d5e1 | 166 | * @brief Battery Multiplicator for the potential divider. |
chrigelburri | 11:775ebb69d5e1 | 167 | * |
chrigelburri | 11:775ebb69d5e1 | 168 | * R2 / (R1 + R2) = 0.153 R2= 10k , R1 = 1.8k 1/0.153 = 6.555 --> 3.3 * 6.555 = 21.6333333f |
chrigelburri | 11:775ebb69d5e1 | 169 | */ |
chrigelburri | 11:775ebb69d5e1 | 170 | #define BAT_MULTIPLICATOR 21.633333333f |
chrigelburri | 11:775ebb69d5e1 | 171 | |
chrigelburri | 11:775ebb69d5e1 | 172 | /** |
chrigelburri | 11:775ebb69d5e1 | 173 | * @brief minium operate voltage, given in [V] |
chrigelburri | 11:775ebb69d5e1 | 174 | */ |
chrigelburri | 11:775ebb69d5e1 | 175 | #define BAT_MIN 17.5f |
chrigelburri | 11:775ebb69d5e1 | 176 | /*! @} */ |
chrigelburri | 0:31f7be68e52d | 177 | |
chrigelburri | 10:09ddb819fdcb | 178 | /** |
chrigelburri | 11:775ebb69d5e1 | 179 | * @name sampling rate for a Task Object |
chrigelburri | 11:775ebb69d5e1 | 180 | * @{ |
chrigelburri | 11:775ebb69d5e1 | 181 | */ |
chrigelburri | 11:775ebb69d5e1 | 182 | |
chrigelburri | 11:775ebb69d5e1 | 183 | /** |
chrigelburri | 11:775ebb69d5e1 | 184 | * @brief 1kHz Rate for Robot Control, given in [s] |
chrigelburri | 11:775ebb69d5e1 | 185 | */ |
chrigelburri | 11:775ebb69d5e1 | 186 | #define PERIOD_ROBOTCONTROL 0.001f |
chrigelburri | 11:775ebb69d5e1 | 187 | |
chrigelburri | 11:775ebb69d5e1 | 188 | /** |
chrigelburri | 11:775ebb69d5e1 | 189 | * @brief 1kHz Rate for State Objekt , given in [s] |
chrigelburri | 11:775ebb69d5e1 | 190 | */ |
chrigelburri | 11:775ebb69d5e1 | 191 | #define PERIOD_STATE 0.001f |
chrigelburri | 11:775ebb69d5e1 | 192 | |
chrigelburri | 11:775ebb69d5e1 | 193 | /** |
chrigelburri | 11:775ebb69d5e1 | 194 | * @brief 10Hz Rate for the Android communication , given in [s] |
chrigelburri | 11:775ebb69d5e1 | 195 | */ |
chrigelburri | 14:6a45a9f940a8 | 196 | #define PERIOD_ANDROID 0.5f |
chrigelburri | 11:775ebb69d5e1 | 197 | /*! @} */ |
chrigelburri | 11:775ebb69d5e1 | 198 | |
chrigelburri | 11:775ebb69d5e1 | 199 | /** |
chrigelburri | 11:775ebb69d5e1 | 200 | * @name Android Buffer Size for communication |
chrigelburri | 11:775ebb69d5e1 | 201 | * @{ |
chrigelburri | 11:775ebb69d5e1 | 202 | */ |
chrigelburri | 11:775ebb69d5e1 | 203 | |
chrigelburri | 11:775ebb69d5e1 | 204 | /** |
chrigelburri | 11:775ebb69d5e1 | 205 | * @brief Buffer Output |
chrigelburri | 11:775ebb69d5e1 | 206 | */ |
chrigelburri | 11:775ebb69d5e1 | 207 | #define OUTL 100 |
chrigelburri | 11:775ebb69d5e1 | 208 | |
chrigelburri | 11:775ebb69d5e1 | 209 | /** |
chrigelburri | 11:775ebb69d5e1 | 210 | * @brief Buffer Input |
chrigelburri | 11:775ebb69d5e1 | 211 | */ |
chrigelburri | 11:775ebb69d5e1 | 212 | #define INBL 100 |
chrigelburri | 11:775ebb69d5e1 | 213 | /*! @} */ |
chrigelburri | 11:775ebb69d5e1 | 214 | |
chrigelburri | 11:775ebb69d5e1 | 215 | /** |
chrigelburri | 11:775ebb69d5e1 | 216 | * @brief struct state |
chrigelburri | 11:775ebb69d5e1 | 217 | * structure containing system sensor data |
chrigelburri | 11:775ebb69d5e1 | 218 | */ |
chrigelburri | 0:31f7be68e52d | 219 | typedef struct state { |
chrigelburri | 11:775ebb69d5e1 | 220 | /** @brief millis Time [ms]*/ |
chrigelburri | 0:31f7be68e52d | 221 | int millis; |
chrigelburri | 11:775ebb69d5e1 | 222 | /** @brief Battery voltage [V] */ |
chrigelburri | 0:31f7be68e52d | 223 | float voltageBattery; |
chrigelburri | 11:775ebb69d5e1 | 224 | /** @brief Number of pulses left */ |
chrigelburri | 0:31f7be68e52d | 225 | int leftPulses; |
chrigelburri | 11:775ebb69d5e1 | 226 | /** @brief Number of pulses right */ |
chrigelburri | 0:31f7be68e52d | 227 | int rightPulses; |
chrigelburri | 11:775ebb69d5e1 | 228 | /** @brief Velocity left [m/s] */ |
chrigelburri | 0:31f7be68e52d | 229 | float leftVelocity; |
chrigelburri | 11:775ebb69d5e1 | 230 | /** @brief Velocity right [m/s] */ |
chrigelburri | 0:31f7be68e52d | 231 | float rightVelocity; |
chrigelburri | 11:775ebb69d5e1 | 232 | /** @brief Velocity of the car [m/s] */ |
chrigelburri | 0:31f7be68e52d | 233 | float velocity; |
chrigelburri | 11:775ebb69d5e1 | 234 | /** @brief Velocity rotation [°/s] */ |
chrigelburri | 0:31f7be68e52d | 235 | float omega; |
chrigelburri | 11:775ebb69d5e1 | 236 | /** @brief X-Axis from co-ordinate [m] */ |
chrigelburri | 0:31f7be68e52d | 237 | float xAxis; |
chrigelburri | 11:775ebb69d5e1 | 238 | /** @brief Y-Axis from co-ordinate [m] */ |
chrigelburri | 0:31f7be68e52d | 239 | float yAxis; |
chrigelburri | 11:775ebb69d5e1 | 240 | /** @brief X-Axis Error [m] */ |
chrigelburri | 0:31f7be68e52d | 241 | float xAxisError; |
chrigelburri | 11:775ebb69d5e1 | 242 | /** @brief X-Axis Error [m] */ |
chrigelburri | 0:31f7be68e52d | 243 | float yAxisError; |
chrigelburri | 11:775ebb69d5e1 | 244 | /** @brief Angle Error [°] */ |
chrigelburri | 0:31f7be68e52d | 245 | float angleError; |
chrigelburri | 11:775ebb69d5e1 | 246 | /** @brief Angle from Car [°] */ |
chrigelburri | 0:31f7be68e52d | 247 | float angle; |
chrigelburri | 11:775ebb69d5e1 | 248 | /** @brief Setpoint X-Axis [m] */ |
chrigelburri | 0:31f7be68e52d | 249 | float setxAxis; |
chrigelburri | 11:775ebb69d5e1 | 250 | /** @brief Setpoint Y-Axis [m] */ |
chrigelburri | 0:31f7be68e52d | 251 | float setyAxis; |
chrigelburri | 11:775ebb69d5e1 | 252 | /** @brief Setpoint Angel [°] */ |
chrigelburri | 0:31f7be68e52d | 253 | float setAngle; |
chrigelburri | 11:775ebb69d5e1 | 254 | /** @brief Setpoint velocitiy [m/s] */ |
chrigelburri | 8:696c2f9dfc62 | 255 | float setVelocity; |
chrigelburri | 11:775ebb69d5e1 | 256 | /** @brief Setpoint rotation velocitiy [rad/s] */ |
chrigelburri | 8:696c2f9dfc62 | 257 | float setOmega; |
chrigelburri | 14:6a45a9f940a8 | 258 | /** @brief State of the car */ |
chrigelburri | 0:31f7be68e52d | 259 | int state; |
chrigelburri | 11:775ebb69d5e1 | 260 | /** @brief distance to Goal */ |
chrigelburri | 2:d8e1613dc38b | 261 | float rho; |
chrigelburri | 11:775ebb69d5e1 | 262 | /** @brief theta to goal */ |
chrigelburri | 2:d8e1613dc38b | 263 | float lamda; |
chrigelburri | 11:775ebb69d5e1 | 264 | /** @brief theta from the goal */ |
chrigelburri | 2:d8e1613dc38b | 265 | float delta; |
chrigelburri | 0:31f7be68e52d | 266 | } state_t; |
chrigelburri | 0:31f7be68e52d | 267 | |
chrigelburri | 18:306d362d692b | 268 | |
chrigelburri | 18:306d362d692b | 269 | |
chrigelburri | 11:775ebb69d5e1 | 270 | #endif |