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 | 5d712fc | 2015-02-15 03:39:31 -0500 | [diff] [blame] | 14 | // Everything is in SI units (volts, radians, meters, seconds, etc). |
| 15 | // Some of these values are related to the conversion between raw values |
| 16 | // (encoder counts, voltage, etc) to scaled units (radians, meters, etc). |
| 17 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 18 | // This structure contains current values for all of the things that change. |
| 19 | struct Values { |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 20 | // Drivetrain Values ///// |
Brian Silverman | 2c79371 | 2014-02-16 19:32:32 -0800 | [diff] [blame] | 21 | |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 22 | // The ratio from the encoder shaft to the drivetrain wheels. |
| 23 | double drivetrain_encoder_ratio; |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 24 | // The ratio from the encoder shaft to the arm joint. |
| 25 | double arm_encoder_ratio; |
| 26 | // The ratio from the pot shaft to the arm joint. |
| 27 | double arm_pot_ratio; |
| 28 | // The ratio from the encoder shaft to the elevator output pulley. |
| 29 | double elev_encoder_ratio; |
| 30 | // The ratio from the pot shaft to the elevator output pulley. |
| 31 | double elev_pot_ratio; |
| 32 | // How far the elevator moves (meters) per radian on the output pulley. |
| 33 | double elev_distance_per_radian; |
| 34 | // The ratio from the encoder shaft to the claw joint. |
| 35 | double claw_encoder_ratio; |
| 36 | // The ratio from the pot shaft to the claw joint. |
| 37 | double claw_pot_ratio; |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 38 | |
| 39 | // The gear ratios from motor shafts to the drivetrain wheels for high and low |
| 40 | // gear. |
| 41 | double low_gear_ratio; |
| 42 | double high_gear_ratio; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 43 | ShifterHallEffect left_drive, right_drive; |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 44 | bool clutch_transmission; |
| 45 | |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 46 | double turn_width; |
| 47 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 48 | ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop; |
| 49 | ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop; |
Brian Silverman | dfdcd58 | 2014-02-16 20:50:09 -0800 | [diff] [blame] | 50 | |
Ben Fredrickson | 890c3fe | 2014-03-02 00:15:16 +0000 | [diff] [blame] | 51 | double drivetrain_done_distance; |
| 52 | double drivetrain_max_speed; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 53 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 54 | // Superstructure Values ///// |
| 55 | |
| 56 | struct ZeroingConstants { |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 57 | // The number of samples in the moving average filter. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 58 | int average_filter_size; |
Brian Silverman | 5d712fc | 2015-02-15 03:39:31 -0500 | [diff] [blame] | 59 | // The difference in scaled units between two index pulses. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 60 | double index_difference; |
Brian Silverman | 5d712fc | 2015-02-15 03:39:31 -0500 | [diff] [blame] | 61 | // The absolute position in scaled units of one of the index pulses. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 62 | double measured_index_position; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 65 | // Defines a range of motion for a subsystem. |
Brian Silverman | 5d712fc | 2015-02-15 03:39:31 -0500 | [diff] [blame] | 66 | // These are all absolute positions in scaled units. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 67 | struct Range { |
| 68 | double lower_hard_limit; |
| 69 | double upper_hard_limit; |
| 70 | double lower_limit; |
| 71 | double upper_limit; |
| 72 | }; |
| 73 | |
| 74 | struct Claw { |
| 75 | Range wrist; |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 76 | ZeroingConstants zeroing; |
Brian Silverman | 5d712fc | 2015-02-15 03:39:31 -0500 | [diff] [blame] | 77 | // The value to add to potentiometer readings after they have been converted |
| 78 | // to radians so that the resulting value is 0 when the claw is at absolute |
| 79 | // 0 (horizontal straight out the front). |
| 80 | double potentiometer_offset; |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 81 | |
| 82 | // Time between sending commands to claw opening pistons and them reaching |
| 83 | // the new state. |
| 84 | double piston_switch_time; |
| 85 | // How far on either side we look for the index pulse before we give up. |
| 86 | double zeroing_range; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 87 | }; |
| 88 | Claw claw; |
| 89 | |
| 90 | struct Fridge { |
| 91 | Range elevator; |
| 92 | Range arm; |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 93 | |
| 94 | ZeroingConstants left_elev_zeroing; |
| 95 | ZeroingConstants right_elev_zeroing; |
| 96 | ZeroingConstants left_arm_zeroing; |
| 97 | ZeroingConstants right_arm_zeroing; |
Brian Silverman | 5d712fc | 2015-02-15 03:39:31 -0500 | [diff] [blame] | 98 | |
| 99 | // Values to add to scaled potentiometer readings so 0 lines up with the |
| 100 | // physical absolute 0. |
| 101 | double left_elevator_potentiometer_offset; |
| 102 | double right_elevator_potentiometer_offset; |
| 103 | double left_arm_potentiometer_offset; |
| 104 | double right_arm_potentiometer_offset; |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 105 | |
| 106 | // How high the elevator has to be before we start zeroing the arm. |
| 107 | double arm_zeroing_height; |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 108 | // The height at which the fridge should hang out by default. |
| 109 | double normal_height; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 110 | }; |
| 111 | Fridge fridge; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 112 | |
| 113 | double max_allowed_left_right_arm_difference; |
| 114 | double max_allowed_left_right_elevator_difference; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 115 | }; |
| 116 | |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 117 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 118 | // returns a reference to it. |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 119 | const Values &GetValues(); |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 120 | |
| 121 | // Creates Values instances for each team number it is called with and returns |
| 122 | // them. |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 123 | const Values &GetValuesForTeam(uint16_t team_number); |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 124 | |
| 125 | } // namespace constants |
| 126 | } // namespace frc971 |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 127 | |
| 128 | #endif // FRC971_CONSTANTS_H_ |