Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / Constants.h @ 81b48c66

History | View | Annotate | Download (9.54 KB)

1 58fe0e0b Thomas Schöpping
#ifndef AMIRO_CONSTANTS_H_
2
#define AMIRO_CONSTANTS_H_
3
4
/*! \brief Constants regarding the AMiRo platform
5
 *
6
 *  This header contains constant variables
7
 *  regarding the AMiRo platform, which means that
8
 *  these values do not change during runtime.
9
 *  Constants are e.g. physical ones like seconds per minute
10
 *  or geometrical ones like the circumference of wheel.
11
 *  All physical constants (therefore all values with a
12
 *  physical unit) are implicitly in µ iff the variable
13
 *  is of type integer, unless it is explicitly named in
14
 *  the variable.
15
 *  All physical constants (therefore all values with a
16
 *  physical unit) are implicitly without prefix (e.g. µ)
17
 *  iff the variable is of type float, unless it is
18
 *  explicitly named in the variable. The SI prefix is
19
 *  used, iff the variable is of type float and therefor
20
 *  in SI units.
21
 */
22
23
#include <math.h>
24
#include <stdint.h>
25
26
/* CAN_* defines start */
27
28
/** \brief Controller Area Network specific defines
29
 *
30
 * These CAN_* defines are used in ControllerAreaNetworkRx.h
31
 * and ControllerAreaNetworkTx.h
32
 */
