Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 1 | #ifndef FRC971_CONSTANTS_H_ |
| 2 | #define FRC971_CONSTANTS_H_ |
| 3 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 6 | #include "frc971/control_loops/state_feedback_loop.h" |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame^] | 7 | #include "frc971/shifter_hall_effect.h" |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 8 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 9 | namespace frc971 { |
| 10 | namespace constants { |
| 11 | |
| 12 | // Has all of the numbers that change for both robots and makes it easy to |
| 13 | // retrieve the values for the current one. |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 14 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 15 | // This structure contains current values for all of the things that change. |
| 16 | struct Values { |
Brian Silverman | 2c79371 | 2014-02-16 19:32:32 -0800 | [diff] [blame] | 17 | // This is useful for representing the 2 sides of a hall effect sensor etc. |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 18 | struct AnglePair { |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 19 | // The angles for increasing values (posedge on lower, negedge on upper). |
| 20 | double lower_angle, upper_angle; |
| 21 | // The angles for decreasing values (negedge on lower, posedge on upper). |
| 22 | double lower_decreasing_angle, upper_decreasing_angle; |
Brian Silverman | 2c79371 | 2014-02-16 19:32:32 -0800 | [diff] [blame] | 23 | }; |
| 24 | |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 25 | // The ratio from the encoder shaft to the drivetrain wheels. |
| 26 | double drivetrain_encoder_ratio; |
| 27 | |
| 28 | // The gear ratios from motor shafts to the drivetrain wheels for high and low |
| 29 | // gear. |
| 30 | double low_gear_ratio; |
| 31 | double high_gear_ratio; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 32 | |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 33 | ShifterHallEffect left_drive, right_drive; |
| 34 | |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 35 | bool clutch_transmission; |
| 36 | |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 37 | double turn_width; |
| 38 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 39 | ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop; |
| 40 | ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop; |
Brian Silverman | dfdcd58 | 2014-02-16 20:50:09 -0800 | [diff] [blame] | 41 | |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 42 | struct Shooter { |
Ben Fredrickson | edf0e09 | 2014-02-16 10:46:50 +0000 | [diff] [blame] | 43 | double lower_limit; |
| 44 | double upper_limit; |
Austin Schuh | 3053788 | 2014-02-18 01:07:23 -0800 | [diff] [blame] | 45 | double lower_hard_limit; |
| 46 | double upper_hard_limit; |
| 47 | // If the plunger is further back than this position, it is safe for the |
| 48 | // latch to be down. Anything else would be considered a collision. |
| 49 | double latch_max_safe_position; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 50 | AnglePair plunger_back; |
| 51 | AnglePair pusher_distal; |
| 52 | AnglePair pusher_proximal; |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 53 | double zeroing_speed; |
Austin Schuh | 6b42860 | 2014-02-22 21:02:00 -0800 | [diff] [blame] | 54 | double unload_speed; |
Ben Fredrickson | edf0e09 | 2014-02-16 10:46:50 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 57 | Shooter shooter; |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 58 | |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 59 | struct Claws { |
| 60 | double claw_zeroing_off_speed; |
| 61 | double claw_zeroing_speed; |
| 62 | double claw_zeroing_separation; |
Austin Schuh | cc0bf31 | 2014-02-09 00:39:29 -0800 | [diff] [blame] | 63 | |
Brian Silverman | 7c021c4 | 2014-02-17 15:15:56 -0800 | [diff] [blame] | 64 | // claw separation that would be considered a collision |
Austin Schuh | 069143b | 2014-02-17 02:46:26 -0800 | [diff] [blame] | 65 | double claw_min_separation; |
| 66 | double claw_max_separation; |
Austin Schuh | cc0bf31 | 2014-02-09 00:39:29 -0800 | [diff] [blame] | 67 | |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 68 | // We should never get closer/farther than these. |
| 69 | double soft_min_separation; |
| 70 | double soft_max_separation; |
| 71 | |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 72 | // Three hall effects are known as front, calib and back |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 73 | typedef Values::AnglePair AnglePair; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 74 | |
| 75 | struct Claw { |
| 76 | double lower_hard_limit; |
| 77 | double upper_hard_limit; |
| 78 | double lower_limit; |
| 79 | double upper_limit; |
| 80 | AnglePair front; |
| 81 | AnglePair calibration; |
| 82 | AnglePair back; |
| 83 | }; |
| 84 | |
| 85 | Claw upper_claw; |
| 86 | Claw lower_claw; |
| 87 | |
| 88 | double claw_unimportant_epsilon; |
| 89 | double start_fine_tune_pos; |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 90 | double max_zeroing_voltage; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 91 | }; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 92 | Claws claw; |
James Kuszmaul | 9ead1de | 2014-02-28 21:24:39 -0800 | [diff] [blame] | 93 | |
| 94 | // Has all the constants for the ShootAction class. |
| 95 | struct ShooterAction { |
| 96 | // Minimum separation required between the claws in order to be able to |
| 97 | // shoot. |
| 98 | double claw_shooting_separation; |
| 99 | |
| 100 | // Goal to send to the claw when opening it up in preparation for shooting; |
| 101 | // should be larger than claw_shooting_separation so that we can shoot |
| 102 | // promptly. |
| 103 | double claw_separation_goal; |
| 104 | }; |
| 105 | ShooterAction shooter_action; |
Ben Fredrickson | 890c3fe | 2014-03-02 00:15:16 +0000 | [diff] [blame] | 106 | double drivetrain_done_distance; |
| 107 | double drivetrain_max_speed; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 110 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 111 | // returns a reference to it. |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 112 | const Values &GetValues(); |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 113 | |
| 114 | // Creates Values instances for each team number it is called with and returns |
| 115 | // them. |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 116 | const Values &GetValuesForTeam(uint16_t team_number); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 117 | |
| 118 | } // namespace constants |
| 119 | } // namespace frc971 |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 120 | |
| 121 | #endif // FRC971_CONSTANTS_H_ |