blob: 92df517d986560b17fc790f907055ca9f86e8cd3 [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
12// Has all of the numbers that change for both robots and makes it easy to
13// retrieve the values for the current one.
14
15// Everything is in SI units (volts, radians, meters, seconds, etc).
16// Some of these values are related to the conversion between raw values
17// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
18
19// This structure contains current values for all of the things that change.
20struct Values {
21 // ///// Mutual constants between robots. /////
22 // TODO(constants): Update/check these with what we're using this year.
Ed Jordan8683f432017-02-12 00:13:26 +000023
Tyler Chatow6107aba2017-01-22 01:39:40 +000024 static const int kZeroingSampleSize = 200;
25
26 // The ratio from the encoder shaft to the drivetrain wheels.
Tyler Chatow6107aba2017-01-22 01:39:40 +000027
Ed Jordan8683f432017-02-12 00:13:26 +000028 static constexpr double kDrivetrainEncoderRatio = 1.0 ;
29
30 // Ratios for our subsystems.
31 static constexpr double kShooterEncoderRatio = 32.0 / 48.0; //Encoder rotation to shooter wheel revolution
32 static constexpr double kIntakeEncoderRatio = (16 * 0.25) * (20 / 40) / (2.0 * numpy.pi) * 0.0254; //Encoder rotation per Meter(inch per radian) of movement
33 static constexpr double kIntakePotRatio = (16 * 0.25) / (2.0 * numpy.pi) * 0.0254; //Pot Rotation per Meter(inch per radian) of movement
34 static constexpr double kHoodEncoderRatio = 20.0 / 345.0; //Encoder rotation to Hood rotation
35 static constexpr double kHoodPotRatio = 20.0 / 345.0; //Pot Rotation per Hood rotation
36 static constexpr double kTurretEncoderRatio = 16.0 / 92.0; //Encoder rotation toTurret rotation
37 static constexpr double kTurretPotRatio = 16.0 / 92.0; //Pot Rotation per Turret rotation
38 static constexpr double kIndexerEncoderRatio = (18.0 / 36.0) * (12.0 / 84.0); //Encoder rotation to Inner indexer rotation
39
40 // Difference in radians between index pulses.
41 static constexpr double kIntakeEncoderIndexDifference =
42 2.0 * M_PI * kIntakeEncoderRatio;
43 static constexpr double kIndexerEncoderIndexDifference =
44 2.0 * M_PI * kIndexerEncoderRatio;
45 static constexpr double kTurretEncoderIndexDifference =
46 2.0 * M_PI * kTurretEncoderRatio;
47 static constexpr double kHoodEncoderIndexDifference =
48 2.0 * M_PI * kHoodEncoderRatio;
49
50 static constexpr ::frc971::constants::Range kIntakeRange{
51 // Lower hard stop in meters(inches)
52 -0.600 * 0.0254,
53 // Upper hard stop
54 8.655 * 0.0254,
55 // Lower soft stop
56 0.000,
57 // Upper soft stop
58 8.530 * 0.0254};
59 static constexpr ::frc971::constants::Range kHoodRange{
60 // Lower hard stop in radians
61 -1.0 / 345.0 * 2.0 * M_PI,
62 // Upper hard stop in radians
63 39.0 / 345.0 * 2.0 * M_PI,
64 // Lower soft stop in radians
65 0.0,
66 // Upper soft stop in radians
67 (39.0 - 1.0) / 345.0 * 2.0 * M_PI};
68 static constexpr ::frc971::constants::Range kTurretRange{
69 // Lower hard stop in radians
70 -460.0 / 2.0 * M_PI / 180.0,
71 // Upper hard stop in radians
72 460.0 / 2.0 * M_PI / 180.0,
73 // Lower soft stop in radians
74 -450.0 / 2.0 * M_PI / 180.0,
75 // Upper soft stop in radians
76 450.0 / 2.0 * M_PI / 180.0};
Tyler Chatow6107aba2017-01-22 01:39:40 +000077 // ///// Dynamic constants. /////
Ed Jordan8683f432017-02-12 00:13:26 +000078 double drivetrain_max_speed;
79
80 struct Intake {
81 double pot_offset;
82 ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
83 };
84 Intake intake;
85
86 struct Turret {
87 double pot_offset;
88 ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
89 };
90 Turret turret;
91
92 struct Hood {
93 double pot_offset;
94 ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
95 };
96 Hood hood;
97
Diana Vandenberg223703d2017-01-28 17:39:53 -080098 double down_error;
Ed Jordan8683f432017-02-12 00:13:26 +000099 const char *vision_name;
Tyler Chatow6107aba2017-01-22 01:39:40 +0000100};
101
102// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
103// returns a reference to it.
104const Values &GetValues();
105
106// Creates Values instances for each team number it is called with and returns
107// them.
108const Values &GetValuesForTeam(uint16_t team_number);
109
110} // namespace constants
111} // namespace y2017
112
113#endif // Y2017_CONSTANTS_H_