blob: 202b436ca74e98cc63654ee68bd2ac8e9ce12a0c [file] [log] [blame]
Comran Morshed6c6a0a92016-01-17 12:45:16 +00001#ifndef Y2016_CONSTANTS_H_
2#define Y2016_CONSTANTS_H_
Comran Morshed9a9948c2016-01-16 15:58:04 +00003
4#include <stdint.h>
5
Comran Morshed6c6a0a92016-01-17 12:45:16 +00006#include "frc971/control_loops/state_feedback_loop.h"
Austin Schuh2fc10fa2016-02-08 00:44:34 -08007#include "frc971/shifter_hall_effect.h"
8#include "frc971/constants.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +00009
Austin Schuhc5467a12016-02-13 20:25:13 -080010#define INTAKE_ENCODER_RATIO (16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0)
11#define INTAKE_POT_RATIO (16.0 / 58.0)
12#define INTAKE_ENCODER_INDEX_DIFFERENCE (2.0 * M_PI * INTAKE_ENCODER_RATIO)
13
14#define SHOULDER_ENCODER_RATIO (16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0)
15#define SHOULDER_POT_RATIO (16.0 / 58.0)
16#define SHOULDER_ENCODER_INDEX_DIFFERENCE (2.0 * M_PI * SHOULDER_ENCODER_RATIO)
17
18#define WRIST_ENCODER_RATIO (16.0 / 48.0 * 18.0 / 64.0 * 14.0 / 54.0)
19#define WRIST_POT_RATIO (16.0 / 48.0)
20#define WRIST_ENCODER_INDEX_DIFFERENCE (2.0 * M_PI * WRIST_ENCODER_RATIO)
21
Comran Morshed6c6a0a92016-01-17 12:45:16 +000022namespace y2016 {
Comran Morshed9a9948c2016-01-16 15:58:04 +000023namespace constants {
24
25using ::frc971::constants::ShifterHallEffect;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080026using ::frc971::constants::ZeroingConstants;
Comran Morshed9a9948c2016-01-16 15:58:04 +000027
28// Has all of the numbers that change for both robots and makes it easy to
29// retrieve the values for the current one.
30
31// Everything is in SI units (volts, radians, meters, seconds, etc).
32// Some of these values are related to the conversion between raw values
33// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
34
35// This structure contains current values for all of the things that change.
36struct Values {
Comran Morshed9a9948c2016-01-16 15:58:04 +000037 // The ratio from the encoder shaft to the drivetrain wheels.
38 double drivetrain_encoder_ratio;
39
40 // The gear ratios from motor shafts to the drivetrain wheels for high and low
41 // gear.
42 double low_gear_ratio;
43 double high_gear_ratio;
44 ShifterHallEffect left_drive, right_drive;
Comran Morshed9a9948c2016-01-16 15:58:04 +000045
46 double turn_width;
47
48 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
49 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
50
51 double drivetrain_max_speed;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080052
53 // Defines a range of motion for a subsystem.
54 // These are all absolute positions in scaled units.
55 struct Range {
56 double lower_hard;
57 double upper_hard;
58 double lower;
59 double upper;
60 };
61
62 struct Intake {
63 Range limits;
64 ZeroingConstants zeroing;
65 };
66 Intake intake;
67
68 struct Shoulder {
69 Range limits;
70 ZeroingConstants zeroing;
71 };
72 Shoulder shoulder;
73
74 struct Wrist {
75 Range limits;
76 ZeroingConstants zeroing;
77 };
78 Wrist wrist;
Comran Morshed9a9948c2016-01-16 15:58:04 +000079};
80
81// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
82// returns a reference to it.
83const Values &GetValues();
84
85// Creates Values instances for each team number it is called with and returns
86// them.
87const Values &GetValuesForTeam(uint16_t team_number);
88
89} // namespace constants
Comran Morshed6c6a0a92016-01-17 12:45:16 +000090} // namespace y2016
Comran Morshed9a9948c2016-01-16 15:58:04 +000091
Comran Morshed6c6a0a92016-01-17 12:45:16 +000092#endif // Y2016_CONSTANTS_H_