Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
firmware_settings.h
Go to the documentation of this file.
1 #ifndef FIRMWARE_SETTINGS_HPP_
2 #define FIRMWARE_SETTINGS_HPP_
3 
4 typedef struct __attribute__((packed, aligned(1))) {
5  int16_t front;
6  int16_t rear;
8 
9 typedef struct __attribute__((packed)) {
10  float motor_current_max; /* Ampere */
11 
12  float erpm_max;
13 
14  float max_brake_current; /* Ampere */
15 
16  ServoOffset_t max_servo_offset; /* shall be positive */
17 
18  uint16_t manual_override_difference;
19 
20  /* if true the car will take the RC steering values in autonomous mode */
21  uint8_t use_rc_to_steer;
22 
23  /* set erpm instead of motor current with RC */
24  uint8_t rc_use_erpm;
25 
26  /* can be negative, depends in which direction the wheels should steer in
27  * idle*/
28  ServoOffset_t servo_offset;
29 
30  float motor_current_max_rc;
31 
32  float erpm_max_rc;
34 /*
35  * tests to ensure that alignment works as intended
36  * Further info here: https://www.embedded.com/design/prototyping-and-development/4024941/Learn-a-new-trick-with-the-offsetof--macro
37  */
38 /* disable warnings for this one, only fail on error */
39 #pragma GCC diagnostic push
40 #pragma GCC diagnostic ignored "-Wunused-variable"
41 static union {
42  char wrong_offset_motor_current_max[(offsetof(FirmwareSetup_t, motor_current_max) == 0) ? 1 : -1];
43 
44  char wrong_offset_erpm_max[(offsetof(FirmwareSetup_t, erpm_max) == 4) ? 1 : -1];
45 
46  char wrong_offset_max_brake_current[(offsetof(FirmwareSetup_t, max_brake_current) == 4 + 4) ? 1 : -1];
47 
48  char wrong_offset_max_servo_offset[(offsetof(FirmwareSetup_t, max_servo_offset) == 12) ? 1 : -1];
49 
50  char wrong_offset_manual_override_difference[(offsetof(FirmwareSetup_t, manual_override_difference) == 12 + 4) ? 1 : -1];
51 
52  char wrong_offset_use_rc_to_steer[(offsetof(FirmwareSetup_t, use_rc_to_steer) == 12 + 4 + 2) ? 1 : -1];
53 
54  char wrong_offset_rc_use_erpm[(offsetof(FirmwareSetup_t, rc_use_erpm) == 12 + 4 + 2 + 1) ? 1 : -1];
55 
56  char wrong_offset_servo_offset[(offsetof(FirmwareSetup_t, servo_offset) == 12 + 4 + 2 + 1 + 1) ? 1 : -1];
57 
58  char wrong_offset_motor_current_max_rc[(offsetof(FirmwareSetup_t, motor_current_max_rc) == 12 + 4 + 2 + 1 + 1 + 4) ? 1 : -1];
59 
60  char wrong_offset_erpm_max_rc[(offsetof(FirmwareSetup_t, erpm_max_rc) == 12 + 4 + 2 + 1 + 1 + 4 + 4) ? 1 : -1];
61 
62  char wrong_sizeof_packet[(sizeof(FirmwareSetup_t) == 32) ? 1 : -1];
64 /* enable all warnings again */
65 #pragma GCC diagnostic pop
66 
67 #endif /* ifndef FIRMWARE_SETTINGS_HPP_ */
wrong_offset_motor_current_max
char wrong_offset_motor_current_max[(offsetof(FirmwareSetup_t, motor_current_max)==0) ? 1 :-1]
Definition: firmware_settings.h:42
FirmwareSetup_t
FirmwareSetup_t
Definition: firmware_settings.h:33
wrong_offset_max_servo_offset
char wrong_offset_max_servo_offset[(offsetof(FirmwareSetup_t, max_servo_offset)==12) ? 1 :-1]
Definition: firmware_settings.h:48
wrong_offset_motor_current_max_rc
char wrong_offset_motor_current_max_rc[(offsetof(FirmwareSetup_t, motor_current_max_rc)==12+4+2+1+1+4) ? 1 :-1]
Definition: firmware_settings.h:58
cuprules::modes::training::erpm_max_rc
const float erpm_max_rc
Definition: cuprules.hpp:10
wrong_offset_rc_use_erpm
char wrong_offset_rc_use_erpm[(offsetof(FirmwareSetup_t, rc_use_erpm)==12+4+2+1) ? 1 :-1]
Definition: firmware_settings.h:54
__attribute__
struct __attribute__((packed, aligned(1)))
Definition: firmware_settings.h:4
wrong_offset_erpm_max_rc
char wrong_offset_erpm_max_rc[(offsetof(FirmwareSetup_t, erpm_max_rc)==12+4+2+1+1+4+4) ? 1 :-1]
Definition: firmware_settings.h:60
FirmwareSetupTest
static union @0 FirmwareSetupTest
wrong_sizeof_packet
char wrong_sizeof_packet[(sizeof(FirmwareSetup_t)==32) ? 1 :-1]
Definition: firmware_settings.h:62
wrong_offset_use_rc_to_steer
char wrong_offset_use_rc_to_steer[(offsetof(FirmwareSetup_t, use_rc_to_steer)==12+4+2) ? 1 :-1]
Definition: firmware_settings.h:52
wrong_offset_manual_override_difference
char wrong_offset_manual_override_difference[(offsetof(FirmwareSetup_t, manual_override_difference)==12+4) ? 1 :-1]
Definition: firmware_settings.h:50
wrong_offset_servo_offset
char wrong_offset_servo_offset[(offsetof(FirmwareSetup_t, servo_offset)==12+4+2+1+1) ? 1 :-1]
Definition: firmware_settings.h:56
ServoOffset_t
ServoOffset_t
Definition: firmware_settings.h:7
wrong_offset_erpm_max
char wrong_offset_erpm_max[(offsetof(FirmwareSetup_t, erpm_max)==4) ? 1 :-1]
Definition: firmware_settings.h:44
wrong_offset_max_brake_current
char wrong_offset_max_brake_current[(offsetof(FirmwareSetup_t, max_brake_current)==4+4) ? 1 :-1]
Definition: firmware_settings.h:46
cuprules::modes::training::rc_use_erpm
const uint8_t rc_use_erpm
Definition: cuprules.hpp:9