blob: 775196941aeb6de8fb185e76919f8724d8a932df [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};
joe3779d0c2014-02-15 19:41:22 -080041const double shooter_lower_physical_limit=0.0;
42const double shooter_upper_physical_limit=0.0;
43const double shooter_voltage=0.0;
joe93778a62014-02-15 13:22:14 -080044const double shooter_hall_effect_start_position=0.0;
45const double shooter_zeroing_off_speed=0.0;
Ben Fredrickson22c93322014-02-17 05:56:33 +000046const double shooter_zeroing_speed=1.0;
joe3779d0c2014-02-15 19:41:22 -080047const double position=0.0;
Brian Silverman6eb51f12013-11-02 14:39:01 -070048
Brian Silverman431500a2013-10-28 19:50:15 -070049const Values *DoGetValues() {
50 uint16_t team = ::aos::network::GetTeamNumber();
51 LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
52 switch (team) {
53 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080054 return new Values{
Austin Schuh288c8c32014-02-16 17:20:17 -080055 kCompDrivetrainEncoderRatio,
56 kCompLowGearRatio,
57 kCompHighGearRatio,
58 kCompLeftDriveShifter,
59 kCompRightDriveShifter,
60 true,
61 control_loops::MakeVClutchDrivetrainLoop,
62 control_loops::MakeClutchDrivetrainLoop,
Brian Silverman5911b402014-02-16 19:40:50 -080063 // ShooterLimits
64 // TODO(ben): make these real numbers
Brian Silverman2f8b72a2014-02-17 00:55:27 -080065 {0.0, 1.0, {-0.03, 0.02}, {-0.01, 0.04}, {0.02, 0.07}},
Brian Silverman2c793712014-02-16 19:32:32 -080066 shooter_voltage,
Brian Silverman5911b402014-02-16 19:40:50 -080067 // shooter_total_length
Brian Silverman6d342ac2014-02-17 00:50:27 -080068 1.0,
Brian Silverman2c793712014-02-16 19:32:32 -080069 shooter_hall_effect_start_position,
70 shooter_zeroing_off_speed,
71 shooter_zeroing_speed,
72 position,
Austin Schuhd27931c2014-02-16 19:18:20 -080073 {0.5,
74 0.1,
75 0.1,
76 0.0,
77 1.57,
78 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
79 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
80 0.01, // claw_unimportant_epsilon
81 0.9, // start_fine_tune_pos
Austin Schuh4cb047f2014-02-16 21:10:19 -080082 4.0,
Austin Schuhd27931c2014-02-16 19:18:20 -080083 }
Brian Silverman756f9ff2014-01-17 23:40:23 -080084 };
Brian Silverman431500a2013-10-28 19:50:15 -070085 break;
86 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080087 return new Values{
Austin Schuh288c8c32014-02-16 17:20:17 -080088 kPracticeDrivetrainEncoderRatio,
89 kPracticeLowGearRatio,
90 kPracticeHighGearRatio,
91 kPracticeLeftDriveShifter,
92 kPracticeRightDriveShifter,
93 false,
94 control_loops::MakeVDogDrivetrainLoop,
95 control_loops::MakeDogDrivetrainLoop,
Brian Silverman5911b402014-02-16 19:40:50 -080096 // ShooterLimits
97 // TODO(ben): make these real numbers
Brian Silverman2f8b72a2014-02-17 00:55:27 -080098 {0.0, 1.0, {-0.03, 0.02}, {-0.01, 0.04}, {0.02, 0.07}},
Brian Silverman2c793712014-02-16 19:32:32 -080099 shooter_voltage,
Brian Silverman5911b402014-02-16 19:40:50 -0800100 // shooter_total_length
Brian Silverman6d342ac2014-02-17 00:50:27 -0800101 1.0,
Brian Silverman2c793712014-02-16 19:32:32 -0800102 shooter_hall_effect_start_position,
103 shooter_zeroing_off_speed,
104 shooter_zeroing_speed,
105 position,
Austin Schuhd27931c2014-02-16 19:18:20 -0800106 {0.5,
107 0.2,
108 0.1,
109 0.0,
110 1.57,
111 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
112 {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
113 0.01, // claw_unimportant_epsilon
114 0.9, // start_fine_tune_pos
Austin Schuh4cb047f2014-02-16 21:10:19 -0800115 4.0,
Austin Schuhd27931c2014-02-16 19:18:20 -0800116 }
Brian Silverman756f9ff2014-01-17 23:40:23 -0800117 };
Brian Silverman431500a2013-10-28 19:50:15 -0700118 break;
119 default:
120 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
121 }
122}
123
124} // namespace
125
126const Values &GetValues() {
127 static ::aos::Once<const Values> once(DoGetValues);
128 return *once.Get();
129}
130
131} // namespace constants
132} // namespace frc971