33
34
/* CAN_* defines end */
35
36
namespace amiro {
37
38 a47d64ad galberding
enum msg_content : uint8_t {
39
  MSG_STOP = 0,
40
  MSG_START = 1,
41
  MSG_EDGE_LEFT = 2,
42
  MSG_EDGE_RIGHT = 3,
43
  MSG_FUZZY = 4,
44
  MSG_DOCK = 5,
45
  MSG_UNDOCK = 6,
46
  MSG_CHARGE = 7,
47
  MSG_RESET_ODOMETRY = 8,
48
  MSG_CALIBRATE_BLACK = 9,
49
  MSG_CALIBRATE_WHITE = 10,
50
  MSG_TEST_MAP_STATE = 11
51
};
52 19a69797 galberding
53 3c3c3bb9 galberding
enum ut_states : int8_t {
54
  UT_IDLE = 0,
55
  UT_FOLLOW_LINE = 1,
56
  UT_DETECT_STATION = 2,
57
  UT_REVERSE = 3,
58
  UT_PUSH_BACK = 4,
59
  UT_CHECK_POSITIONING = 5,
60
  UT_CHECK_VOLTAGE = 6,
61
  UT_CHARGING = 7,
62
  UT_RELEASE = 8,
63
  UT_RELEASE_TO_CORRECT = 9,
64
  UT_CORRECT_POSITIONING = 10,
65
  UT_TURN = 12,
66
  UT_INACTIVE = 13,
67
  UT_CALIBRATION = 14,
68
  UT_CALIBRATION_CHECK = 15,
69
  UT_DEVIATION_CORRECTION = 16,
70
  UT_TEST_MAP_STATE = 17,
71
  UT_TEST_MAP_AUTO_STATE = 18,
72
  UT_DOCKING_ERROR = -1,
73
  UT_REVERSE_TIMEOUT_ERROR = -2,
74
  UT_CALIBRATION_ERROR = -3,
75
  UT_WHITE_DETECTION_ERROR = -4,
76
  UT_PROXY_DETECTION_ERROR = -5,
77
  UT_NO_CHARGING_POWER_ERROR = -6,
78
  UT_UNKNOWN_STATE_ERROR = -7
79
};
80
81 58fe0e0b Thomas Schöpping
namespace CAN {
82
83 dd47d655 galberding
  const uint32_t UPDATE_PERIOD        = US2ST(10000);  // 100 Hz
84 58fe0e0b Thomas Schöpping
85
  const uint32_t PERIODIC_TIMER_ID         = 1;
86
  const uint32_t RECEIVED_ID               = 2;
87
88
  const uint32_t BOARD_ID_SHIFT            = 0x00u;
89
  const uint32_t BOARD_ID_MASK             = 0x07u;
90
  const uint32_t DEVICE_ID_SHIFT           = 0x03u;
91
  const uint32_t DEVICE_ID_MASK            = 0xFFu;
92
  const uint32_t INDEX_ID_SHIFT            = 0x03u;
93
  const uint32_t INDEX_ID_MASK             = 0x07u;
94
95
  const uint32_t DI_WHEEL_DRIVE_ID         = 1;
96
  const uint32_t POWER_MANAGEMENT_ID       = 2;
97
  const uint32_t LIGHT_RING_ID             = 3;
98
  const uint32_t COGNITION                 = 4;
99
100 b4885314 Thomas Schöpping
  const uint32_t MAGNETOMETER_X_ID         = 0x54;
101
  const uint32_t MAGNETOMETER_Y_ID         = 0x55;
102
  const uint32_t MAGNETOMETER_Z_ID         = 0x56;
103
  const uint32_t GYROSCOPE_ID              = 0x58;
104 58fe0e0b Thomas Schöpping
  const uint32_t PROXIMITY_FLOOR_ID        = 0x51;
105
  const uint32_t ODOMETRY_ID               = 0x50;
106
  const uint32_t BRIGHTNESS_ID             = 0x40;
107
  inline constexpr uint32_t COLOR_ID(uint32_t index)             {return 0x38 | ((index) & 0x7);}
108
  inline constexpr uint32_t PROXIMITY_RING_ID(uint32_t index)    {return 0x30 | ((index) & 0x7);}
109 beb4f137 galberding
  // Charging
110
  const uint32_t REQUEST_CHARGING_OVER_PIN = 0x25;
111
112
  // Line following
113 98e7c69b galberding
  const uint32_t TRANSMIT_LINE_FOLLOW_STATE= 0x19;
114 f3972840 galberding
  const uint32_t SET_LINE_FOLLOW_MSG       = 0x24;
115 25388c2f Georg Alberding
  const uint32_t SET_LINE_FOLLOW_SPEED     = 0x23;
116 58fe0e0b Thomas Schöpping
  const uint32_t SET_KINEMATIC_CONST_ID    = 0x22;
117
  const uint32_t TARGET_POSITION_ID        = 0x21;
118
  const uint32_t ACTUAL_SPEED_ID           = 0x20;
119
  const uint32_t SET_ODOMETRY_ID           = 0x12;
120
  const uint32_t TARGET_RPM_ID             = 0x11;
121
  const uint32_t TARGET_SPEED_ID           = 0x10;
122
  const uint32_t POWER_STATUS_ID           = 0x60;
123
  const uint32_t ROBOT_ID                  = 0x48;
124
  inline constexpr uint32_t SHELL_QUERY_ID(uint8_t index)        {return 0x70 | ((index) & 0x7);}
125
  inline constexpr uint32_t SHELL_REPLY_ID(uint8_t index)        {return 0x78 | ((index) & 0x7);}
126
  const uint32_t BROADCAST_SHUTDOWN        = 0x80u;
127
128
  const uint32_t CALIBRATE_PROXIMITY_FLOOR = 0x81u;
129
  const uint32_t CALIBRATE_PROXIMITY_RING  = 0x82u;
130
131
  const uint32_t SHUTDOWN_MAGIC            = 0xAA55u;
132
}
133
134
namespace constants {
135
136
  /** \brief Amount of seconds per minute */
137
  const int32_t secondsPerMinute = 60;
138
139
  /** \brief Amount of minutes per hour */
140
  const int32_t minutesPerHour = 60;
141
142
  /** \brief Amount of milliseconds per second */
143
  const int32_t millisecondsPerSecond = 1000;
144
145
  /* Several definitions of PI */
146
  constexpr float    PI   = float(M_PI);                /**< PI approximated with single precision floating point */
147
  constexpr uint32_t PIe9 = (M_PI * 1000000000) + 0.5f; /**< PI approximated with 32-bit integer and multiplied by factor 1e9 */
148
  constexpr uint32_t PIe6 = (M_PI * 1000000) + 0.5f;    /**< PI approximated with 32-bit integer and multiplied by factor 1e6 */
149
  constexpr uint16_t PIe3 = (M_PI * 1000) + 0.5f;       /**< PI approximated with 16-bit integer and multiplied by factor 1e3 */
150
  constexpr uint16_t PIe2 = (M_PI * 100) + 0.5f;        /**< PI approximated with 16-bit integer and multiplied by factor 1e2 */
151
  constexpr uint8_t  PIe1 = (M_PI * 10) + 0.5f;         /**< PI approximated with 8-bit integer and multiplied by factor 1e1 */
152
  constexpr uint8_t  PIe0 = (M_PI * 1) + 0.5f;          /**< PI approximated with 8-bit integer and multiplied by factor 1e0 */
153
154
namespace LightRing {
155
156
  /** \brief Index of the top LEDs
157
   *
158
   * Top view of the AMiRo top LEDs and their indices:
159
   *   _______
160
   *  / 7 F 0 \
161
   * |6       1|
162
   * |5       2|
163
   *  \_4_B_3_/
164
   */
165
  enum ledIndex : uint8_t {
166
    LED_BL = 4, LED_BACK_LEFT = 4, LED_SSW = 4, LED_SOUTH_SOUTHWEST = 4,
167
    LED_LB = 5, LED_LEFT_BACK = 5, LED_WSW = 5, LED_WEST_SOUTHWEST = 5,
168
    LED_LF = 6, LED_LEFT_FRONT = 6, LED_WNW = 6, LED_WEST_NORTHWEST = 6,
169
    LED_FL = 7, LED_FRONT_LEFT = 7, LED_NNW = 7, LED_NORTH_NORTHWEST = 7,
170
    LED_FR = 0, LED_FRONT_RIGHT = 0, LED_NNE = 0, LED_NORTH_NORTHEAST = 0,
171
    LED_RF = 1, LED_RIGHT_FRONT = 1, LED_ENE = 1, LED_EAST_NORTHEAST = 1,
172
    LED_RB = 2, LED_RIGHT_BACK = 2, LED_ESE = 2, LED_EAST_SOUTHEAST = 2,
173
    LED_BR = 3, LED_BACK_RIGHT = 3, LED_SSE = 3, LED_SOUTH_SOUTHEAST = 3
174
  };
175
}
176
177
namespace DiWheelDrive {
178
179
  /** \brief Distance between wheels in meter */
180
  const float wheelBaseDistanceSI = 0.069f;
181
182
  /** \brief Distance between wheels in micrometer */
183
  const int32_t wheelBaseDistance = wheelBaseDistanceSI * 1e6;
184
185
  /** \brief Wheel diameter in meter */
186
  const float wheelDiameterSI = 0.05571f;
187
188
  /** \brief Wheel diameter */
189
  const int32_t wheelDiameter = wheelDiameterSI * 1e6;
190
191
  /** \brief Wheel circumference in meter */
192
  const float wheelCircumferenceSI = M_PI * wheelDiameterSI;
193
194
  /** \brief Wheel circumference in micrometer */
195
  const int32_t wheelCircumference = wheelCircumferenceSI * 1e6;
196
197
  /** \brief Wheel error in meter (topview left:0, right:1) */
198
  const float wheelErrorSI[2] = {0.1, 0.1};
199
200
  /** \brief Wheel error in meter (topview left:0, right:1) */
201
  const int32_t wheelError[2] = {(int32_t) (wheelErrorSI[0] * 1e6), (int32_t) (wheelErrorSI[1] * 1e6)};
202
203
  /** \brief Motor increments per revolution
204
   *
205
   *  The increments are produced by 2 channels á 16
206
   *  pulses per revolution with respect to the rising
207
   *  and falling signal => 2*2*16 pulses/revolution.
208
   *  The gearbox is 22:1 => 2*2*16*22 pulses/revolution
209
   */
210
  const int32_t incrementsPerRevolution = 2 * 2 * 16 * 22;
211
212
  /** \brief Index of the proximity sensors
213
   *
214
   * Bottom view of the AMiRo sensors and their indices (F:Front, B:Back):
215
   *  _____
216
   * / 0F3 \
217
   * |1   2|
218
   * \__B__/
219
   */
220
  enum proximitySensorIdx : uint8_t {
221
    PROX_WL = 2, PROX_LW = 2, PROX_WHEEL_LEFT = 2, PROX_LEFT_WHEEL = 2,
222
    PROX_FL = 3, PROX_LF = 3, PROX_FRONT_LEFT = 3, PROX_LEFT_FRONT = 3,
223
    PROX_FR = 0, PROX_RF = 0, PROX_FRONT_RIGHT = 0, PROX_RIGHT_FRONT = 0,
224
    PROX_WR = 1, PROX_RW = 1, PROX_WHEEL_RIGHT = 1, PROX_RIGHT_WHEEL = 1,
225
  };
226
227
  /** \brief Index of the wheels
228
   *
229
   * Top view of the AMiRo wheels and their indices (F:Front, B:Back):
230
   *   ____
231
   * /| F |\
232
   * |0   1|
233
   * \|_B_|/
234
   */
235
  enum wheelIdx : uint8_t {
236
    WHEEL_L = 0, WHEEL_LEFT = 0, LEFT_WHEEL = 0,
237
    WHEEL_R = 1, WHEEL_RIGHT = 1, RIGHT_WHEEL = 1,
238
  };
239 19a69797 galberding
240
241 58fe0e0b Thomas Schöpping
}
242
243 19a69797 galberding
244
245 58fe0e0b Thomas Schöpping
namespace PowerManagement {
246
247
  /** \brief Index of the proximity sensors
248
   *
249
   * Top view of the AMiRo sensors and their indices:
250
   *   _______
251
   *  / 3 F 4 \
252
   * |2       5|
253
   * |1       6|
254
   *  \_0_B_7_/
255
   */
256
  enum proximitySensorIdx : uint8_t {
257
    PROX_BL = 0, PROX_BACK_LEFT = 0, PROX_SSW = 0, PROX_SOUTH_SOUTHWEST = 0,
258
    PROX_LB = 1, PROX_LEFT_BACK = 1, PROX_WSW = 1, PROX_WEST_SOUTHWEST = 1,
259
    PROX_LF = 2, PROX_LEFT_FRONT = 2, PROX_WNW = 2, PROX_WEST_NORTHWEST = 2,
260
    PROX_FL = 3, PROX_FRONT_LEFT = 3, PROX_NNW = 3, PROX_NORTH_NORTHWEST = 3,
261
    PROX_FR = 4, PROX_FRONT_RIGHT = 4, PROX_NNE = 4, PROX_NORTH_NORTHEAST = 4,
262
    PROX_RF = 5, PROX_RIGHT_FRONT = 5, PROX_ENE = 5, PROX_EAST_NORTHEAST = 5,
263
    PROX_RB = 6, PROX_RIGHT_BACK = 6, PROX_ESE = 6, PROX_EAST_SOUTHEAST = 6,
264
    PROX_BR = 7, PROX_BACK_RIGHT = 7, PROX_SSE = 7, PROX_SOUTH_SOUTHEAST = 7
265
  };
266
267
  /** \brief Index of the batteries.
268
   *
269
   * The port names are printed on the PCB.
270
   */
271
  enum batteryPortIdx : uint8_t {
272
    BAT_P7 = 0, BAT_A = 0,
273
    BAT_P8 = 1, BAT_B = 1
274
  };
275
276
  /** \brief Index of the power monitors.
277
   */
278
  enum powerMonitorIdx : uint8_t {
279
    INA_VDD = 0,
280
    INA_VIO18 = 1,
281
    INA_VIO33 = 2,
282
    INA_VIO42 = 3,
283
    INA_VIO50 = 4
284
  };
285
}
286
287
}
288
289
}
290
291 a47d64ad galberding
#endif /* AMIRO_CONSTANTS_H_ */