blob: eed56165a96fa735cb1eba39c51abc7a4fe9c3ee [file] [log] [blame]
Brian Silvermanb691f5e2015-08-02 11:37:55 -07001#ifndef Y2015_CONSTANTS_H_
2#define Y2015_CONSTANTS_H_
3
4#include <stdint.h>
5
6#include "frc971/control_loops/state_feedback_loop.h"
7#include "frc971/shifter_hall_effect.h"
8#include "frc971/constants.h"
9
Austin Schuh88af0852016-12-04 20:31:32 -080010namespace y2015 {
Brian Silvermanb691f5e2015-08-02 11:37:55 -070011namespace constants {
12
13// Has all of the numbers that change for both robots and makes it easy to
14// retrieve the values for the current one.
15
16// Everything is in SI units (volts, radians, meters, seconds, etc).
17// Some of these values are related to the conversion between raw values
18// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
19
20// This structure contains current values for all of the things that change.
21struct Values {
22 // Drivetrain Values /////
23
24 // The ratio from the encoder shaft to the drivetrain wheels.
25 double drivetrain_encoder_ratio;
26 // The ratio from the encoder shaft to the arm joint.
27 double arm_encoder_ratio;
28 // The ratio from the pot shaft to the arm joint.
29 double arm_pot_ratio;
30 // The ratio from the encoder shaft to the elevator output pulley.
31 double elev_encoder_ratio;
32 // The ratio from the pot shaft to the elevator output pulley.
33 double elev_pot_ratio;
34 // How far the elevator moves (meters) per radian on the output pulley.
35 double elev_distance_per_radian;
36 // The ratio from the encoder shaft to the claw joint.
37 double claw_encoder_ratio;
38 // The ratio from the pot shaft to the claw joint.
39 double claw_pot_ratio;
40
41 // How tall a tote is in meters.
42 double tote_height;
43
44 // The gear ratios from motor shafts to the drivetrain wheels for high and low
45 // gear.
46 double low_gear_ratio;
47 double high_gear_ratio;
Austin Schuh88af0852016-12-04 20:31:32 -080048 ::frc971::constants::ShifterHallEffect left_drive, right_drive;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070049 bool clutch_transmission;
50
51 double turn_width;
52
53 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
54 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
55
Brian Silvermanb691f5e2015-08-02 11:37:55 -070056 double drivetrain_max_speed;
57
58 // Superstructure Values /////
59
60 // Defines a range of motion for a subsystem.
61 // These are all absolute positions in scaled units.
62 struct Range {
63 double lower_hard_limit;
64 double upper_hard_limit;
65 double lower_limit;
66 double upper_limit;
67 };
68
69 struct Claw {
70 Range wrist;
Austin Schuh88af0852016-12-04 20:31:32 -080071 ::frc971::constants::ZeroingConstants zeroing;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070072 // The value to add to potentiometer readings after they have been converted
73 // to radians so that the resulting value is 0 when the claw is at absolute
74 // 0 (horizontal straight out the front).
75 double potentiometer_offset;
76
77 // Time between sending commands to claw opening pistons and them reaching
78 // the new state.
79 double piston_switch_time;
80 // How far on either side we look for the index pulse before we give up.
81 double zeroing_range;
82 };
83 Claw claw;
84
85 struct Fridge {
86 Range elevator;
87 Range arm;
88
Austin Schuh88af0852016-12-04 20:31:32 -080089 ::frc971::constants::ZeroingConstants left_elev_zeroing;
90 ::frc971::constants::ZeroingConstants right_elev_zeroing;
91 ::frc971::constants::ZeroingConstants left_arm_zeroing;
92 ::frc971::constants::ZeroingConstants right_arm_zeroing;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070093
94 // Values to add to scaled potentiometer readings so 0 lines up with the
95 // physical absolute 0.
96 double left_elevator_potentiometer_offset;
97 double right_elevator_potentiometer_offset;
98 double left_arm_potentiometer_offset;
99 double right_arm_potentiometer_offset;
100
101 // How high the elevator has to be before we start zeroing the arm.
102 double arm_zeroing_height;
103
104 // The length of the arm, from the axis of the bottom pivot to the axis of
105 // the top pivot.
106 double arm_length;
107 };
108 Fridge fridge;
109
110 double max_allowed_left_right_arm_difference;
111 double max_allowed_left_right_elevator_difference;
112
113 struct ClawGeometry {
114 // Horizontal distance from the center of the grabber to the end.
115 double grabber_half_length;
116 // Vertical distance from the arm rotation center to the bottom of the
117 // grabber. Distance measured with arm vertical (theta = 0).
118 double grabber_delta_y;
119 // Vertical separation of the claw and arm rotation centers with the
120 // elevator at 0.0 and the arm angle set to zero.
121 double grabber_arm_vert_separation;
122 // Horizontal separation of the claw and arm rotation centers with the
123 // elevator at 0.0 and the arm angle set to zero.
124 double grabber_arm_horz_separation;
125 // Distance between the center of the claw to the top of the claw.
126 // The line drawn at this distance parallel to the claw centerline is used
127 // to determine if claw interfears with the grabber.
128 double claw_top_thickness;
129 // The grabber is safe at any height if it is behind this location.
130 double grabber_always_safe_h_min;
131 // The grabber is safe at any x if it is above this location.
132 double grabber_always_safe_x_max;
133 };
134 ClawGeometry clawGeometry;
135};
136
137// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
138// returns a reference to it.
139const Values &GetValues();
140
141// Creates Values instances for each team number it is called with and returns
142// them.
143const Values &GetValuesForTeam(uint16_t team_number);
144
145} // namespace constants
Austin Schuh88af0852016-12-04 20:31:32 -0800146} // namespace y2015
Brian Silvermanb691f5e2015-08-02 11:37:55 -0700147
148#endif // Y2015_CONSTANTS_H_