blob: b17a7cbff672ad508123d33a6775e9c20dd97d76 [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_lower_limit=0.0;
42const double shooter_upper_limit=0.0;
43const double shooter_hall_effect_start_position=0.0;
44const double shooter_zeroing_off_speed=0.0;
45const double shooter_zeroing_speed=0.0;
46const double pos=0.0;
Brian Silverman6eb51f12013-11-02 14:39:01 -070047
Brian Silverman431500a2013-10-28 19:50:15 -070048const Values *DoGetValues() {
49 uint16_t team = ::aos::network::GetTeamNumber();
50 LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
51 switch (team) {
52 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080053 return new Values{
54 kCompDrivetrainEncoderRatio,
55 kCompLowGearRatio,
56 kCompHighGearRatio,
joe93778a62014-02-15 13:22:14 -080057 shooter_lower_limit,
58 shooter_upper_limit,
59 shooter_hall_effect_start_position,
60 shooter_zeroing_off_speed,
61 shooter_zeroing_speed,
62 pos,
Brian Silverman756f9ff2014-01-17 23:40:23 -080063 kCompLeftDriveShifter,
64 kCompRightDriveShifter,
65 true,
66 control_loops::MakeVClutchDrivetrainLoop,
67 control_loops::MakeClutchDrivetrainLoop,
68 };
Brian Silverman431500a2013-10-28 19:50:15 -070069 break;
70 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080071 return new Values{
72 kPracticeDrivetrainEncoderRatio,
73 kPracticeLowGearRatio,
74 kPracticeHighGearRatio,
joe93778a62014-02-15 13:22:14 -080075 shooter_lower_limit,
76 shooter_upper_limit,
77 shooter_hall_effect_start_position,
78 shooter_zeroing_off_speed,
79 shooter_zeroing_speed,
80 pos,
Brian Silverman756f9ff2014-01-17 23:40:23 -080081 kPracticeLeftDriveShifter,
82 kPracticeRightDriveShifter,
83 false,
84 control_loops::MakeVDogDrivetrainLoop,
85 control_loops::MakeDogDrivetrainLoop,
86 };
Brian Silverman431500a2013-10-28 19:50:15 -070087 break;
88 default:
89 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
90 }
91}
92
93} // namespace
94
95const Values &GetValues() {
96 static ::aos::Once<const Values> once(DoGetValues);
97 return *once.Get();
98}
99
100} // namespace constants
101} // namespace frc971