blob: ba1690261b8ef4229c7c1f21255ca2f9cc25b0c1 [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 {
Austin Schuh2fc10fa2016-02-08 00:44:34 -080025 // Defines a range of motion for a subsystem.
26 // These are all absolute positions in scaled units.
27 struct Range {
28 double lower_hard;
29 double upper_hard;
30 double lower;
31 double upper;
32 };
33
Comran Morshed225f0b92016-02-10 20:34:27 +000034 // ///// Mutual constants between robots. /////
35 // TODO(constants): Update/check these with what we're using this year.
36 static const int kZeroingSampleSize = 200;
37
38 // The ratio from the encoder shaft to the drivetrain wheels.
39 static constexpr double kDrivetrainEncoderRatio =
40 (18.0 / 50.0) /*output reduction*/ * (56.0 / 30.0);
41
42 // The gear ratios from motor shafts to the drivetrain wheels for high and low
43 // gear.
44 static constexpr double kLowGearRatio = 18.0 / 60.0 * 18.0 / 50.0;
45 static constexpr double kHighGearRatio = 28.0 / 50.0 * 18.0 / 50.0;
46
47 static constexpr double kTurnWidth = 25.0 / 100.0 * 2.54; // Robot width.
48
49 // Ratios for our subsystems.
50 static constexpr double kShooterEncoderRatio = 1.0;
51 static constexpr double kIntakeEncoderRatio = 16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0;
52 static constexpr double kShoulderEncoderRatio = 16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0;
53 static constexpr double kWristEncoderRatio = 16.0 / 48.0 * 18.0 / 64.0 * 14.0 / 54.0;
54
55 static constexpr double kIntakePotRatio = 16.0 / 58.0;
56 static constexpr double kShoulderPotRatio = 16.0 / 58.0;
57 static constexpr double kWristPotRatio = 16.0 / 48.0;
58
59 // Difference in radians between index pulses.
60 static constexpr double kIntakeEncoderIndexDifference = 2.0 * M_PI * kIntakeEncoderRatio;
61 static constexpr double kShoulderEncoderIndexDifference = 2.0 * M_PI * kShoulderEncoderRatio;
62 static constexpr double kWristEncoderIndexDifference = 2.0 * M_PI * kWristEncoderRatio;
63
64 // Subsystem motion ranges, in whatever units that their respective queues say
65 // the use.
66 static constexpr Range kIntakeRange{-0.4, 2.0, -0.3, 1.9};
67 static constexpr Range kShoulderRange{-0.2, 2.0, -0.1, 1.9};
68 static constexpr Range kWristRange{-2.0, 2.0, -1.9, 1.0};
69
70 // ///// Dynamic constants. /////
71 double drivetrain_max_speed;
72
Austin Schuh2fc10fa2016-02-08 00:44:34 -080073 struct Intake {
Comran Morshed225f0b92016-02-10 20:34:27 +000074 double pot_offset;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080075 ZeroingConstants zeroing;
76 };
77 Intake intake;
78
79 struct Shoulder {
Comran Morshed225f0b92016-02-10 20:34:27 +000080 double pot_offset;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080081 ZeroingConstants zeroing;
82 };
83 Shoulder shoulder;
84
85 struct Wrist {
Comran Morshed225f0b92016-02-10 20:34:27 +000086 double pot_offset;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080087 ZeroingConstants zeroing;
88 };
89 Wrist wrist;
Comran Morshed9a9948c2016-01-16 15:58:04 +000090};
91
92// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
93// returns a reference to it.
94const Values &GetValues();
95
96// Creates Values instances for each team number it is called with and returns
97// them.
98const Values &GetValuesForTeam(uint16_t team_number);
99
100} // namespace constants
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000101} // namespace y2016
Comran Morshed9a9948c2016-01-16 15:58:04 +0000102
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000103#endif // Y2016_CONSTANTS_H_