blob: eca49d7f2bc208e7f5e61ca8581f518906e5f389 [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;
20
21 // The gear ratios from motor shafts to the drivetrain wheels for high and low
22 // gear.
23 double low_gear_ratio;
24 double high_gear_ratio;
Brian Silverman6eb51f12013-11-02 14:39:01 -070025 ShifterHallEffect left_drive, right_drive;
Brian Silverman1a6590d2013-11-04 14:46:46 -080026 bool clutch_transmission;
27
Brian Silvermanad9e0002014-04-13 14:55:57 -070028 double turn_width;
29
Brian Silverman2c590c32013-11-04 18:08:54 -080030 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
31 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
Brian Silvermandfdcd582014-02-16 20:50:09 -080032
Ben Fredrickson890c3fe2014-03-02 00:15:16 +000033 double drivetrain_done_distance;
34 double drivetrain_max_speed;
Comran Morshed79bd3db2015-02-07 14:51:13 +000035
36
37 // Superstructure Values /////
38
39 struct ZeroingConstants {
Austin Schuh703b8d42015-02-01 14:56:34 -080040 // The number of samples in the moving average filter.
Comran Morshed79bd3db2015-02-07 14:51:13 +000041 int average_filter_size;
Austin Schuh703b8d42015-02-01 14:56:34 -080042 // The difference in SI units between two index pulses.
Comran Morshed79bd3db2015-02-07 14:51:13 +000043 double index_difference;
Austin Schuh703b8d42015-02-01 14:56:34 -080044 // The absolute position in SI units of one of the index pulses.
45 double measured_index_position;
Comran Morshed79bd3db2015-02-07 14:51:13 +000046 };
47
48 ZeroingConstants left_arm_zeroing_constants;
49 ZeroingConstants right_arm_zeroing_constants;
50 ZeroingConstants left_elevator_zeroing_constants;
51 ZeroingConstants right_elevator_zeroing_constants;
52 ZeroingConstants claw_zeroing_constants;
53
54 // Defines a range of motion for a subsystem.
55 struct Range {
56 double lower_hard_limit;
57 double upper_hard_limit;
58 double lower_limit;
59 double upper_limit;
60 };
61
62 struct Claw {
63 Range wrist;
64 };
65 Claw claw;
66
67 struct Fridge {
68 Range elevator;
69 Range arm;
70 };
71 Fridge fridge;
Austin Schuh703b8d42015-02-01 14:56:34 -080072
73 double max_allowed_left_right_arm_difference;
74 double max_allowed_left_right_elevator_difference;
Brian Silverman431500a2013-10-28 19:50:15 -070075};
76
Brian Silverman0a151c92014-05-02 15:28:44 -070077// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
78// returns a reference to it.
Brian Silverman431500a2013-10-28 19:50:15 -070079const Values &GetValues();
Brian Silverman0a151c92014-05-02 15:28:44 -070080
81// Creates Values instances for each team number it is called with and returns
82// them.
Ben Fredricksona9dcfa42014-02-23 02:05:59 +000083const Values &GetValuesForTeam(uint16_t team_number);
brians343bc112013-02-10 01:53:46 +000084
85} // namespace constants
86} // namespace frc971
Brian Silverman431500a2013-10-28 19:50:15 -070087
88#endif // FRC971_CONSTANTS_H_