blob: 8cefe7e1742e99c1e4b9c4c2cd8d1b588de27937 [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
Austin Schuhf2a50ba2016-12-24 16:16:26 -08006#include "aos/common/time.h"
7#include "frc971/constants.h"
Brian Silvermanb691f5e2015-08-02 11:37:55 -07008#include "frc971/control_loops/state_feedback_loop.h"
9#include "frc971/shifter_hall_effect.h"
Brian Silvermanb691f5e2015-08-02 11:37:55 -070010
Austin Schuh88af0852016-12-04 20:31:32 -080011namespace y2015 {
Brian Silvermanb691f5e2015-08-02 11:37:55 -070012namespace constants {
13
14// Has all of the numbers that change for both robots and makes it easy to
15// retrieve the values for the current one.
16
17// Everything is in SI units (volts, radians, meters, seconds, etc).
18// Some of these values are related to the conversion between raw values
19// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
20
21// This structure contains current values for all of the things that change.
22struct Values {
23 // Drivetrain Values /////
24
25 // The ratio from the encoder shaft to the drivetrain wheels.
26 double drivetrain_encoder_ratio;
27 // The ratio from the encoder shaft to the arm joint.
28 double arm_encoder_ratio;
29 // The ratio from the pot shaft to the arm joint.
30 double arm_pot_ratio;
31 // The ratio from the encoder shaft to the elevator output pulley.
32 double elev_encoder_ratio;
33 // The ratio from the pot shaft to the elevator output pulley.
34 double elev_pot_ratio;
35 // How far the elevator moves (meters) per radian on the output pulley.
36 double elev_distance_per_radian;
37 // The ratio from the encoder shaft to the claw joint.
38 double claw_encoder_ratio;
39 // The ratio from the pot shaft to the claw joint.
40 double claw_pot_ratio;
41
42 // How tall a tote is in meters.
43 double tote_height;
44
45 // The gear ratios from motor shafts to the drivetrain wheels for high and low
46 // gear.
47 double low_gear_ratio;
48 double high_gear_ratio;
Austin Schuh88af0852016-12-04 20:31:32 -080049 ::frc971::constants::ShifterHallEffect left_drive, right_drive;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070050 bool clutch_transmission;
51
52 double turn_width;
53
54 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
55 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
56
Brian Silvermanb691f5e2015-08-02 11:37:55 -070057 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;
Austin Schuh88af0852016-12-04 20:31:32 -080072 ::frc971::constants::ZeroingConstants zeroing;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070073 // 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.
Austin Schuhf2a50ba2016-12-24 16:16:26 -080080 ::aos::monotonic_clock::duration piston_switch_time;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070081 // 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
Austin Schuh88af0852016-12-04 20:31:32 -080090 ::frc971::constants::ZeroingConstants left_elev_zeroing;
91 ::frc971::constants::ZeroingConstants right_elev_zeroing;
92 ::frc971::constants::ZeroingConstants left_arm_zeroing;
93 ::frc971::constants::ZeroingConstants right_arm_zeroing;
Brian Silvermanb691f5e2015-08-02 11:37:55 -070094
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
Austin Schuh88af0852016-12-04 20:31:32 -0800147} // namespace y2015
Brian Silvermanb691f5e2015-08-02 11:37:55 -0700148
149#endif // Y2015_CONSTANTS_H_