Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 1 | #ifndef FRC971_CONSTANTS_H_ |
| 2 | #define FRC971_CONSTANTS_H_ |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 3 | #include <stdint.h> |
| 4 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 5 | #include "frc971/control_loops/state_feedback_loop.h" |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 6 | #include "frc971/shifter_hall_effect.h" |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 7 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 8 | namespace frc971 { |
| 9 | namespace constants { |
| 10 | |
| 11 | // Has all of the numbers that change for both robots and makes it easy to |
| 12 | // retrieve the values for the current one. |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 13 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 14 | // This structure contains current values for all of the things that change. |
| 15 | struct Values { |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 16 | // Drivetrain Values ///// |
Brian Silverman | 2c79371 | 2014-02-16 19:32:32 -0800 | [diff] [blame] | 17 | |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 18 | // The ratio from the encoder shaft to the drivetrain wheels. |
| 19 | double drivetrain_encoder_ratio; |
| 20 | |
| 21 | // The gear ratios from motor shafts to the drivetrain wheels for high and low |
| 22 | // gear. |
| 23 | double low_gear_ratio; |
| 24 | double high_gear_ratio; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 25 | ShifterHallEffect left_drive, right_drive; |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 26 | bool clutch_transmission; |
| 27 | |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 28 | double turn_width; |
| 29 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 30 | ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop; |
| 31 | ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop; |
Brian Silverman | dfdcd58 | 2014-02-16 20:50:09 -0800 | [diff] [blame] | 32 | |
Ben Fredrickson | 890c3fe | 2014-03-02 00:15:16 +0000 | [diff] [blame] | 33 | double drivetrain_done_distance; |
| 34 | double drivetrain_max_speed; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 35 | |
| 36 | |
| 37 | // Superstructure Values ///// |
| 38 | |
| 39 | struct ZeroingConstants { |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame^] | 40 | // The number of samples in the moving average filter. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 41 | int average_filter_size; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame^] | 42 | // The difference in SI units between two index pulses. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 43 | double index_difference; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame^] | 44 | // The absolute position in SI units of one of the index pulses. |
| 45 | double measured_index_position; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | ZeroingConstants left_arm_zeroing_constants; |
| 49 | ZeroingConstants right_arm_zeroing_constants; |
| 50 | ZeroingConstants left_elevator_zeroing_constants; |
| 51 | ZeroingConstants right_elevator_zeroing_constants; |
| 52 | ZeroingConstants claw_zeroing_constants; |
| 53 | |
| 54 | // Defines a range of motion for a subsystem. |
| 55 | struct Range { |
| 56 | double lower_hard_limit; |
| 57 | double upper_hard_limit; |
| 58 | double lower_limit; |
| 59 | double upper_limit; |
| 60 | }; |
| 61 | |
| 62 | struct Claw { |
| 63 | Range wrist; |
| 64 | }; |
| 65 | Claw claw; |
| 66 | |
| 67 | struct Fridge { |
| 68 | Range elevator; |
| 69 | Range arm; |
| 70 | }; |
| 71 | Fridge fridge; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame^] | 72 | |
| 73 | double max_allowed_left_right_arm_difference; |
| 74 | double max_allowed_left_right_elevator_difference; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 77 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 78 | // returns a reference to it. |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 79 | const Values &GetValues(); |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 80 | |
| 81 | // Creates Values instances for each team number it is called with and returns |
| 82 | // them. |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 83 | const Values &GetValuesForTeam(uint16_t team_number); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 84 | |
| 85 | } // namespace constants |
| 86 | } // namespace frc971 |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 87 | |
| 88 | #endif // FRC971_CONSTANTS_H_ |