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


rr_openrover_basic
Author(s): Jack Kilian
autogenerated on Fri Jan 17 2020 03:18:17