blob: e68143c05a7a3fb83d1a55a81f921206e0c22ac1 [file] [log] [blame]
Tyler Chatow37ecdcd2019-01-26 20:18:42 -08001#ifndef Y2019_CONSTANTS_H_
2#define Y2019_CONSTANTS_H_
3
Tyler Chatow37ecdcd2019-01-26 20:18:42 -08004#include <math.h>
Sabina Davis1b84afa2019-02-09 01:20:21 -08005#include <stdint.h>
Tyler Chatow37ecdcd2019-01-26 20:18:42 -08006
7#include "frc971/constants.h"
Sabina Davis7be49f32019-02-02 00:30:19 -08008#include "y2019/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
Tyler Chatow37ecdcd2019-01-26 20:18:42 -08009
10namespace y2019 {
11namespace constants {
12
13// Has all of our "constants", except the ones that come from other places. The
14// ones which change between robots are put together with a workable way to
15// retrieve the values for the current robot.
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// All ratios are from the encoder shaft to the output units.
22
23struct Values {
24 static const int kZeroingSampleSize = 200;
Sabina Davis7be49f32019-02-02 00:30:19 -080025
26 static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; }
27 static constexpr double kDrivetrainEncoderCountsPerRevolution() {
28 return kDrivetrainCyclesPerRevolution() * 4;
29 }
30 static constexpr double kDrivetrainEncoderRatio() {
Sabina Davis1b84afa2019-02-09 01:20:21 -080031 return (24.0 / 52.0);
Sabina Davis7be49f32019-02-02 00:30:19 -080032 }
33 static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() {
34 return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) *
35 control_loops::drivetrain::kHighOutputRatio /
36 constants::Values::kDrivetrainEncoderRatio() *
37 kDrivetrainEncoderCountsPerRevolution();
38 }
Tyler Chatow37ecdcd2019-01-26 20:18:42 -080039};
40
41// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
42// returns a reference to it.
43const Values &GetValues();
44
45// Creates Values instances for each team number it is called with and returns
46// them.
47const Values &GetValuesForTeam(uint16_t team_number);
48
49} // namespace constants
50} // namespace y2019
51
52#endif // Y2019_CONSTANTS_H_