Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / Constants.h @ a0033dcb

History | View | Annotate | Download (8.852 KB)

1
#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
    // Control the FSM for line following
39
  // enum msg_content : uint8_t{
40
  //     STOP = 0, 
41
  //     START = 1,
42
  //     EDGE_LEFT = 2,
43
  //     EDGE_RIGHT = 3,
44
  //     FUZZY = 4,
45
  //     DOCK = 5,
46
  //     UNDOCK = 6,
47
  //     CHARGE = 7
48
  //   };
49

    
50
namespace CAN {
51

    
52
  const uint32_t UPDATE_PERIOD        = US2ST(10000);  // 100 Hz
53

    
54
  const uint32_t PERIODIC_TIMER_ID         = 1;
55
  const uint32_t RECEIVED_ID               = 2;
56

    
57
  const uint32_t BOARD_ID_SHIFT            = 0x00u;
58
  const uint32_t BOARD_ID_MASK             = 0x07u;
59
  const uint32_t DEVICE_ID_SHIFT           = 0x03u;
60
  const uint32_t DEVICE_ID_MASK            = 0xFFu;
61
  const uint32_t INDEX_ID_SHIFT            = 0x03u;
62
  const uint32_t INDEX_ID_MASK             = 0x07u;
63

    
64
  const uint32_t DI_WHEEL_DRIVE_ID         = 1;
65
  const uint32_t POWER_MANAGEMENT_ID       = 2;
66
  const uint32_t LIGHT_RING_ID             = 3;
67
  const uint32_t COGNITION                 = 4;
68

    
69
  const uint32_t MAGNETOMETER_X_ID         = 0x54;
70
  const uint32_t MAGNETOMETER_Y_ID         = 0x55;
71
  const uint32_t MAGNETOMETER_Z_ID         = 0x56;
72
  const uint32_t GYROSCOPE_ID              = 0x58;
73
  const uint32_t PROXIMITY_FLOOR_ID        = 0x51;
74
  const uint32_t ODOMETRY_ID               = 0x50;
75
  const uint32_t BRIGHTNESS_ID             = 0x40;
76
  inline constexpr uint32_t COLOR_ID(uint32_t index)             {return 0x38 | ((index) & 0x7);}
77
  inline constexpr uint32_t PROXIMITY_RING_ID(uint32_t index)    {return 0x30 | ((index) & 0x7);}
78
  // Charging
79
  const uint32_t REQUEST_CHARGING_OVER_PIN = 0x25;
80

    
81
  // Line following
82
  const uint32_t TRANSMIT_LINE_FOLLOW_STATE= 0x19;
83
  const uint32_t SET_LINE_FOLLOW_MSG       = 0x24;
84
  const uint32_t SET_LINE_FOLLOW_SPEED     = 0x23;
85
  const uint32_t SET_KINEMATIC_CONST_ID    = 0x22;
86
  const uint32_t TARGET_POSITION_ID        = 0x21;
87
  const uint32_t ACTUAL_SPEED_ID           = 0x20;
88
  const uint32_t SET_ODOMETRY_ID           = 0x12;
89
  const uint32_t TARGET_RPM_ID             = 0x11;
90
  const uint32_t TARGET_SPEED_ID           = 0x10;
91
  const uint32_t POWER_STATUS_ID           = 0x60;
92
  const uint32_t ROBOT_ID                  = 0x48;
93
  inline constexpr uint32_t SHELL_QUERY_ID(uint8_t index)        {return 0x70 | ((index) & 0x7);}
94
  inline constexpr uint32_t SHELL_REPLY_ID(uint8_t index)        {return 0x78 | ((index) & 0x7);}
95
  const uint32_t BROADCAST_SHUTDOWN        = 0x80u;
96

    
97
  const uint32_t CALIBRATE_PROXIMITY_FLOOR = 0x81u;
98
  const uint32_t CALIBRATE_PROXIMITY_RING  = 0x82u;
99

    
100
  const uint32_t SHUTDOWN_MAGIC            = 0xAA55u;
101
}
102

    
103
namespace constants {
104

    
105
  /** \brief Amount of seconds per minute */
106
  const int32_t secondsPerMinute = 60;
107

    
108
  /** \brief Amount of minutes per hour */
109
  const int32_t minutesPerHour = 60;
110

    
111
  /** \brief Amount of milliseconds per second */
112
  const int32_t millisecondsPerSecond = 1000;
113

    
114
  /* Several definitions of PI */
115
  constexpr float    PI   = float(M_PI);                /**< PI approximated with single precision floating point */
116
  constexpr uint32_t PIe9 = (M_PI * 1000000000) + 0.5f; /**< PI approximated with 32-bit integer and multiplied by factor 1e9 */
117
  constexpr uint32_t PIe6 = (M_PI * 1000000) + 0.5f;    /**< PI approximated with 32-bit integer and multiplied by factor 1e6 */
118
  constexpr uint16_t PIe3 = (M_PI * 1000) + 0.5f;       /**< PI approximated with 16-bit integer and multiplied by factor 1e3 */
119
  constexpr uint16_t PIe2 = (M_PI * 100) + 0.5f;        /**< PI approximated with 16-bit integer and multiplied by factor 1e2 */
120
  constexpr uint8_t  PIe1 = (M_PI * 10) + 0.5f;         /**< PI approximated with 8-bit integer and multiplied by factor 1e1 */
121
  constexpr uint8_t  PIe0 = (M_PI * 1) + 0.5f;          /**< PI approximated with 8-bit integer and multiplied by factor 1e0 */
122

    
123
namespace LightRing {
124

    
125
  /** \brief Index of the top LEDs
126
   *
127
   * Top view of the AMiRo top LEDs and their indices:
128
   *   _______
129
   *  / 7 F 0 \
130
   * |6       1|
131
   * |5       2|
132
   *  \_4_B_3_/
133
   */
134
  enum ledIndex : uint8_t {
135
    LED_BL = 4, LED_BACK_LEFT = 4, LED_SSW = 4, LED_SOUTH_SOUTHWEST = 4,
136
    LED_LB = 5, LED_LEFT_BACK = 5, LED_WSW = 5, LED_WEST_SOUTHWEST = 5,
137
    LED_LF = 6, LED_LEFT_FRONT = 6, LED_WNW = 6, LED_WEST_NORTHWEST = 6,
138
    LED_FL = 7, LED_FRONT_LEFT = 7, LED_NNW = 7, LED_NORTH_NORTHWEST = 7,
139
    LED_FR = 0, LED_FRONT_RIGHT = 0, LED_NNE = 0, LED_NORTH_NORTHEAST = 0,
140
    LED_RF = 1, LED_RIGHT_FRONT = 1, LED_ENE = 1, LED_EAST_NORTHEAST = 1,
141
    LED_RB = 2, LED_RIGHT_BACK = 2, LED_ESE = 2, LED_EAST_SOUTHEAST = 2,
142
    LED_BR = 3, LED_BACK_RIGHT = 3, LED_SSE = 3, LED_SOUTH_SOUTHEAST = 3
143
  };
144
}
145

    
146
namespace DiWheelDrive {
147

    
148
  /** \brief Distance between wheels in meter */
149
  const float wheelBaseDistanceSI = 0.069f;
150

    
151
  /** \brief Distance between wheels in micrometer */
152
  const int32_t wheelBaseDistance = wheelBaseDistanceSI * 1e6;
153

    
154
  /** \brief Wheel diameter in meter */
155
  const float wheelDiameterSI = 0.05571f;
156

    
157
  /** \brief Wheel diameter */
158
  const int32_t wheelDiameter = wheelDiameterSI * 1e6;
159

    
160
  /** \brief Wheel circumference in meter */
161
  const float wheelCircumferenceSI = M_PI * wheelDiameterSI;
162

    
163
  /** \brief Wheel circumference in micrometer */
164
  const int32_t wheelCircumference = wheelCircumferenceSI * 1e6;
165

    
166
  /** \brief Wheel error in meter (topview left:0, right:1) */
167
  const float wheelErrorSI[2] = {0.1, 0.1};
168

    
169
  /** \brief Wheel error in meter (topview left:0, right:1) */
170
  const int32_t wheelError[2] = {(int32_t) (wheelErrorSI[0] * 1e6), (int32_t) (wheelErrorSI[1] * 1e6)};
171

    
172
  /** \brief Motor increments per revolution
173
   *
174
   *  The increments are produced by 2 channels á 16
175
   *  pulses per revolution with respect to the rising
176
   *  and falling signal => 2*2*16 pulses/revolution.
177
   *  The gearbox is 22:1 => 2*2*16*22 pulses/revolution
178
   */
179
  const int32_t incrementsPerRevolution = 2 * 2 * 16 * 22;
180

    
181
  /** \brief Index of the proximity sensors
182
   *
183
   * Bottom view of the AMiRo sensors and their indices (F:Front, B:Back):
184
   *  _____
185
   * / 0F3 \
186
   * |1   2|
187
   * \__B__/
188
   */
189
  enum proximitySensorIdx : uint8_t {
190
    PROX_WL = 2, PROX_LW = 2, PROX_WHEEL_LEFT = 2, PROX_LEFT_WHEEL = 2,
191
    PROX_FL = 3, PROX_LF = 3, PROX_FRONT_LEFT = 3, PROX_LEFT_FRONT = 3,
192
    PROX_FR = 0, PROX_RF = 0, PROX_FRONT_RIGHT = 0, PROX_RIGHT_FRONT = 0,
193
    PROX_WR = 1, PROX_RW = 1, PROX_WHEEL_RIGHT = 1, PROX_RIGHT_WHEEL = 1,
194
  };
195

    
196
  /** \brief Index of the wheels
197
   *
198
   * Top view of the AMiRo wheels and their indices (F:Front, B:Back):
199
   *   ____
200
   * /| F |\
201
   * |0   1|
202
   * \|_B_|/
203
   */
204
  enum wheelIdx : uint8_t {
205
    WHEEL_L = 0, WHEEL_LEFT = 0, LEFT_WHEEL = 0,
206
    WHEEL_R = 1, WHEEL_RIGHT = 1, RIGHT_WHEEL = 1,
207
  };
208

    
209

    
210
}
211

    
212

    
213

    
214
namespace PowerManagement {
215

    
216
  /** \brief Index of the proximity sensors
217
   *
218
   * Top view of the AMiRo sensors and their indices:
219
   *   _______
220
   *  / 3 F 4 \
221
   * |2       5|
222
   * |1       6|
223
   *  \_0_B_7_/
224
   */
225
  enum proximitySensorIdx : uint8_t {
226
    PROX_BL = 0, PROX_BACK_LEFT = 0, PROX_SSW = 0, PROX_SOUTH_SOUTHWEST = 0,
227
    PROX_LB = 1, PROX_LEFT_BACK = 1, PROX_WSW = 1, PROX_WEST_SOUTHWEST = 1,
228
    PROX_LF = 2, PROX_LEFT_FRONT = 2, PROX_WNW = 2, PROX_WEST_NORTHWEST = 2,
229
    PROX_FL = 3, PROX_FRONT_LEFT = 3, PROX_NNW = 3, PROX_NORTH_NORTHWEST = 3,
230
    PROX_FR = 4, PROX_FRONT_RIGHT = 4, PROX_NNE = 4, PROX_NORTH_NORTHEAST = 4,
231
    PROX_RF = 5, PROX_RIGHT_FRONT = 5, PROX_ENE = 5, PROX_EAST_NORTHEAST = 5,
232
    PROX_RB = 6, PROX_RIGHT_BACK = 6, PROX_ESE = 6, PROX_EAST_SOUTHEAST = 6,
233
    PROX_BR = 7, PROX_BACK_RIGHT = 7, PROX_SSE = 7, PROX_SOUTH_SOUTHEAST = 7
234
  };
235

    
236
  /** \brief Index of the batteries.
237
   *
238
   * The port names are printed on the PCB.
239
   */
240
  enum batteryPortIdx : uint8_t {
241
    BAT_P7 = 0, BAT_A = 0,
242
    BAT_P8 = 1, BAT_B = 1
243
  };
244

    
245
  /** \brief Index of the power monitors.
246
   */
247
  enum powerMonitorIdx : uint8_t {
248
    INA_VDD = 0,
249
    INA_VIO18 = 1,
250
    INA_VIO33 = 2,
251
    INA_VIO42 = 3,
252
    INA_VIO50 = 4
253
  };
254
}
255

    
256
}
257

    
258
}
259

    
260
#endif /* AMIRO_CONSTANTS_H_ */