blob: 20fcb56720dd04ccc4deab049f1493ae51202580 [file] [log] [blame]
Tyler Chatow6107aba2017-01-22 01:39:40 +00001#ifndef Y2017_CONSTANTS_H_
2#define Y2017_CONSTANTS_H_
3
4#include <stdint.h>
Ed Jordan8683f432017-02-12 00:13:26 +00005#include <math.h>
6
7#include "frc971/constants.h"
Tyler Chatow6107aba2017-01-22 01:39:40 +00008
9namespace y2017 {
10namespace constants {
11
Brian Silvermandb8498a2017-02-11 17:16:09 -080012// Has all of our "constants", except the ones that come from other places. The
13// ones which change between robots are put together with a workable way to
14// retrieve the values for the current robot.
Tyler Chatow6107aba2017-01-22 01:39:40 +000015
16// Everything is in SI units (volts, radians, meters, seconds, etc).
17// Some of these values are related to the conversion between raw values
18// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
Brian Silvermandb8498a2017-02-11 17:16:09 -080019//
20// All ratios are from the encoder shaft to the output units.
Tyler Chatow6107aba2017-01-22 01:39:40 +000021
Tyler Chatow6107aba2017-01-22 01:39:40 +000022struct Values {
Tyler Chatow6107aba2017-01-22 01:39:40 +000023 // TODO(constants): Update/check these with what we're using this year.
Ed Jordan8683f432017-02-12 00:13:26 +000024
Ed Jordan8683f432017-02-12 00:13:26 +000025 struct Intake {
26 double pot_offset;
27 ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
28 };
Ed Jordan8683f432017-02-12 00:13:26 +000029
30 struct Turret {
31 double pot_offset;
32 ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
33 };
Ed Jordan8683f432017-02-12 00:13:26 +000034
35 struct Hood {
36 double pot_offset;
37 ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
38 };
Brian Silvermandb8498a2017-02-11 17:16:09 -080039
40 static const int kZeroingSampleSize = 200;
41
42 // TODO(Brian): This isn't all the way to the output yet.
43 static constexpr double kDrivetrainEncoderRatio = 1.0 ;
44
45 static constexpr double kShooterEncoderRatio = 32.0 / 48.0;
46
47 static constexpr double kIntakeEncoderRatio =
48 (16.0 * 0.25) * (20.0 / 40.0) / (2.0 * M_PI) * 0.0254;
49 static constexpr double kIntakePotRatio = (16 * 0.25) / (2.0 * M_PI) * 0.0254;
50 static constexpr double kIntakeEncoderIndexDifference =
51 2.0 * M_PI * kIntakeEncoderRatio;
52
53 static constexpr ::frc971::constants::Range kIntakeRange{
54 // Lower hard stop in meters (from inches).
55 -0.600 * 0.0254,
56 // Upper hard stop in meters (from inches).
57 8.655 * 0.0254,
58 // Lower soft stop in meters (from inches).
59 0.000,
60 // Upper soft stop in meters (from inches).
61 8.530 * 0.0254};
62
63 static constexpr double kHoodEncoderRatio = 20.0 / 345.0;
64 static constexpr double kHoodPotRatio = 20.0 / 345.0;
65 static constexpr double kHoodEncoderIndexDifference =
66 2.0 * M_PI * kHoodEncoderRatio;
67
68 static constexpr ::frc971::constants::Range kHoodRange{
69 // Lower hard stop in radians.
70 -1.0 / 345.0 * 2.0 * M_PI,
71 // Upper hard stop in radians.
72 39.0 / 345.0 * 2.0 * M_PI,
73 // Lower soft stop in radians.
74 0.0,
75 // Upper soft stop in radians.
76 (39.0 - 1.0) / 345.0 * 2.0 * M_PI};
77
78 static constexpr double kTurretEncoderRatio = 16.0 / 92.0;
79 static constexpr double kTurretPotRatio = 16.0 / 92.0;
80 static constexpr double kTurretEncoderIndexDifference =
81 2.0 * M_PI * kTurretEncoderRatio;
82
83 static constexpr ::frc971::constants::Range kTurretRange{
84 // Lower hard stop in radians.
85 -460.0 / 2.0 * M_PI / 180.0,
86 // Upper hard stop in radians.
87 460.0 / 2.0 * M_PI / 180.0,
88 // Lower soft stop in radians.
89 -450.0 / 2.0 * M_PI / 180.0,
90 // Upper soft stop in radians.
91 450.0 / 2.0 * M_PI / 180.0};
92
93 static constexpr double kIndexerEncoderRatio = (18.0 / 36.0) * (12.0 / 84.0);
94 static constexpr double kIndexerEncoderIndexDifference =
95 2.0 * M_PI * kIndexerEncoderRatio;
96
97 double drivetrain_max_speed;
98
99 Intake intake;
100
101 Turret turret;
102
Ed Jordan8683f432017-02-12 00:13:26 +0000103 Hood hood;
104
Diana Vandenberg223703d2017-01-28 17:39:53 -0800105 double down_error;
Ed Jordan8683f432017-02-12 00:13:26 +0000106 const char *vision_name;
Tyler Chatow6107aba2017-01-22 01:39:40 +0000107};
108
109// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
110// returns a reference to it.
111const Values &GetValues();
112
113// Creates Values instances for each team number it is called with and returns
114// them.
115const Values &GetValuesForTeam(uint16_t team_number);
116
117} // namespace constants
118} // namespace y2017
119
120#endif // Y2017_CONSTANTS_H_