Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 1 | #ifndef Y2016_CONSTANTS_H_ |
| 2 | #define Y2016_CONSTANTS_H_ |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 6 | #include "frc971/control_loops/state_feedback_loop.h" |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 7 | #include "frc971/shifter_hall_effect.h" |
| 8 | #include "frc971/constants.h" |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 9 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 10 | namespace y2016 { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 11 | namespace constants { |
| 12 | |
| 13 | using ::frc971::constants::ShifterHallEffect; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 14 | using ::frc971::constants::ZeroingConstants; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 15 | |
| 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. |
| 24 | struct Values { |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 25 | // 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 Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 34 | // ///// 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 = |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 40 | (18.0 / 36.0) /*output reduction*/ * (44.0 / 30.0); |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 41 | |
| 42 | // The gear ratios from motor shafts to the drivetrain wheels for high and low |
| 43 | // gear. |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 44 | static constexpr double kLowGearRatio = 18.0 / 60.0 * 18.0 / 36.0; |
| 45 | static constexpr double kHighGearRatio = 28.0 / 50.0 * 18.0 / 36.0; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 46 | |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 47 | static constexpr double kTurnWidth = 0.601; // Robot width. |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 48 | |
| 49 | // Ratios for our subsystems. |
| 50 | static constexpr double kShooterEncoderRatio = 1.0; |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 51 | static constexpr double kIntakeEncoderRatio = |
| 52 | 16.0 / 48.0 * 18.0 / 72.0 * 14.0 / 64.0; |
| 53 | static constexpr double kShoulderEncoderRatio = |
| 54 | 16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0; |
| 55 | static constexpr double kWristEncoderRatio = |
| 56 | 16.0 / 48.0 * 18.0 / 64.0 * 14.0 / 54.0; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 57 | |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 58 | static constexpr double kIntakePotRatio = 16.0 / 48.0; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 59 | static constexpr double kShoulderPotRatio = 16.0 / 58.0; |
| 60 | static constexpr double kWristPotRatio = 16.0 / 48.0; |
| 61 | |
| 62 | // Difference in radians between index pulses. |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 63 | static constexpr double kIntakeEncoderIndexDifference = |
| 64 | 2.0 * M_PI * kIntakeEncoderRatio; |
| 65 | static constexpr double kShoulderEncoderIndexDifference = |
| 66 | 2.0 * M_PI * kShoulderEncoderRatio; |
| 67 | static constexpr double kWristEncoderIndexDifference = |
| 68 | 2.0 * M_PI * kWristEncoderRatio; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 69 | |
| 70 | // Subsystem motion ranges, in whatever units that their respective queues say |
| 71 | // the use. |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame^] | 72 | static constexpr Range kIntakeRange{-0.270, 2.0, -0.200, 1.9}; |
| 73 | static constexpr Range kShoulderRange{-0.050, 2.0, 0.000, 1.9}; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 74 | static constexpr Range kWristRange{-2.0, 2.0, -1.9, 1.0}; |
| 75 | |
| 76 | // ///// Dynamic constants. ///// |
| 77 | double drivetrain_max_speed; |
| 78 | |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 79 | struct Intake { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 80 | double pot_offset; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 81 | ZeroingConstants zeroing; |
| 82 | }; |
| 83 | Intake intake; |
| 84 | |
| 85 | struct Shoulder { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 86 | double pot_offset; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 87 | ZeroingConstants zeroing; |
| 88 | }; |
| 89 | Shoulder shoulder; |
| 90 | |
| 91 | struct Wrist { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 92 | double pot_offset; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 93 | ZeroingConstants zeroing; |
| 94 | }; |
| 95 | Wrist wrist; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 99 | // returns a reference to it. |
| 100 | const Values &GetValues(); |
| 101 | |
| 102 | // Creates Values instances for each team number it is called with and returns |
| 103 | // them. |
| 104 | const Values &GetValuesForTeam(uint16_t team_number); |
| 105 | |
| 106 | } // namespace constants |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 107 | } // namespace y2016 |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 108 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 109 | #endif // Y2016_CONSTANTS_H_ |