blob: 3cbb895a4e2fdf3c4d29cd3ee9b1578f32e2d395 [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;
Tyler Chatowf8f03112017-02-05 14:31:34 -080014using ::frc971::constants::PotAndIndexPulseZeroingConstants;
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 =
Austin Schuh9f77fd22016-02-21 02:53:58 -080031 (18.0 / 36.0) /*output reduction*/ * (44.0 / 30.0) /*encoder gears*/;
Comran Morshed225f0b92016-02-10 20:34:27 +000032
Comran Morshed225f0b92016-02-10 20:34:27 +000033 // Ratios for our subsystems.
34 static constexpr double kShooterEncoderRatio = 1.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000035 static constexpr double kIntakeEncoderRatio =
Campbell Crowley3b6977e2016-08-07 16:27:03 -070036 14.0 / 64.0 * 18.0 / 72.0 * 16.0 / 48.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000037 static constexpr double kShoulderEncoderRatio =
Campbell Crowley3b6977e2016-08-07 16:27:03 -070038 14.0 / 64.0 * 18.0 / 72.0 * 12.0 / 42.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000039 static constexpr double kWristEncoderRatio =
Campbell Crowley3b6977e2016-08-07 16:27:03 -070040 14.0 / 54.0 * 18.0 / 64.0 * 16.0 / 48.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000041
Campbell Crowley3b6977e2016-08-07 16:27:03 -070042 static constexpr double kIntakePotRatio = 18.0 / 72.0 * 16.0 / 48.0;
43 static constexpr double kShoulderPotRatio = 12.0 / 42.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000044 static constexpr double kWristPotRatio = 16.0 / 48.0;
45
46 // Difference in radians between index pulses.
Comran Morshed1b3290d2016-02-14 16:35:51 +000047 static constexpr double kIntakeEncoderIndexDifference =
48 2.0 * M_PI * kIntakeEncoderRatio;
49 static constexpr double kShoulderEncoderIndexDifference =
50 2.0 * M_PI * kShoulderEncoderRatio;
51 static constexpr double kWristEncoderIndexDifference =
52 2.0 * M_PI * kWristEncoderRatio;
Comran Morshed225f0b92016-02-10 20:34:27 +000053
54 // Subsystem motion ranges, in whatever units that their respective queues say
55 // the use.
Austin Schuh6aeae0c2016-03-20 16:45:28 -070056 static constexpr ::frc971::constants::Range kIntakeRange{// Lower hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070057 -0.5,
Austin Schuh6aeae0c2016-03-20 16:45:28 -070058 // Upper hard stop
Adam Snaidera5aa3f92016-04-17 13:31:59 -070059 2.85 + 0.05,
Austin Schuh6aeae0c2016-03-20 16:45:28 -070060 // Lower soft stop
61 -0.300,
62 // Uppper soft stop
63 2.725};
Austin Schuh3480e932016-02-21 13:06:51 -080064 static constexpr ::frc971::constants::Range kShoulderRange{// Lower hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070065 -0.150,
Austin Schuh3480e932016-02-21 13:06:51 -080066 // Upper hard stop
67 2.8,
68 // Lower soft stop
Austin Schuh449966b2016-03-11 21:27:05 -080069 -0.010,
Austin Schuh3480e932016-02-21 13:06:51 -080070 // Uppper soft stop
71 2.0};
72 static constexpr ::frc971::constants::Range kWristRange{// Lower hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070073 -3.0,
Austin Schuh3480e932016-02-21 13:06:51 -080074 // Upper hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070075 3.0,
Austin Schuh3480e932016-02-21 13:06:51 -080076 // Lower soft stop
Austin Schuha3240bd2016-03-13 15:31:01 -070077 -2.6,
Austin Schuh3480e932016-02-21 13:06:51 -080078 // Uppper soft stop
Austin Schuha3240bd2016-03-13 15:31:01 -070079 2.6};
Comran Morshed225f0b92016-02-10 20:34:27 +000080
81 // ///// Dynamic constants. /////
82 double drivetrain_max_speed;
83
Austin Schuh2fc10fa2016-02-08 00:44:34 -080084 struct Intake {
Comran Morshed225f0b92016-02-10 20:34:27 +000085 double pot_offset;
Tyler Chatowf8f03112017-02-05 14:31:34 -080086 PotAndIndexPulseZeroingConstants zeroing;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080087 };
88 Intake intake;
89
90 struct Shoulder {
Comran Morshed225f0b92016-02-10 20:34:27 +000091 double pot_offset;
Tyler Chatowf8f03112017-02-05 14:31:34 -080092 PotAndIndexPulseZeroingConstants zeroing;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080093 };
94 Shoulder shoulder;
95
96 struct Wrist {
Comran Morshed225f0b92016-02-10 20:34:27 +000097 double pot_offset;
Tyler Chatowf8f03112017-02-05 14:31:34 -080098 PotAndIndexPulseZeroingConstants zeroing;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080099 };
100 Wrist wrist;
Brian Silverman2ccf8c52016-03-15 00:22:26 -0400101
Austin Schuh889fee82016-04-13 22:16:36 -0700102 const double down_error;
Brian Silverman2ccf8c52016-03-15 00:22:26 -0400103 const char *vision_name;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000104};
105
106// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
107// returns a reference to it.
108const Values &GetValues();
109
110// Creates Values instances for each team number it is called with and returns
111// them.
112const Values &GetValuesForTeam(uint16_t team_number);
113
114} // namespace constants
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000115} // namespace y2016
Comran Morshed9a9948c2016-01-16 15:58:04 +0000116
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000117#endif // Y2016_CONSTANTS_H_