amiro-os / include / amiro / Constants.h @ b8085493
History | View | Annotate | Download (8.415 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 |
namespace CAN { |
39 |
|
40 |
const uint32_t UPDATE_PERIOD = US2ST(62500); // 16 Hz |
41 |
|
42 |
const uint32_t PERIODIC_TIMER_ID = 1; |
43 |
const uint32_t RECEIVED_ID = 2; |
44 |
|
45 |
const uint32_t BOARD_ID_SHIFT = 0x00u; |
46 |
const uint32_t BOARD_ID_MASK = 0x07u; |
47 |
const uint32_t DEVICE_ID_SHIFT = 0x03u; |
48 |
const uint32_t DEVICE_ID_MASK = 0xFFu; |
49 |
const uint32_t INDEX_ID_SHIFT = 0x03u; |
50 |
const uint32_t INDEX_ID_MASK = 0x07u; |
51 |
|
52 |
const uint32_t DI_WHEEL_DRIVE_ID = 1; |
53 |
const uint32_t POWER_MANAGEMENT_ID = 2; |
54 |
const uint32_t LIGHT_RING_ID = 3; |
55 |
const uint32_t COGNITION = 4; |
56 |
|
57 |
const uint32_t MAGNETOMETER_X_ID = 0x54; |
58 |
const uint32_t MAGNETOMETER_Y_ID = 0x55; |
59 |
const uint32_t MAGNETOMETER_Z_ID = 0x56; |
60 |
const uint32_t GYROSCOPE_ID = 0x58; |
61 |
const uint32_t PROXIMITY_FLOOR_ID = 0x51; |
62 |
const uint32_t ODOMETRY_ID = 0x50; |
63 |
const uint32_t BRIGHTNESS_ID = 0x40; |
64 |
inline constexpr uint32_t COLOR_ID(uint32_t index) {return 0x38 | ((index) & 0x7);} |
65 |
inline constexpr uint32_t PROXIMITY_RING_ID(uint32_t index) {return 0x30 | ((index) & 0x7);} |
66 |
const uint32_t SET_LINE_FOLLOW_SPEED = 0x23; |
67 |
const uint32_t SET_KINEMATIC_CONST_ID = 0x22; |
68 |
const uint32_t TARGET_POSITION_ID = 0x21; |
69 |
const uint32_t ACTUAL_SPEED_ID = 0x20; |
70 |
const uint32_t SET_ODOMETRY_ID = 0x12; |
71 |
const uint32_t TARGET_RPM_ID = 0x11; |
72 |
const uint32_t TARGET_SPEED_ID = 0x10; |
73 |
const uint32_t POWER_STATUS_ID = 0x60; |
74 |
const uint32_t ROBOT_ID = 0x48; |
75 |
inline constexpr uint32_t SHELL_QUERY_ID(uint8_t index) {return 0x70 | ((index) & 0x7);} |
76 |
inline constexpr uint32_t SHELL_REPLY_ID(uint8_t index) {return 0x78 | ((index) & 0x7);} |
77 |
const uint32_t BROADCAST_SHUTDOWN = 0x80u; |
78 |
|
79 |
const uint32_t CALIBRATE_PROXIMITY_FLOOR = 0x81u; |
80 |
const uint32_t CALIBRATE_PROXIMITY_RING = 0x82u; |
81 |
|
82 |
const uint32_t SHUTDOWN_MAGIC = 0xAA55u; |
83 |
} |
84 |
|
85 |
namespace constants { |
86 |
|
87 |
/** \brief Amount of seconds per minute */
|
88 |
const int32_t secondsPerMinute = 60; |
89 |
|
90 |
/** \brief Amount of minutes per hour */
|
91 |
const int32_t minutesPerHour = 60; |
92 |
|
93 |
/** \brief Amount of milliseconds per second */
|
94 |
const int32_t millisecondsPerSecond = 1000; |
95 |
|
96 |
/* Several definitions of PI */
|
97 |
constexpr float PI = float(M_PI); /**< PI approximated with single precision floating point */ |
98 |
constexpr uint32_t PIe9 = (M_PI * 1000000000) + 0.5f; /**< PI approximated with 32-bit integer and multiplied by factor 1e9 */ |
99 |
constexpr uint32_t PIe6 = (M_PI * 1000000) + 0.5f; /**< PI approximated with 32-bit integer and multiplied by factor 1e6 */ |
100 |
constexpr uint16_t PIe3 = (M_PI * 1000) + 0.5f; /**< PI approximated with 16-bit integer and multiplied by factor 1e3 */ |
101 |
constexpr uint16_t PIe2 = (M_PI * 100) + 0.5f; /**< PI approximated with 16-bit integer and multiplied by factor 1e2 */ |
102 |
constexpr uint8_t PIe1 = (M_PI * 10) + 0.5f; /**< PI approximated with 8-bit integer and multiplied by factor 1e1 */ |
103 |
constexpr uint8_t PIe0 = (M_PI * 1) + 0.5f; /**< PI approximated with 8-bit integer and multiplied by factor 1e0 */ |
104 |
|
105 |
namespace LightRing { |
106 |
|
107 |
/** \brief Index of the top LEDs
|
108 |
*
|
109 |
* Top view of the AMiRo top LEDs and their indices:
|
110 |
* _______
|
111 |
* / 7 F 0 \
|
112 |
* |6 1|
|
113 |
* |5 2|
|
114 |
* \_4_B_3_/
|
115 |
*/
|
116 |
enum ledIndex : uint8_t {
|
117 |
LED_BL = 4, LED_BACK_LEFT = 4, LED_SSW = 4, LED_SOUTH_SOUTHWEST = 4, |
118 |
LED_LB = 5, LED_LEFT_BACK = 5, LED_WSW = 5, LED_WEST_SOUTHWEST = 5, |
119 |
LED_LF = 6, LED_LEFT_FRONT = 6, LED_WNW = 6, LED_WEST_NORTHWEST = 6, |
120 |
LED_FL = 7, LED_FRONT_LEFT = 7, LED_NNW = 7, LED_NORTH_NORTHWEST = 7, |
121 |
LED_FR = 0, LED_FRONT_RIGHT = 0, LED_NNE = 0, LED_NORTH_NORTHEAST = 0, |
122 |
LED_RF = 1, LED_RIGHT_FRONT = 1, LED_ENE = 1, LED_EAST_NORTHEAST = 1, |
123 |
LED_RB = 2, LED_RIGHT_BACK = 2, LED_ESE = 2, LED_EAST_SOUTHEAST = 2, |
124 |
LED_BR = 3, LED_BACK_RIGHT = 3, LED_SSE = 3, LED_SOUTH_SOUTHEAST = 3 |
125 |
}; |
126 |
} |
127 |
|
128 |
namespace DiWheelDrive { |
129 |
|
130 |
/** \brief Distance between wheels in meter */
|
131 |
const float wheelBaseDistanceSI = 0.069f; |
132 |
|
133 |
/** \brief Distance between wheels in micrometer */
|
134 |
const int32_t wheelBaseDistance = wheelBaseDistanceSI * 1e6; |
135 |
|
136 |
/** \brief Wheel diameter in meter */
|
137 |
const float wheelDiameterSI = 0.05571f; |
138 |
|
139 |
/** \brief Wheel diameter */
|
140 |
const int32_t wheelDiameter = wheelDiameterSI * 1e6; |
141 |
|
142 |
/** \brief Wheel circumference in meter */
|
143 |
const float wheelCircumferenceSI = M_PI * wheelDiameterSI; |
144 |
|
145 |
/** \brief Wheel circumference in micrometer */
|
146 |
const int32_t wheelCircumference = wheelCircumferenceSI * 1e6; |
147 |
|
148 |
/** \brief Wheel error in meter (topview left:0, right:1) */
|
149 |
const float wheelErrorSI[2] = {0.1, 0.1}; |
150 |
|
151 |
/** \brief Wheel error in meter (topview left:0, right:1) */
|
152 |
const int32_t wheelError[2] = {(int32_t) (wheelErrorSI[0] * 1e6), (int32_t) (wheelErrorSI[1] * 1e6)}; |
153 |
|
154 |
/** \brief Motor increments per revolution
|
155 |
*
|
156 |
* The increments are produced by 2 channels á 16
|
157 |
* pulses per revolution with respect to the rising
|
158 |
* and falling signal => 2*2*16 pulses/revolution.
|
159 |
* The gearbox is 22:1 => 2*2*16*22 pulses/revolution
|
160 |
*/
|
161 |
const int32_t incrementsPerRevolution = 2 * 2 * 16 * 22; |
162 |
|
163 |
/** \brief Index of the proximity sensors
|
164 |
*
|
165 |
* Bottom view of the AMiRo sensors and their indices (F:Front, B:Back):
|
166 |
* _____
|
167 |
* / 0F3 \
|
168 |
* |1 2|
|
169 |
* \__B__/
|
170 |
*/
|
171 |
enum proximitySensorIdx : uint8_t {
|
172 |
PROX_WL = 2, PROX_LW = 2, PROX_WHEEL_LEFT = 2, PROX_LEFT_WHEEL = 2, |
173 |
PROX_FL = 3, PROX_LF = 3, PROX_FRONT_LEFT = 3, PROX_LEFT_FRONT = 3, |
174 |
PROX_FR = 0, PROX_RF = 0, PROX_FRONT_RIGHT = 0, PROX_RIGHT_FRONT = 0, |
175 |
PROX_WR = 1, PROX_RW = 1, PROX_WHEEL_RIGHT = 1, PROX_RIGHT_WHEEL = 1, |
176 |
}; |
177 |
|
178 |
/** \brief Index of the wheels
|
179 |
*
|
180 |
* Top view of the AMiRo wheels and their indices (F:Front, B:Back):
|
181 |
* ____
|
182 |
* /| F |\
|
183 |
* |0 1|
|
184 |
* \|_B_|/
|
185 |
*/
|
186 |
enum wheelIdx : uint8_t {
|
187 |
WHEEL_L = 0, WHEEL_LEFT = 0, LEFT_WHEEL = 0, |
188 |
WHEEL_R = 1, WHEEL_RIGHT = 1, RIGHT_WHEEL = 1, |
189 |
}; |
190 |
} |
191 |
|
192 |
namespace PowerManagement { |
193 |
|
194 |
/** \brief Index of the proximity sensors
|
195 |
*
|
196 |
* Top view of the AMiRo sensors and their indices:
|
197 |
* _______
|
198 |
* / 3 F 4 \
|
199 |
* |2 5|
|
200 |
* |1 6|
|
201 |
* \_0_B_7_/
|
202 |
*/
|
203 |
enum proximitySensorIdx : uint8_t {
|
204 |
PROX_BL = 0, PROX_BACK_LEFT = 0, PROX_SSW = 0, PROX_SOUTH_SOUTHWEST = 0, |
205 |
PROX_LB = 1, PROX_LEFT_BACK = 1, PROX_WSW = 1, PROX_WEST_SOUTHWEST = 1, |
206 |
PROX_LF = 2, PROX_LEFT_FRONT = 2, PROX_WNW = 2, PROX_WEST_NORTHWEST = 2, |
207 |
PROX_FL = 3, PROX_FRONT_LEFT = 3, PROX_NNW = 3, PROX_NORTH_NORTHWEST = 3, |
208 |
PROX_FR = 4, PROX_FRONT_RIGHT = 4, PROX_NNE = 4, PROX_NORTH_NORTHEAST = 4, |
209 |
PROX_RF = 5, PROX_RIGHT_FRONT = 5, PROX_ENE = 5, PROX_EAST_NORTHEAST = 5, |
210 |
PROX_RB = 6, PROX_RIGHT_BACK = 6, PROX_ESE = 6, PROX_EAST_SOUTHEAST = 6, |
211 |
PROX_BR = 7, PROX_BACK_RIGHT = 7, PROX_SSE = 7, PROX_SOUTH_SOUTHEAST = 7 |
212 |
}; |
213 |
|
214 |
/** \brief Index of the batteries.
|
215 |
*
|
216 |
* The port names are printed on the PCB.
|
217 |
*/
|
218 |
enum batteryPortIdx : uint8_t {
|
219 |
BAT_P7 = 0, BAT_A = 0, |
220 |
BAT_P8 = 1, BAT_B = 1 |
221 |
}; |
222 |
|
223 |
/** \brief Index of the power monitors.
|
224 |
*/
|
225 |
enum powerMonitorIdx : uint8_t {
|
226 |
INA_VDD = 0,
|
227 |
INA_VIO18 = 1,
|
228 |
INA_VIO33 = 2,
|
229 |
INA_VIO42 = 3,
|
230 |
INA_VIO50 = 4
|
231 |
}; |
232 |
} |
233 |
|
234 |
} |
235 |
|
236 |
} |
237 |
|
238 |
#endif /* AMIRO_CONSTANTS_H_ */ |