blob: c3bf6815f2f4c9bc3fdda1f65465e2515541de65 [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
Tyler Chatowbf0609c2021-07-31 16:13:27 -07004#include <cstdint>
Comran Morshed9a9948c2016-01-16 15:58:04 +00005
Tyler Chatowbf0609c2021-07-31 16:13:27 -07006#include "frc971/constants.h"
Comran Morshed6c6a0a92016-01-17 12:45:16 +00007#include "frc971/control_loops/state_feedback_loop.h"
Austin Schuh2fc10fa2016-02-08 00:44:34 -08008#include "frc971/shifter_hall_effect.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +00009
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080010namespace y2016::constants {
Comran Morshed9a9948c2016-01-16 15:58:04 +000011
Tyler Chatowf8f03112017-02-05 14:31:34 -080012using ::frc971::constants::PotAndIndexPulseZeroingConstants;
Tyler Chatowbf0609c2021-07-31 16:13:27 -070013using ::frc971::constants::ShifterHallEffect;
Comran Morshed9a9948c2016-01-16 15:58:04 +000014
15// Has all of the numbers that change for both robots and makes it easy to
16// retrieve the values for the current one.
17
18// Everything is in SI units (volts, radians, meters, seconds, etc).
19// Some of these values are related to the conversion between raw values
20// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
21
22// This structure contains current values for all of the things that change.
23struct Values {
Comran Morshed225f0b92016-02-10 20:34:27 +000024 // ///// Mutual constants between robots. /////
25 // TODO(constants): Update/check these with what we're using this year.
26 static const int kZeroingSampleSize = 200;
27
28 // The ratio from the encoder shaft to the drivetrain wheels.
29 static constexpr double kDrivetrainEncoderRatio =
Austin Schuh9f77fd22016-02-21 02:53:58 -080030 (18.0 / 36.0) /*output reduction*/ * (44.0 / 30.0) /*encoder gears*/;
Comran Morshed225f0b92016-02-10 20:34:27 +000031
Comran Morshed225f0b92016-02-10 20:34:27 +000032 // Ratios for our subsystems.
33 static constexpr double kShooterEncoderRatio = 1.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000034 static constexpr double kIntakeEncoderRatio =
Campbell Crowley3b6977e2016-08-07 16:27:03 -070035 14.0 / 64.0 * 18.0 / 72.0 * 16.0 / 48.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000036 static constexpr double kShoulderEncoderRatio =
Campbell Crowley3b6977e2016-08-07 16:27:03 -070037 14.0 / 64.0 * 18.0 / 72.0 * 12.0 / 42.0;
Comran Morshed1b3290d2016-02-14 16:35:51 +000038 static constexpr double kWristEncoderRatio =
Campbell Crowley3b6977e2016-08-07 16:27:03 -070039 14.0 / 54.0 * 18.0 / 64.0 * 16.0 / 48.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000040
Campbell Crowley3b6977e2016-08-07 16:27:03 -070041 static constexpr double kIntakePotRatio = 18.0 / 72.0 * 16.0 / 48.0;
42 static constexpr double kShoulderPotRatio = 12.0 / 42.0;
Comran Morshed225f0b92016-02-10 20:34:27 +000043 static constexpr double kWristPotRatio = 16.0 / 48.0;
44
45 // Difference in radians between index pulses.
Comran Morshed1b3290d2016-02-14 16:35:51 +000046 static constexpr double kIntakeEncoderIndexDifference =
47 2.0 * M_PI * kIntakeEncoderRatio;
48 static constexpr double kShoulderEncoderIndexDifference =
49 2.0 * M_PI * kShoulderEncoderRatio;
50 static constexpr double kWristEncoderIndexDifference =
51 2.0 * M_PI * kWristEncoderRatio;
Comran Morshed225f0b92016-02-10 20:34:27 +000052
53 // Subsystem motion ranges, in whatever units that their respective queues say
54 // the use.
Austin Schuh6aeae0c2016-03-20 16:45:28 -070055 static constexpr ::frc971::constants::Range kIntakeRange{// Lower hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070056 -0.5,
Austin Schuh6aeae0c2016-03-20 16:45:28 -070057 // Upper hard stop
Adam Snaidera5aa3f92016-04-17 13:31:59 -070058 2.85 + 0.05,
Austin Schuh6aeae0c2016-03-20 16:45:28 -070059 // Lower soft stop
60 -0.300,
61 // Uppper soft stop
62 2.725};
Austin Schuh3480e932016-02-21 13:06:51 -080063 static constexpr ::frc971::constants::Range kShoulderRange{// Lower hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070064 -0.150,
Austin Schuh3480e932016-02-21 13:06:51 -080065 // Upper hard stop
66 2.8,
67 // Lower soft stop
Austin Schuh449966b2016-03-11 21:27:05 -080068 -0.010,
Austin Schuh3480e932016-02-21 13:06:51 -080069 // Uppper soft stop
70 2.0};
71 static constexpr ::frc971::constants::Range kWristRange{// Lower hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070072 -3.0,
Austin Schuh3480e932016-02-21 13:06:51 -080073 // Upper hard stop
Austin Schuhe54b9872016-05-01 12:29:17 -070074 3.0,
Austin Schuh3480e932016-02-21 13:06:51 -080075 // Lower soft stop
Austin Schuha3240bd2016-03-13 15:31:01 -070076 -2.6,
Austin Schuh3480e932016-02-21 13:06:51 -080077 // Uppper soft stop
Austin Schuha3240bd2016-03-13 15:31:01 -070078 2.6};
Comran Morshed225f0b92016-02-10 20:34:27 +000079
80 // ///// Dynamic constants. /////
81 double drivetrain_max_speed;
82
Austin Schuh2fc10fa2016-02-08 00:44:34 -080083 struct Intake {
Comran Morshed225f0b92016-02-10 20:34:27 +000084 double pot_offset;
Tyler Chatowf8f03112017-02-05 14:31:34 -080085 PotAndIndexPulseZeroingConstants zeroing;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080086 };
87 Intake intake;
88
89 struct Shoulder {
Comran Morshed225f0b92016-02-10 20:34:27 +000090 double pot_offset;
Tyler Chatowf8f03112017-02-05 14:31:34 -080091 PotAndIndexPulseZeroingConstants zeroing;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080092 };
93 Shoulder shoulder;
94
95 struct Wrist {
Comran Morshed225f0b92016-02-10 20:34:27 +000096 double pot_offset;
Tyler Chatowf8f03112017-02-05 14:31:34 -080097 PotAndIndexPulseZeroingConstants zeroing;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080098 };
99 Wrist wrist;
Brian Silverman2ccf8c52016-03-15 00:22:26 -0400100
Austin Schuh889fee82016-04-13 22:16:36 -0700101 const double down_error;
Brian Silverman2ccf8c52016-03-15 00:22:26 -0400102 const char *vision_name;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000103};
104
105// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
106// returns a reference to it.
107const Values &GetValues();
108
109// Creates Values instances for each team number it is called with and returns
110// them.
111const Values &GetValuesForTeam(uint16_t team_number);
112
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -0800113} // namespace y2016::constants
Comran Morshed9a9948c2016-01-16 15:58:04 +0000114
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000115#endif // Y2016_CONSTANTS_H_