blob: 7541f7c05acf2d9ccf4e957bf1b5310879427322 [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;
46const double shooter_zeroing_speed=0.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{
55 kCompDrivetrainEncoderRatio,
56 kCompLowGearRatio,
57 kCompHighGearRatio,
joe3779d0c2014-02-15 19:41:22 -080058 shooter_voltage,
59 shooter_lower_physical_limit,
60 shooter_upper_physical_limit,
joe93778a62014-02-15 13:22:14 -080061 shooter_hall_effect_start_position,
62 shooter_zeroing_off_speed,
63 shooter_zeroing_speed,
joe3779d0c2014-02-15 19:41:22 -080064 position,
Brian Silverman756f9ff2014-01-17 23:40:23 -080065 kCompLeftDriveShifter,
66 kCompRightDriveShifter,
67 true,
68 control_loops::MakeVClutchDrivetrainLoop,
69 control_loops::MakeClutchDrivetrainLoop,
Austin Schuhf9286cd2014-02-11 00:51:09 -080070 0.5,
Austin Schuhcc0bf312014-02-09 00:39:29 -080071 0.1,
Austin Schuh3bb9a442014-02-02 16:01:45 -080072 0.0,
Austin Schuhcc0bf312014-02-09 00:39:29 -080073 1.57,
74
Austin Schuh4b7b5d02014-02-10 21:20:34 -080075 {0.0, 2.05, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
76 {0.0, 2.05, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
Ben Fredrickson9b388422014-02-13 06:15:31 +000077 0.02, // claw_unimportant_epsilon
78 50505.05, // start_fine_tune_pos
Brian Silverman756f9ff2014-01-17 23:40:23 -080079 };
Brian Silverman431500a2013-10-28 19:50:15 -070080 break;
81 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080082 return new Values{
83 kPracticeDrivetrainEncoderRatio,
84 kPracticeLowGearRatio,
85 kPracticeHighGearRatio,
joe3779d0c2014-02-15 19:41:22 -080086 shooter_voltage,
87 shooter_lower_physical_limit,
88 shooter_upper_physical_limit,
joe93778a62014-02-15 13:22:14 -080089 shooter_hall_effect_start_position,
90 shooter_zeroing_off_speed,
91 shooter_zeroing_speed,
joe3779d0c2014-02-15 19:41:22 -080092 position,
Brian Silverman756f9ff2014-01-17 23:40:23 -080093 kPracticeLeftDriveShifter,
94 kPracticeRightDriveShifter,
95 false,
96 control_loops::MakeVDogDrivetrainLoop,
97 control_loops::MakeDogDrivetrainLoop,
Austin Schuhf9286cd2014-02-11 00:51:09 -080098 0.5,
Austin Schuhcc0bf312014-02-09 00:39:29 -080099 0.1,
Austin Schuh3bb9a442014-02-02 16:01:45 -0800100 0.0,
Austin Schuhcc0bf312014-02-09 00:39:29 -0800101 1.57,
Austin Schuh4b7b5d02014-02-10 21:20:34 -0800102 {0.0, 2.05, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
103 {0.0, 2.05, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
Ben Fredrickson9b388422014-02-13 06:15:31 +0000104 0.02, // claw_unimportant_epsilon
105 50505.05, //start_fine_tune_pos
Brian Silverman756f9ff2014-01-17 23:40:23 -0800106 };
Brian Silverman431500a2013-10-28 19:50:15 -0700107 break;
108 default:
109 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
110 }
111}
112
113} // namespace
114
115const Values &GetValues() {
116 static ::aos::Once<const Values> once(DoGetValues);
117 return *once.Get();
118}
119
120} // namespace constants
121} // namespace frc971