blob: 883e1b1befb81094704903273060d49c1043a8e5 [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 Silverman431500a2013-10-28 19:50:15 -070014// This structure contains current values for all of the things that change.
15struct Values {
Comran Morshed79bd3db2015-02-07 14:51:13 +000016 // Drivetrain Values /////
Brian Silverman2c793712014-02-16 19:32:32 -080017
Brian Silverman1a6590d2013-11-04 14:46:46 -080018 // The ratio from the encoder shaft to the drivetrain wheels.
19 double drivetrain_encoder_ratio;
Daniel Pettia7827412015-02-13 20:55:57 -080020 // The ratio from the encoder shaft to the arm joint.
21 double arm_encoder_ratio;
22 // The ratio from the pot shaft to the arm joint.
23 double arm_pot_ratio;
24 // The ratio from the encoder shaft to the elevator output pulley.
25 double elev_encoder_ratio;
26 // The ratio from the pot shaft to the elevator output pulley.
27 double elev_pot_ratio;
28 // How far the elevator moves (meters) per radian on the output pulley.
29 double elev_distance_per_radian;
30 // The ratio from the encoder shaft to the claw joint.
31 double claw_encoder_ratio;
32 // The ratio from the pot shaft to the claw joint.
33 double claw_pot_ratio;
Brian Silverman1a6590d2013-11-04 14:46:46 -080034
35 // The gear ratios from motor shafts to the drivetrain wheels for high and low
36 // gear.
37 double low_gear_ratio;
38 double high_gear_ratio;
Brian Silverman6eb51f12013-11-02 14:39:01 -070039 ShifterHallEffect left_drive, right_drive;
Brian Silverman1a6590d2013-11-04 14:46:46 -080040 bool clutch_transmission;
41
Brian Silvermanad9e0002014-04-13 14:55:57 -070042 double turn_width;
43
Brian Silverman2c590c32013-11-04 18:08:54 -080044 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
45 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
Brian Silvermandfdcd582014-02-16 20:50:09 -080046
Ben Fredrickson890c3fe2014-03-02 00:15:16 +000047 double drivetrain_done_distance;
48 double drivetrain_max_speed;
Comran Morshed79bd3db2015-02-07 14:51:13 +000049
50
51 // Superstructure Values /////
52
53 struct ZeroingConstants {
Austin Schuh703b8d42015-02-01 14:56:34 -080054 // The number of samples in the moving average filter.
Comran Morshed79bd3db2015-02-07 14:51:13 +000055 int average_filter_size;
Austin Schuh703b8d42015-02-01 14:56:34 -080056 // The difference in SI units between two index pulses.
Comran Morshed79bd3db2015-02-07 14:51:13 +000057 double index_difference;
Austin Schuh703b8d42015-02-01 14:56:34 -080058 // The absolute position in SI units of one of the index pulses.
59 double measured_index_position;
Comran Morshed79bd3db2015-02-07 14:51:13 +000060 };
61
Comran Morshed79bd3db2015-02-07 14:51:13 +000062 // Defines a range of motion for a subsystem.
63 struct Range {
64 double lower_hard_limit;
65 double upper_hard_limit;
66 double lower_limit;
67 double upper_limit;
68 };
69
70 struct Claw {
71 Range wrist;
Daniel Pettia7827412015-02-13 20:55:57 -080072 ZeroingConstants zeroing;
Comran Morshed79bd3db2015-02-07 14:51:13 +000073 };
74 Claw claw;
75
76 struct Fridge {
77 Range elevator;
78 Range arm;
Daniel Pettia7827412015-02-13 20:55:57 -080079
80 ZeroingConstants left_elev_zeroing;
81 ZeroingConstants right_elev_zeroing;
82 ZeroingConstants left_arm_zeroing;
83 ZeroingConstants right_arm_zeroing;
Comran Morshed79bd3db2015-02-07 14:51:13 +000084 };
85 Fridge fridge;
Austin Schuh703b8d42015-02-01 14:56:34 -080086
87 double max_allowed_left_right_arm_difference;
88 double max_allowed_left_right_elevator_difference;
Brian Silverman431500a2013-10-28 19:50:15 -070089};
90
Brian Silverman0a151c92014-05-02 15:28:44 -070091// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
92// returns a reference to it.
Brian Silverman431500a2013-10-28 19:50:15 -070093const Values &GetValues();
Brian Silverman0a151c92014-05-02 15:28:44 -070094
95// Creates Values instances for each team number it is called with and returns
96// them.
Ben Fredricksona9dcfa42014-02-23 02:05:59 +000097const Values &GetValuesForTeam(uint16_t team_number);
brians343bc112013-02-10 01:53:46 +000098
99} // namespace constants
100} // namespace frc971
Brian Silverman431500a2013-10-28 19:50:15 -0700101
102#endif // FRC971_CONSTANTS_H_