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