blob: be98d3192ce0fa73c40322707249fcef22d8302e [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) {
48 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080049 return new Values{
Austin Schuh288c8c32014-02-16 17:20:17 -080050 kCompDrivetrainEncoderRatio,
51 kCompLowGearRatio,
52 kCompHighGearRatio,
53 kCompLeftDriveShifter,
54 kCompRightDriveShifter,
55 true,
56 control_loops::MakeVClutchDrivetrainLoop,
57 control_loops::MakeClutchDrivetrainLoop,
Brian Silverman5911b402014-02-16 19:40:50 -080058 // ShooterLimits
59 // TODO(ben): make these real numbers
Austin Schuh30537882014-02-18 01:07:23 -080060 {-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
61 {-0.001778, 0.000762}, {-0.001778, 0.009906}, {0.006096, 0.026416},
62 shooter_zeroing_off_speed,
63 shooter_zeroing_speed
Austin Schuh60c56662014-02-17 14:37:19 -080064 },
Austin Schuhd27931c2014-02-16 19:18:20 -080065 {0.5,
66 0.1,
67 0.1,
68 0.0,
69 1.57,
70 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
71 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
72 0.01, // claw_unimportant_epsilon
73 0.9, // start_fine_tune_pos
Austin Schuh4cb047f2014-02-16 21:10:19 -080074 4.0,
Austin Schuhd27931c2014-02-16 19:18:20 -080075 }
Brian Silverman756f9ff2014-01-17 23:40:23 -080076 };
Brian Silverman431500a2013-10-28 19:50:15 -070077 break;
78 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080079 return new Values{
Austin Schuh288c8c32014-02-16 17:20:17 -080080 kPracticeDrivetrainEncoderRatio,
81 kPracticeLowGearRatio,
82 kPracticeHighGearRatio,
83 kPracticeLeftDriveShifter,
84 kPracticeRightDriveShifter,
85 false,
86 control_loops::MakeVDogDrivetrainLoop,
87 control_loops::MakeDogDrivetrainLoop,
Brian Silverman5911b402014-02-16 19:40:50 -080088 // ShooterLimits
89 // TODO(ben): make these real numbers
Austin Schuh30537882014-02-18 01:07:23 -080090 {-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
91 {-0.001778, 0.000762}, {-0.001778, 0.009906}, {0.006096, 0.026416},
92 shooter_zeroing_off_speed,
93 shooter_zeroing_speed
Austin Schuh60c56662014-02-17 14:37:19 -080094 },
Austin Schuhd27931c2014-02-16 19:18:20 -080095 {0.5,
96 0.2,
97 0.1,
98 0.0,
99 1.57,
Austin Schuhe7f90d12014-02-17 00:48:25 -0800100 // TODO(austin): Radians...
101 {-196.70, 121.42, 0.02, 2.02, {-196.92, -180.99}, {-15.17, -3.30}, {106.26, 129.55}},
102 {-142.96, 179.45, 0.02, 2.02, {-147.01, -127.93}, {-17.84, -5.39}, {167.75, 192.25}},
Austin Schuhd27931c2014-02-16 19:18:20 -0800103 0.01, // claw_unimportant_epsilon
104 0.9, // start_fine_tune_pos
Austin Schuh4cb047f2014-02-16 21:10:19 -0800105 4.0,
Austin Schuhd27931c2014-02-16 19:18:20 -0800106 }
Brian Silverman756f9ff2014-01-17 23:40:23 -0800107 };
Brian Silverman431500a2013-10-28 19:50:15 -0700108 break;
109 default:
110 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
111 }
112}
113
114} // namespace
115
116const Values &GetValues() {
117 static ::aos::Once<const Values> once(DoGetValues);
118 return *once.Get();
119}
120
121} // namespace constants
122} // namespace frc971