constants.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 namespace openrover
4 {
5 
6 //special build numbers that have significance for operation of the driver
8 
9 //empirically tuned - tested extensively
10 const float MOTOR_RPM_TO_MPS_RATIO = 13749 / 1.26;
11 const float MOTOR_RPM_TO_MPS_CFB = -0.07;
12 const float WHEEL_TO_TRACK_RATIO = 1.818;
13 
14 const unsigned char SERIAL_START_BYTE = 253;
17 const int LOOP_RATE = 1000; // microseconds between serial manager calls
18 
19 // flipper constants__________
20 // odometry flipper constants
21 const float ODOM_ENCODER_COEF_F = 110.8; // r_track*2*pi*(2.54/100)/96*1e6/45
22 const float ODOM_AXLE_TRACK_F = 10.75; // distance between centerlines of tracks
23 const float ODOM_ANGULAR_COEF_F = 0.5 / (ODOM_AXLE_TRACK_F * 2.54 / 100); // rad per meter
24 const float ODOM_TRACTION_FACTOR_F = 0.75;
25 // high speed mode cmd_vel to motor command flipper constants
28 
29 // 4wd constants__________
30 // odometry 4wd constants
31 const float ODOM_ENCODER_COEF_4WD = 182.405; // r_wheel*2*pi*(2.54/100)/96*1e6/45
32 const float ODOM_AXLE_TRACK_4WD = 14.375; // distance between wheels
33 const float ODOM_ANGULAR_COEF_4WD = 1.0 / (ODOM_AXLE_TRACK_4WD * 2.54 / 100); // rad per meter
34 const float ODOM_TRACTION_FACTOR_4WD = 0.9;
35 // high speed cmd_vel to motor command 4wd constants
38 const float MOTOR_SPEED_CW_TURN_COEF = 1.0;
39 
40 // 2wd constants__________
41 // odometry 2wd constants
42 const float ODOM_ENCODER_COEF_2WD = 182.405; // r_track*2*pi*(2.54/100)/96*1e6/45
43 const float ODOM_AXLE_TRACK_2WD = 14.375; // distance between wheels
44 const float ODOM_ANGULAR_COEF_2WD = 1.0 / (ODOM_AXLE_TRACK_2WD * 2.54 / 100); // rad per meter
45 const float ODOM_TRACTION_FACTOR_2WD = 0.9877;
46 // high speed cmd_vel to motor command 2wd constants
49 
50 // Velocity Controller Constants
51 const int CONTROLLER_DEADBAND_COMP = 0; // reduce MOTOR_DEADBAND by this amount
52 const int MAX_ACCEL_CUTOFF = 20; // m/s^2
53 
54 // general openrover_driver platform constants
55 // the rovers can only go fast enough to get an encoder reading down to ~50 so
56 // anything lower is most likely a stall condition being misread. Over 4000 is
57 // a rover moving slower than ~1mm/s which is essentially stopped.
58 const int ENCODER_MAX = 14000;
59 const int ENCODER_MIN = 40;
60 const int MOTOR_FLIPPER_COEF = 100;
61 
62 const int MOTOR_DEADBAND = 9;
63 const int MOTOR_NEUTRAL = 125;
64 const int MOTOR_SPEED_MAX = 250;
65 const int MOTOR_SPEED_MIN = 0;
66 const int MOTOR_DIFF_MAX = 200; // Max command difference between left and
67 
68 // Firmware parameters. Kept numbering from Firmware SDK-Protocol Documents_07-03-2018_1
69 // to maintain consistency. Some parameters are still a work in progress (WIP)
70 // as labeled below and so will return -1.
71 
72 const int i_REG_PWR_TOTAL_CURRENT = 0; // 5hz
73 const int i_REG_MOTOR_FB_RPM_LEFT = 2; // 5hz ------ WIP
74 const int i_REG_MOTOR_FB_RPM_RIGHT = 4; // 5hz ------ WIP
75 const int i_REG_FLIPPER_FB_POSITION_POT1 = 6; // 5hz
76 const int i_REG_FLIPPER_FB_POSITION_POT2 = 8; // 5hz
77 
78 const int i_REG_MOTOR_FB_CURRENT_LEFT = 10; // 5hz
79 const int i_REG_MOTOR_FB_CURRENT_RIGHT = 12; // 5hz
80 const int i_REG_MOTOR_FAULT_FLAG_LEFT = 18; // 1hz ------ WIP
81 const int i_REG_MOTOR_TEMP_LEFT = 20; // 1hz
82 const int i_REG_MOTOR_TEMP_RIGHT = 22; // 1hz
83 
84 const int i_REG_POWER_BAT_VOLTAGE_A = 24; // 1hz
85 const int i_REG_POWER_BAT_VOLTAGE_B = 26; // 1hz
86 const int i_ENCODER_INTERVAL_MOTOR_LEFT = 28; // 10hz
87 const int i_ENCODER_INTERVAL_MOTOR_RIGHT = 30; // 10hz
88 const int i_ENCODER_INTERVAL_MOTOR_FLIPPER = 32; // 10hz ------ WIP
89 
90 const int i_REG_ROBOT_REL_SOC_A = 34; // 1hz ------ WIP
91 const int i_REG_ROBOT_REL_SOC_B = 36; // 1hz
92 const int i_REG_MOTOR_CHARGER_STATE = 38; // 5hz
93 const int i_BUILDNO = 40; // 1hz
94 const int i_REG_POWER_A_CURRENT = 42; // 5hz
95 
96 const int i_REG_POWER_B_CURRENT = 44; // 5hz
97 const int i_REG_MOTOR_FLIPPER_ANGLE = 46; // 5hz
98 
99 // const int i_to_computer_REG_MOTOR_SIDE_FAN_SPEED = 48; //5hz----WIP
100 // const int i_to_computer_REG_MOTOR_SLOW_SPEED = 50; //5hz ----WIP
101 
102 const int i_BATTERY_STATUS_A = 52;
103 const int i_BATTERY_STATUS_B = 54;
104 const int i_BATTERY_MODE_A = 56;
105 const int i_BATTERY_MODE_B = 58;
106 const int i_BATTERY_TEMP_A = 60;
107 const int i_BATTERY_TEMP_B = 62;
108 
109 const int i_BATTERY_VOLTAGE_A = 64;
110 const int i_BATTERY_VOLTAGE_B = 66;
111 const int i_BATTERY_CURRENT_A = 68;
112 const int i_BATTERY_CURRENT_B = 70;
113 
114 const int ROBOT_DATA_INDEX_FAST[] = {
116  //, i_ENCODER_INTERVAL_MOTOR_FLIPPER ----WIP //10hz
117  i_REG_MOTOR_FB_RPM_LEFT, i_REG_MOTOR_FB_RPM_RIGHT
118 };
119 
120 const int ROBOT_DATA_INDEX_MEDIUM[] = {
122  // i_REG_MOTOR_FB_RPM_LEFT,i_REG_MOTOR_FB_RPM_RIGHT, ----WIP
125  i_REG_MOTOR_FLIPPER_ANGLE, i_BATTERY_CURRENT_A, i_BATTERY_CURRENT_B
126  // i_to_computer_REG_MOTOR_SIDE_FAN_SPEED, i_to_computer_REG_MOTOR_SLOW_SPEED ----WIP
127 };
128 
129 const int ROBOT_DATA_INDEX_SLOW[] = {
130  // i_REG_MOTOR_FAULT_FLAG_LEFT, ----WIP
136 };
137 
138 const int FAST_SIZE = sizeof(ROBOT_DATA_INDEX_FAST) / sizeof(ROBOT_DATA_INDEX_FAST[0]);
139 const int MEDIUM_SIZE = sizeof(ROBOT_DATA_INDEX_MEDIUM) / sizeof(ROBOT_DATA_INDEX_MEDIUM[0]);
140 const int SLOW_SIZE = sizeof(ROBOT_DATA_INDEX_SLOW) / sizeof(ROBOT_DATA_INDEX_SLOW[0]);
141 
142 struct PidGains
143 {
144  double Kp;
145  double Ki;
146  double Kd;
147 
148  PidGains(float p, float i, float d) : Kp(p), Ki(i), Kd(d)
149  {
150  }
151 
152 };
153 
154 }
PidGains(float p, float i, float d)
Definition: constants.hpp:148
const int i_REG_MOTOR_FB_CURRENT_LEFT
Definition: constants.hpp:78
const int i_BATTERY_VOLTAGE_B
Definition: constants.hpp:110
const int i_REG_MOTOR_FLIPPER_ANGLE
Definition: constants.hpp:97
const int MOTOR_SPEED_ANGULAR_COEF_4WD_HS
Definition: constants.hpp:37
const int MOTOR_SPEED_LINEAR_COEF_F_HS
Definition: constants.hpp:26
const int LOOP_RATE
Definition: constants.hpp:17
const float ODOM_AXLE_TRACK_F
Definition: constants.hpp:22
const int i_REG_MOTOR_TEMP_RIGHT
Definition: constants.hpp:82
const int i_REG_POWER_BAT_VOLTAGE_A
Definition: constants.hpp:84
const int i_ENCODER_INTERVAL_MOTOR_RIGHT
Definition: constants.hpp:87
const int MEDIUM_SIZE
Definition: constants.hpp:139
const int i_REG_ROBOT_REL_SOC_A
Definition: constants.hpp:90
const float ODOM_AXLE_TRACK_2WD
Definition: constants.hpp:43
const int i_REG_MOTOR_CHARGER_STATE
Definition: constants.hpp:92
const int i_BATTERY_VOLTAGE_A
Definition: constants.hpp:109
const float MOTOR_SPEED_CW_TURN_COEF
Definition: constants.hpp:38
const float ODOM_ENCODER_COEF_2WD
Definition: constants.hpp:42
const int i_BATTERY_MODE_A
Definition: constants.hpp:104
const float ODOM_ENCODER_COEF_F
Definition: constants.hpp:21
const int ENCODER_MIN
Definition: constants.hpp:59
const int i_ENCODER_INTERVAL_MOTOR_FLIPPER
Definition: constants.hpp:88
const float MOTOR_RPM_TO_MPS_RATIO
Definition: constants.hpp:10
const int MOTOR_SPEED_ANGULAR_COEF_F_HS
Definition: constants.hpp:27
const float ODOM_TRACTION_FACTOR_2WD
Definition: constants.hpp:45
const int i_REG_FLIPPER_FB_POSITION_POT2
Definition: constants.hpp:76
const int ROBOT_DATA_INDEX_FAST[]
Definition: constants.hpp:114
const float ODOM_ANGULAR_COEF_4WD
Definition: constants.hpp:33
const int i_REG_MOTOR_FAULT_FLAG_LEFT
Definition: constants.hpp:80
const int ENCODER_MAX
Definition: constants.hpp:58
const int i_BATTERY_CURRENT_B
Definition: constants.hpp:112
const int CONTROLLER_DEADBAND_COMP
Definition: constants.hpp:51
const int i_REG_FLIPPER_FB_POSITION_POT1
Definition: constants.hpp:75
const int MOTOR_SPEED_MAX
Definition: constants.hpp:64
const int SERIAL_OUT_PACKAGE_LENGTH
Definition: constants.hpp:15
const float ODOM_AXLE_TRACK_4WD
Definition: constants.hpp:32
const int MOTOR_FLIPPER_COEF
Definition: constants.hpp:60
const int FAST_SIZE
Definition: constants.hpp:138
const int i_BATTERY_MODE_B
Definition: constants.hpp:105
const int i_REG_POWER_B_CURRENT
Definition: constants.hpp:96
const int i_BATTERY_TEMP_A
Definition: constants.hpp:106
const int i_REG_ROBOT_REL_SOC_B
Definition: constants.hpp:91
const int MOTOR_NEUTRAL
Definition: constants.hpp:63
const int i_BATTERY_TEMP_B
Definition: constants.hpp:107
const int i_ENCODER_INTERVAL_MOTOR_LEFT
Definition: constants.hpp:86
const int SERIAL_IN_PACKAGE_LENGTH
Definition: constants.hpp:16
const int MOTOR_SPEED_ANGULAR_COEF_2WD_HS
Definition: constants.hpp:48
const int i_REG_POWER_BAT_VOLTAGE_B
Definition: constants.hpp:85
const int MAX_ACCEL_CUTOFF
Definition: constants.hpp:52
const int i_REG_MOTOR_FB_RPM_RIGHT
Definition: constants.hpp:74
const float ODOM_TRACTION_FACTOR_F
Definition: constants.hpp:24
const float MOTOR_RPM_TO_MPS_CFB
Definition: constants.hpp:11
const int i_BATTERY_STATUS_A
Definition: constants.hpp:102
const int i_REG_MOTOR_TEMP_LEFT
Definition: constants.hpp:81
const float ODOM_ENCODER_COEF_4WD
Definition: constants.hpp:31
const float WHEEL_TO_TRACK_RATIO
Definition: constants.hpp:12
const int MOTOR_SPEED_LINEAR_COEF_4WD_HS
Definition: constants.hpp:36
const int ROBOT_DATA_INDEX_SLOW[]
Definition: constants.hpp:129
const int ROBOT_DATA_INDEX_MEDIUM[]
Definition: constants.hpp:120
const int i_REG_PWR_TOTAL_CURRENT
Definition: constants.hpp:72
const int MOTOR_DIFF_MAX
Definition: constants.hpp:66
const float ODOM_ANGULAR_COEF_2WD
Definition: constants.hpp:44
const int SLOW_SIZE
Definition: constants.hpp:140
const int i_REG_POWER_A_CURRENT
Definition: constants.hpp:94
const int MOTOR_DEADBAND
Definition: constants.hpp:62
const float ODOM_TRACTION_FACTOR_4WD
Definition: constants.hpp:34
const int BUILD_NUMBER_WITH_GOOD_RPM_DATA
Definition: constants.hpp:7
const int i_REG_MOTOR_FB_CURRENT_RIGHT
Definition: constants.hpp:79
const int MOTOR_SPEED_MIN
Definition: constants.hpp:65
const float ODOM_ANGULAR_COEF_F
Definition: constants.hpp:23
const int i_REG_MOTOR_FB_RPM_LEFT
Definition: constants.hpp:73
const int MOTOR_SPEED_LINEAR_COEF_2WD_HS
Definition: constants.hpp:47
const int i_BATTERY_STATUS_B
Definition: constants.hpp:103
const unsigned char SERIAL_START_BYTE
Definition: constants.hpp:14
const int i_BATTERY_CURRENT_A
Definition: constants.hpp:111
const int i_BUILDNO
Definition: constants.hpp:93


rr_openrover_driver
Author(s): Jack Kilian
autogenerated on Mon Feb 28 2022 23:43:54