blob: d66853b006bf4d942db42e983b0cb46d9a8a77e3 [file] [log] [blame]
Brian Silverman431500a2013-10-28 19:50:15 -07001#ifndef FRC971_CONSTANTS_H_
2#define FRC971_CONSTANTS_H_
brians343bc112013-02-10 01:53:46 +00003#include <stdint.h>
4
Brian Silverman2c590c32013-11-04 18:08:54 -08005#include "frc971/control_loops/state_feedback_loop.h"
Daniel Pettiaece37f2014-10-25 17:13:44 -07006#include "frc971/shifter_hall_effect.h"
Brian Silverman2c590c32013-11-04 18:08:54 -08007
brians343bc112013-02-10 01:53:46 +00008namespace frc971 {
9namespace 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.
brians343bc112013-02-10 01:53:46 +000013
Brian Silverman5d712fc2015-02-15 03:39:31 -050014// 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 Silverman431500a2013-10-28 19:50:15 -070018// This structure contains current values for all of the things that change.
19struct Values {
Comran Morshed79bd3db2015-02-07 14:51:13 +000020 // Drivetrain Values /////
Brian Silverman2c793712014-02-16 19:32:32 -080021
Brian Silverman1a6590d2013-11-04 14:46:46 -080022 // The ratio from the encoder shaft to the drivetrain wheels.
23 double drivetrain_encoder_ratio;
Daniel Pettia7827412015-02-13 20:55:57 -080024 // 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 Silverman1a6590d2013-11-04 14:46:46 -080038
Daniel Pettidfc90ba2015-02-17 21:42:15 -080039 // How tall a tote is in meters.
40 double tote_height;
41
Brian Silverman1a6590d2013-11-04 14:46:46 -080042 // The gear ratios from motor shafts to the drivetrain wheels for high and low
43 // gear.
44 double low_gear_ratio;
45 double high_gear_ratio;
Brian Silverman6eb51f12013-11-02 14:39:01 -070046 ShifterHallEffect left_drive, right_drive;
Brian Silverman1a6590d2013-11-04 14:46:46 -080047 bool clutch_transmission;
48
Brian Silvermanad9e0002014-04-13 14:55:57 -070049 double turn_width;
50
Brian Silverman2c590c32013-11-04 18:08:54 -080051 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
52 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
Brian Silvermandfdcd582014-02-16 20:50:09 -080053
Ben Fredrickson890c3fe2014-03-02 00:15:16 +000054 double drivetrain_done_distance;
55 double drivetrain_max_speed;
Comran Morshed79bd3db2015-02-07 14:51:13 +000056
Comran Morshed79bd3db2015-02-07 14:51:13 +000057 // Superstructure Values /////
58
59 struct ZeroingConstants {
Austin Schuh703b8d42015-02-01 14:56:34 -080060 // The number of samples in the moving average filter.
Comran Morshed79bd3db2015-02-07 14:51:13 +000061 int average_filter_size;
Brian Silverman5d712fc2015-02-15 03:39:31 -050062 // The difference in scaled units between two index pulses.
Comran Morshed79bd3db2015-02-07 14:51:13 +000063 double index_difference;
Brian Silverman5d712fc2015-02-15 03:39:31 -050064 // The absolute position in scaled units of one of the index pulses.
Austin Schuh703b8d42015-02-01 14:56:34 -080065 double measured_index_position;
Adam Snaider3cd11c52015-02-16 02:16:09 +000066 // Value between 0 and 1 which determines a fraction of the index_diff
67 // you want to use.
68 double allowable_encoder_error;
Comran Morshed79bd3db2015-02-07 14:51:13 +000069 };
70
Comran Morshed79bd3db2015-02-07 14:51:13 +000071 // Defines a range of motion for a subsystem.
Brian Silverman5d712fc2015-02-15 03:39:31 -050072 // These are all absolute positions in scaled units.
Comran Morshed79bd3db2015-02-07 14:51:13 +000073 struct Range {
74 double lower_hard_limit;
75 double upper_hard_limit;
76 double lower_limit;
77 double upper_limit;
78 };
79
80 struct Claw {
81 Range wrist;
Daniel Pettia7827412015-02-13 20:55:57 -080082 ZeroingConstants zeroing;
Brian Silverman5d712fc2015-02-15 03:39:31 -050083 // The value to add to potentiometer readings after they have been converted
84 // to radians so that the resulting value is 0 when the claw is at absolute
85 // 0 (horizontal straight out the front).
86 double potentiometer_offset;
Daniel Petti9cf68c82015-02-14 14:57:17 -080087
88 // Time between sending commands to claw opening pistons and them reaching
89 // the new state.
90 double piston_switch_time;
91 // How far on either side we look for the index pulse before we give up.
92 double zeroing_range;
Comran Morshed79bd3db2015-02-07 14:51:13 +000093 };
94 Claw claw;
95
96 struct Fridge {
97 Range elevator;
98 Range arm;
Daniel Pettia7827412015-02-13 20:55:57 -080099
100 ZeroingConstants left_elev_zeroing;
101 ZeroingConstants right_elev_zeroing;
102 ZeroingConstants left_arm_zeroing;
103 ZeroingConstants right_arm_zeroing;
Brian Silverman5d712fc2015-02-15 03:39:31 -0500104
105 // Values to add to scaled potentiometer readings so 0 lines up with the
106 // physical absolute 0.
107 double left_elevator_potentiometer_offset;
108 double right_elevator_potentiometer_offset;
109 double left_arm_potentiometer_offset;
110 double right_arm_potentiometer_offset;
Daniel Pettie1bb13e2015-02-17 13:59:15 -0800111
112 // How high the elevator has to be before we start zeroing the arm.
113 double arm_zeroing_height;
Comran Morshed79bd3db2015-02-07 14:51:13 +0000114 };
115 Fridge fridge;
Austin Schuh703b8d42015-02-01 14:56:34 -0800116
117 double max_allowed_left_right_arm_difference;
118 double max_allowed_left_right_elevator_difference;
Brian Silverman431500a2013-10-28 19:50:15 -0700119};
120
Brian Silverman0a151c92014-05-02 15:28:44 -0700121// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
122// returns a reference to it.
Brian Silverman431500a2013-10-28 19:50:15 -0700123const Values &GetValues();
Brian Silverman0a151c92014-05-02 15:28:44 -0700124
125// Creates Values instances for each team number it is called with and returns
126// them.
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000127const Values &GetValuesForTeam(uint16_t team_number);
brians343bc112013-02-10 01:53:46 +0000128
129} // namespace constants
130} // namespace frc971
Brian Silverman431500a2013-10-28 19:50:15 -0700131
132#endif // FRC971_CONSTANTS_H_