blob: 4b181ebb7e5e295175ec2bfc14cfb647470e6374 [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
Brian Silvermanc8efb5e2014-02-18 21:03:24 -080037const ShifterHallEffect kPracticeLeftDriveShifter{5, 0, 0.60,
Brian Silverman6eb51f12013-11-02 14:39:01 -070038 0.47};
Brian Silvermanc8efb5e2014-02-18 21:03:24 -080039const ShifterHallEffect kPracticeRightDriveShifter{5, 0, 0.62,
Brian Silverman6eb51f12013-11-02 14:39:01 -070040 0.55};
Austin Schuhbe1401f2014-02-18 03:18:41 -080041const double shooter_zeroing_off_speed = 0.0;
Austin Schuh06cbbf12014-02-22 02:07:31 -080042const double shooter_zeroing_speed = 0.05;
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
Austin Schuh06cbbf12014-02-22 02:07:31 -0800124 {-0.001042, 0.294084, -0.001935, 0.303460, 0.0138401,
125 {-0.002, 0.000446, -0.002, 0.000446},
126 {-0.002, 0.009078, -0.002, 0.009078},
127 {0.003869, 0.026194, 0.003869, 0.026194},
Austin Schuh30537882014-02-18 01:07:23 -0800128 shooter_zeroing_off_speed,
129 shooter_zeroing_speed
Austin Schuh60c56662014-02-17 14:37:19 -0800130 },
Austin Schuh01c652b2014-02-21 23:13:42 -0800131 {0.400000,
132 0.200000,
Austin Schuh54e2e6c2014-02-21 22:58:53 -0800133 0.000000,
134 -0.762218,
135 0.912207,
136 -0.362218,
137 0.512207,
138 {-1.682379, 1.043334, -1.282379, 0.643334, {-1.7, -1.544662, -1.7, -1.547616}, {-0.130218, -0.019771, -0.132036, -0.018862}, {0.935842, 1.1, 0.932660, 1.1}},
139 {-1.225821, 1.553752, -0.825821, 1.153752, {-1.3, -1.088331, -1.3, -1.088331}, {-0.134536, -0.018408, -0.136127, -0.019771}, {1.447396, 1.6, 1.443987, 1.6}},
140 0.020000, // claw_unimportant_epsilon
141 -0.200000, // start_fine_tune_pos
142 4.000000,
Austin Schuhd27931c2014-02-16 19:18:20 -0800143 }
Brian Silverman756f9ff2014-01-17 23:40:23 -0800144 };
Brian Silverman431500a2013-10-28 19:50:15 -0700145 break;
146 default:
147 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
148 }
149}
150
151} // namespace
152
153const Values &GetValues() {
154 static ::aos::Once<const Values> once(DoGetValues);
155 return *once.Get();
156}
157
158} // namespace constants
159} // namespace frc971