blob: bbc1966203bf71706e85b954a346270be8804e3d [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};
41
Brian Silverman431500a2013-10-28 19:50:15 -070042const Values *DoGetValues() {
43 uint16_t team = ::aos::network::GetTeamNumber();
44 LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
45 switch (team) {
46 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080047 return new Values{
48 kCompDrivetrainEncoderRatio,
49 kCompLowGearRatio,
50 kCompHighGearRatio,
51 kCompLeftDriveShifter,
52 kCompRightDriveShifter,
53 true,
54 control_loops::MakeVClutchDrivetrainLoop,
55 control_loops::MakeClutchDrivetrainLoop,
Austin Schuhcc0bf312014-02-09 00:39:29 -080056 2.05,
57 2.05,
Austin Schuh3bb9a442014-02-02 16:01:45 -080058 0.0,
59 0.0,
Austin Schuhcc0bf312014-02-09 00:39:29 -080060 1.0,
61 0.1,
Austin Schuh3bb9a442014-02-02 16:01:45 -080062 0.0,
Austin Schuhcc0bf312014-02-09 00:39:29 -080063 1.57,
64
65 -0.1,
66 0.05,
67 1.0,
68 1.1,
69 2.0,
70 2.1,
71 -0.1,
72 0.05,
73 1.0,
74 1.1,
75 2.0,
76 2.1,
Brian Silverman756f9ff2014-01-17 23:40:23 -080077 };
Brian Silverman431500a2013-10-28 19:50:15 -070078 break;
79 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -080080 return new Values{
81 kPracticeDrivetrainEncoderRatio,
82 kPracticeLowGearRatio,
83 kPracticeHighGearRatio,
84 kPracticeLeftDriveShifter,
85 kPracticeRightDriveShifter,
86 false,
87 control_loops::MakeVDogDrivetrainLoop,
88 control_loops::MakeDogDrivetrainLoop,
Austin Schuhcc0bf312014-02-09 00:39:29 -080089 2.05,
90 2.05,
Austin Schuh3bb9a442014-02-02 16:01:45 -080091 0.0,
92 0.0,
Austin Schuhcc0bf312014-02-09 00:39:29 -080093 1.0,
94 0.1,
Austin Schuh3bb9a442014-02-02 16:01:45 -080095 0.0,
Austin Schuhcc0bf312014-02-09 00:39:29 -080096 1.57,
97
98 -0.1,
99 0.05,
100 1.0,
101 1.1,
102 2.0,
103 2.1,
104 -0.1,
105 0.05,
106 1.0,
107 1.1,
108 2.0,
109 2.1,
Brian Silverman756f9ff2014-01-17 23:40:23 -0800110 };
Brian Silverman431500a2013-10-28 19:50:15 -0700111 break;
112 default:
113 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
114 }
115}
116
117} // namespace
118
119const Values &GetValues() {
120 static ::aos::Once<const Values> once(DoGetValues);
121 return *once.Get();
122}
123
124} // namespace constants
125} // namespace frc971