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