blob: 3bc82314ba21a2d4a532d60645704704df83bf37 [file] [log] [blame]
Brian Silverman431500a2013-10-28 19:50:15 -07001#include "frc971/constants.h"
2
3#include <math.h>
4#include <stdint.h>
5#include <inttypes.h>
6
7#include "aos/common/logging/logging.h"
8#include "aos/common/once.h"
9#include "aos/common/network/team_number.h"
10
Brian Silverman2c590c32013-11-04 18:08:54 -080011#include "frc971/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
12#include "frc971/control_loops/drivetrain/polydrivetrain_clutch_motor_plant.h"
13#include "frc971/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
14#include "frc971/control_loops/drivetrain/drivetrain_clutch_motor_plant.h"
15
Brian Silverman431500a2013-10-28 19:50:15 -070016#ifndef M_PI
17#define M_PI 3.14159265358979323846
18#endif
19
20namespace frc971 {
21namespace constants {
22namespace {
23
Brian Silverman1a6590d2013-11-04 14:46:46 -080024const double kCompDrivetrainEncoderRatio =
25 (15.0 / 50.0) /*output reduction*/ * (36.0 / 24.0) /*encoder gears*/;
26const double kCompLowGearRatio = 14.0 / 60.0 * 15.0 / 50.0;
27const double kCompHighGearRatio = 30.0 / 44.0 * 15.0 / 50.0;
Brian Silverman431500a2013-10-28 19:50:15 -070028
Brian Silverman1a6590d2013-11-04 14:46:46 -080029const double kPracticeDrivetrainEncoderRatio =
30 (17.0 / 50.0) /*output reduction*/ * (64.0 / 24.0) /*encoder gears*/;
31const double kPracticeLowGearRatio = 16.0 / 60.0 * 19.0 / 50.0;
32const double kPracticeHighGearRatio = 28.0 / 48.0 * 19.0 / 50.0;
33
Brian Silverman98e1ab62013-11-06 21:03:23 -080034const ShifterHallEffect kCompLeftDriveShifter{0.83, 2.32, 1.2, 1.0};
Brian Silverman1a6590d2013-11-04 14:46:46 -080035const ShifterHallEffect kCompRightDriveShifter{0.865, 2.375, 1.2, 1.0};
Brian Silverman6eb51f12013-11-02 14:39:01 -070036
37const ShifterHallEffect kPracticeLeftDriveShifter{2.082283, 0.834433, 0.60,
38 0.47};
39const ShifterHallEffect kPracticeRightDriveShifter{2.070124, 0.838993, 0.62,
40 0.55};
joe93778a62014-02-15 13:22:14 -080041const double shooter_zeroing_off_speed=0.0;
Ben Fredrickson22c93322014-02-17 05:56:33 +000042const double shooter_zeroing_speed=1.0;
Brian Silverman6eb51f12013-11-02 14:39:01 -070043
Brian Silverman431500a2013-10-28 19:50:15 -070044const Values *DoGetValues() {
45 uint16_t team = ::aos::network::GetTeamNumber();
46 LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
47 switch (team) {
Brian Silverman0d2b7cb2014-02-18 20:25:57 -080048 case 1: // for tests
49 return new Values{
50 kCompDrivetrainEncoderRatio,
51 kCompLowGearRatio,
52 kCompHighGearRatio,
53 kCompLeftDriveShifter,
54 kCompRightDriveShifter,
55 true,
56 control_loops::MakeVClutchDrivetrainLoop,
57 control_loops::MakeClutchDrivetrainLoop,
58 // ShooterLimits
59 // TODO(ben): make these real numbers
60 {-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
61 {-0.001778, 0.000762, 0, 0}, {-0.001778, 0.009906, 0, 0}, {0.006096, 0.026416, 0, 0},
62 shooter_zeroing_off_speed,
63 shooter_zeroing_speed
64 },
65 {0.5,
66 0.1,
67 0.1,
68 0.0,
69 1.57,
70 0,
71 0,
72 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
73 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
74 0.01, // claw_unimportant_epsilon
75 0.9, // start_fine_tune_pos
76 4.0,
77 }
78 };
79 break;
Brian Silverman431500a2013-10-28 19:50:15 -070080 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080081 return new Values{
Austin Schuh288c8c32014-02-16 17:20:17 -080082 kCompDrivetrainEncoderRatio,
83 kCompLowGearRatio,
84 kCompHighGearRatio,
85 kCompLeftDriveShifter,
86 kCompRightDriveShifter,
87 true,
88 control_loops::MakeVClutchDrivetrainLoop,
89 control_loops::MakeClutchDrivetrainLoop,
Brian Silverman5911b402014-02-16 19:40:50 -080090 // ShooterLimits
91 // TODO(ben): make these real numbers
Austin Schuh30537882014-02-18 01:07:23 -080092 {-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -080093 {-0.001778, 0.000762, 0, 0}, {-0.001778, 0.009906, 0, 0}, {0.006096, 0.026416, 0, 0},
Austin Schuh30537882014-02-18 01:07:23 -080094 shooter_zeroing_off_speed,
95 shooter_zeroing_speed
Austin Schuh60c56662014-02-17 14:37:19 -080096 },
Austin Schuhd27931c2014-02-16 19:18:20 -080097 {0.5,
98 0.1,
99 0.1,
100 0.0,
101 1.57,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800102 0,
103 0,
104 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
105 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
Austin Schuhd27931c2014-02-16 19:18:20 -0800106 0.01, // claw_unimportant_epsilon
107 0.9, // start_fine_tune_pos
Austin Schuh4cb047f2014-02-16 21:10:19 -0800108 4.0,
Austin Schuhd27931c2014-02-16 19:18:20 -0800109 }
Brian Silverman756f9ff2014-01-17 23:40:23 -0800110 };
Brian Silverman431500a2013-10-28 19:50:15 -0700111 break;
112 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -0800113 return new Values{
Austin Schuh288c8c32014-02-16 17:20:17 -0800114 kPracticeDrivetrainEncoderRatio,
115 kPracticeLowGearRatio,
116 kPracticeHighGearRatio,
117 kPracticeLeftDriveShifter,
118 kPracticeRightDriveShifter,
119 false,
120 control_loops::MakeVDogDrivetrainLoop,
121 control_loops::MakeDogDrivetrainLoop,
Brian Silverman5911b402014-02-16 19:40:50 -0800122 // ShooterLimits
123 // TODO(ben): make these real numbers
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800124 {-0.000446, 0.300038, -0.001, 0.304354,
125 0.014436,
126 {-2, 0.001786, 0.001786, -2}, {-2, -0.000446, -2, 0.026938}, {0.006096, 0.026416, 0, 0},
Austin Schuh30537882014-02-18 01:07:23 -0800127 shooter_zeroing_off_speed,
128 shooter_zeroing_speed
Austin Schuh60c56662014-02-17 14:37:19 -0800129 },
Austin Schuhd27931c2014-02-16 19:18:20 -0800130 {0.5,
131 0.2,
132 0.1,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800133 -0.446558,
134 0.90675,
135 -0.39110,
136 0.843349,
137#if 0
138 separations (top, bottom)
139 hard min position:-0.253845, position:-0.001136,
140 soft min position:-0.244528, position:-0.047269,
141 soft max position:0.526326, position:-0.510872,
142 hard max position:0.517917, position:-0.582685,
143#endif
144 {-1.62102, 1.039699, -1.606248, 0.989702, {-1.65, -1.546252, -1.65, -1.548752}, {-0.13249, -0.02113, -0.134763, -0.021589}, {0.934024, 1.05, 0.92970, 1.05}},
145 {-1.420352, 1.348313, -1.161281, 1.264001, {-1.45, -1.283771, -1.45, -1.28468}, {-0.332476, -0.214984, -0.334294, -0.217029}, {1.248547, 1.37, 1.245366, 1.37}},
Austin Schuhd27931c2014-02-16 19:18:20 -0800146 0.01, // claw_unimportant_epsilon
147 0.9, // start_fine_tune_pos
Austin Schuh4cb047f2014-02-16 21:10:19 -0800148 4.0,
Austin Schuhd27931c2014-02-16 19:18:20 -0800149 }
Brian Silverman756f9ff2014-01-17 23:40:23 -0800150 };
Brian Silverman431500a2013-10-28 19:50:15 -0700151 break;
152 default:
153 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
154 }
155}
156
157} // namespace
158
159const Values &GetValues() {
160 static ::aos::Once<const Values> once(DoGetValues);
161 return *once.Get();
162}
163
164} // namespace constants
165} // namespace frc971