blob: 3b84c447c8dfd4a472f868d10a6e8d80feda89e3 [file] [log] [blame]
Comran Morshed6c6a0a92016-01-17 12:45:16 +00001#ifndef Y2016_CONSTANTS_H_
2#define Y2016_CONSTANTS_H_
Comran Morshed9a9948c2016-01-16 15:58:04 +00003
4#include <stdint.h>
5
Comran Morshed6c6a0a92016-01-17 12:45:16 +00006#include "frc971/control_loops/state_feedback_loop.h"
Austin Schuh2fc10fa2016-02-08 00:44:34 -08007#include "frc971/shifter_hall_effect.h"
8#include "frc971/constants.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +00009
Comran Morshed6c6a0a92016-01-17 12:45:16 +000010namespace y2016 {
Comran Morshed9a9948c2016-01-16 15:58:04 +000011namespace constants {
12
13using ::frc971::constants::ShifterHallEffect;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080014using ::frc971::constants::ZeroingConstants;
Comran Morshed9a9948c2016-01-16 15:58:04 +000015
16// Has all of the numbers that change for both robots and makes it easy to
17// retrieve the values for the current one.
18
19// Everything is in SI units (volts, radians, meters, seconds, etc).
20// Some of these values are related to the conversion between raw values
21// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
22
23// This structure contains current values for all of the things that change.
24struct Values {
Comran Morshed225f0b92016-02-10 20:34:27 +000025 // ///// Mutual constants between robots. /////
26 // TODO(constants): Update/check these with what we're using this year.
27 static const int kZeroingSampleSize = 200;
28
29 // The ratio from the encoder shaft to the drivetrain wheels.
30 static constexpr double kDrivetrainEncoderRatio =
Comran Morshed001c7c32016-02-15 21:04:55 +000031 (18.0 / 36.0) /*output reduction*/ * (30.0 / 44.0) /*encoder gears*/;
Comran Morshed225f0b92016-02-10 20:34:27 +000032
33 // The gear ratios from motor shafts to the drivetrain wheels for high and low
34 // gear.
Comran Morshed001c7c32016-02-15 21:04:55 +000035 static constexpr double kLowGearRatio =
36 14.0 / 48.0 * 18.0 / 60.0 * 18.0 / 36.0;
37 static constexpr double kHighGearRatio =
38 14.0 / 48.0 * 28.0 / 50.0 * 18.0 / 36.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000039
Comran Morshed1b3290d2016-02-14 16:35:51 +000040 static constexpr double kTurnWidth = 0.601; // Robot width.
Comran Morshed225f0b92016-02-10 20:34:27 +000041
42 // Ratios for our subsystems.
43 static constexpr double kShooterEncoderRatio = 1.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000044 static constexpr double kIntakeEncoderRatio =
45 16.0 / 48.0 * 18.0 / 72.0 * 14.0 / 64.0;
46 static constexpr double kShoulderEncoderRatio =
47 16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0;
48 static constexpr double kWristEncoderRatio =
49 16.0 / 48.0 * 18.0 / 64.0 * 14.0 / 54.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000050
Comran Morshed1b3290d2016-02-14 16:35:51 +000051 static constexpr double kIntakePotRatio = 16.0 / 48.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000052 static constexpr double kShoulderPotRatio = 16.0 / 58.0;
53 static constexpr double kWristPotRatio = 16.0 / 48.0;
54
55 // Difference in radians between index pulses.
Comran Morshed1b3290d2016-02-14 16:35:51 +000056 static constexpr double kIntakeEncoderIndexDifference =
57 2.0 * M_PI * kIntakeEncoderRatio;
58 static constexpr double kShoulderEncoderIndexDifference =
59 2.0 * M_PI * kShoulderEncoderRatio;
60 static constexpr double kWristEncoderIndexDifference =
61 2.0 * M_PI * kWristEncoderRatio;
Comran Morshed225f0b92016-02-10 20:34:27 +000062
63 // Subsystem motion ranges, in whatever units that their respective queues say
64 // the use.
Brian Silvermanebca77a2016-02-14 22:14:00 -050065 static constexpr ::frc971::constants::Range kIntakeRange{-0.270, 2.0, -0.200,
66 1.9};
67 static constexpr ::frc971::constants::Range kShoulderRange{-0.050, 2.0, 0.000,
68 1.9};
Philipp Schrader9fa521a2016-02-16 00:13:33 +000069 static constexpr ::frc971::constants::Range kWristRange{-2.0, 2.0, -1.9, 1.9};
Comran Morshed225f0b92016-02-10 20:34:27 +000070
71 // ///// Dynamic constants. /////
72 double drivetrain_max_speed;
73
Austin Schuh2fc10fa2016-02-08 00:44:34 -080074 struct Intake {
Comran Morshed225f0b92016-02-10 20:34:27 +000075 double pot_offset;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080076 ZeroingConstants zeroing;
77 };
78 Intake intake;
79
80 struct Shoulder {
Comran Morshed225f0b92016-02-10 20:34:27 +000081 double pot_offset;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080082 ZeroingConstants zeroing;
83 };
84 Shoulder shoulder;
85
86 struct Wrist {
Comran Morshed225f0b92016-02-10 20:34:27 +000087 double pot_offset;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080088 ZeroingConstants zeroing;
89 };
90 Wrist wrist;
Comran Morshed9a9948c2016-01-16 15:58:04 +000091};
92
93// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
94// returns a reference to it.
95const Values &GetValues();
96
97// Creates Values instances for each team number it is called with and returns
98// them.
99const Values &GetValuesForTeam(uint16_t team_number);
100
101} // namespace constants
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000102} // namespace y2016
Comran Morshed9a9948c2016-01-16 15:58:04 +0000103
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000104#endif // Y2016_CONSTANTS_H_