blob: e7c178b0ec1656885256f0a7bf2635d1fc534daf [file] [log] [blame]
Tyler Chatow37ecdcd2019-01-26 20:18:42 -08001#ifndef Y2019_CONSTANTS_H_
2#define Y2019_CONSTANTS_H_
3
4#include <stdint.h>
5#include <math.h>
6
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() {
31 return (52.0 / 24.0);
32 }
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_