blob: a87315c8afabab95fb0a430a6ca09ed0697a1fc1 [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
10namespace frc971 {
11namespace 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;
48 ShifterHallEffect left_drive, right_drive;
49 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
56 double drivetrain_done_distance;
57 double drivetrain_max_speed;
58
59 // Superstructure Values /////
60
61 // Defines a range of motion for a subsystem.
62 // These are all absolute positions in scaled units.
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;
72 ZeroingConstants zeroing;
73 // The value to add to potentiometer readings after they have been converted
74 // to radians so that the resulting value is 0 when the claw is at absolute
75 // 0 (horizontal straight out the front).
76 double potentiometer_offset;
77
78 // Time between sending commands to claw opening pistons and them reaching
79 // the new state.
80 double piston_switch_time;
81 // How far on either side we look for the index pulse before we give up.
82 double zeroing_range;
83 };
84 Claw claw;
85
86 struct Fridge {
87 Range elevator;
88 Range arm;
89
90 ZeroingConstants left_elev_zeroing;
91 ZeroingConstants right_elev_zeroing;
92 ZeroingConstants left_arm_zeroing;
93 ZeroingConstants right_arm_zeroing;
94
95 // Values to add to scaled potentiometer readings so 0 lines up with the
96 // physical absolute 0.
97 double left_elevator_potentiometer_offset;
98 double right_elevator_potentiometer_offset;
99 double left_arm_potentiometer_offset;
100 double right_arm_potentiometer_offset;
101
102 // How high the elevator has to be before we start zeroing the arm.
103 double arm_zeroing_height;
104
105 // The length of the arm, from the axis of the bottom pivot to the axis of
106 // the top pivot.
107 double arm_length;
108 };
109 Fridge fridge;
110
111 double max_allowed_left_right_arm_difference;
112 double max_allowed_left_right_elevator_difference;
113
114 struct ClawGeometry {
115 // Horizontal distance from the center of the grabber to the end.
116 double grabber_half_length;
117 // Vertical distance from the arm rotation center to the bottom of the
118 // grabber. Distance measured with arm vertical (theta = 0).
119 double grabber_delta_y;
120 // Vertical separation of the claw and arm rotation centers with the
121 // elevator at 0.0 and the arm angle set to zero.
122 double grabber_arm_vert_separation;
123 // Horizontal separation of the claw and arm rotation centers with the
124 // elevator at 0.0 and the arm angle set to zero.
125 double grabber_arm_horz_separation;
126 // Distance between the center of the claw to the top of the claw.
127 // The line drawn at this distance parallel to the claw centerline is used
128 // to determine if claw interfears with the grabber.
129 double claw_top_thickness;
130 // The grabber is safe at any height if it is behind this location.
131 double grabber_always_safe_h_min;
132 // The grabber is safe at any x if it is above this location.
133 double grabber_always_safe_x_max;
134 };
135 ClawGeometry clawGeometry;
136};
137
138// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
139// returns a reference to it.
140const Values &GetValues();
141
142// Creates Values instances for each team number it is called with and returns
143// them.
144const Values &GetValuesForTeam(uint16_t team_number);
145
146} // namespace constants
147} // namespace frc971
148
149#endif // Y2015_CONSTANTS_H_