blob: 76a5f3ba3b67b3704b4532e01390e91a4682832f [file] [log] [blame]
Brian Silverman431500a2013-10-28 19:50:15 -07001#include "frc971/constants.h"
2
3#include <math.h>
4#include <stdint.h>
5#include <inttypes.h>
6
7#include "aos/common/logging/logging.h"
8#include "aos/common/once.h"
9#include "aos/common/network/team_number.h"
10
11#ifndef M_PI
12#define M_PI 3.14159265358979323846
13#endif
14
15namespace frc971 {
16namespace constants {
17namespace {
18
19// It has about 0.029043 of gearbox slop.
20// For purposes of moving the end up/down by a certain amount, the wrist is 18
21// inches long.
22const double kCompWristHallEffectStartAngle = 1.285;
23const double kPracticeWristHallEffectStartAngle = 1.175;
24
25const double kWristHallEffectStopAngle = 100 * M_PI / 180.0;
26
27const double kPracticeWristUpperPhysicalLimit = 1.677562;
28const double kCompWristUpperPhysicalLimit = 1.677562;
29
30const double kPracticeWristLowerPhysicalLimit = -0.746128;
31const double kCompWristLowerPhysicalLimit = -0.746128;
32
33const double kPracticeWristUpperLimit = 1.615385;
34const double kCompWristUpperLimit = 1.615385;
35
36const double kPracticeWristLowerLimit = -0.746128;
37const double kCompWristLowerLimit = -0.746128;
38
39const double kWristZeroingSpeed = 0.125;
40const double kWristZeroingOffSpeed = 0.35;
41
42const int kAngleAdjustHallEffect = 2;
43
44// Angle measured from CAD with the top of the angle adjust at the top of the
45// wire guide is 0.773652098 radians.
46
47const double kCompAngleAdjustHallEffectStartAngle[2] = {0.301170496, 1.5};
48const double kPracticeAngleAdjustHallEffectStartAngle[2] = {0.305172594, 1.5};
49
50const double kAngleAdjustHallEffectStopAngle[2] = {0.1, 1.0};
51
52const double kPracticeAngleAdjustUpperPhysicalLimit = 0.904737;
53const double kCompAngleAdjustUpperPhysicalLimit = 0.904737;
54
55const double kPracticeAngleAdjustLowerPhysicalLimit = 0.270;
56const double kCompAngleAdjustLowerPhysicalLimit = 0.302;
57
58const double kPracticeAngleAdjustUpperLimit = 0.87;
59const double kCompAngleAdjustUpperLimit = 0.87;
60
61const double kPracticeAngleAdjustLowerLimit = 0.31;
62const double kCompAngleAdjustLowerLimit = 0.28;
63
64const double kAngleAdjustZeroingSpeed = -0.2;
65const double kAngleAdjustZeroingOffSpeed = -0.5;
66
67const double kPracticeAngleAdjustDeadband = 0.4;
68const double kCompAngleAdjustDeadband = 0.65;
69
70const int kCompCameraCenter = -2;
71const int kPracticeCameraCenter = -5;
72
73const int kCompDrivetrainGearboxPinion = 19;
74const int kPracticeDrivetrainGearboxPinion = 17;
75
76const Values *DoGetValues() {
77 uint16_t team = ::aos::network::GetTeamNumber();
78 LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
79 switch (team) {
80 case kCompTeamNumber:
81 return new Values{kCompWristHallEffectStartAngle,
82 kWristHallEffectStopAngle,
83 kCompWristUpperLimit,
84 kCompWristLowerLimit,
85 kCompWristUpperPhysicalLimit,
86 kCompWristLowerPhysicalLimit,
87 kWristZeroingSpeed,
88 kWristZeroingOffSpeed,
89 kCompAngleAdjustHallEffectStartAngle,
90 kAngleAdjustHallEffectStopAngle,
91 kCompAngleAdjustUpperLimit,
92 kCompAngleAdjustLowerLimit,
93 kCompAngleAdjustUpperPhysicalLimit,
94 kCompAngleAdjustLowerPhysicalLimit,
95 kAngleAdjustZeroingSpeed,
96 kAngleAdjustZeroingOffSpeed,
97 kCompAngleAdjustDeadband,
98 kCompDrivetrainGearboxPinion,
99 kCompCameraCenter};
100 break;
101 case kPracticeTeamNumber:
102 return new Values{kPracticeWristHallEffectStartAngle,
103 kWristHallEffectStopAngle,
104 kPracticeWristUpperLimit,
105 kPracticeWristLowerLimit,
106 kPracticeWristUpperPhysicalLimit,
107 kPracticeWristLowerPhysicalLimit,
108 kWristZeroingSpeed,
109 kWristZeroingOffSpeed,
110 kPracticeAngleAdjustHallEffectStartAngle,
111 kAngleAdjustHallEffectStopAngle,
112 kPracticeAngleAdjustUpperLimit,
113 kPracticeAngleAdjustLowerLimit,
114 kPracticeAngleAdjustUpperPhysicalLimit,
115 kPracticeAngleAdjustLowerPhysicalLimit,
116 kAngleAdjustZeroingSpeed,
117 kAngleAdjustZeroingOffSpeed,
118 kPracticeAngleAdjustDeadband,
119 kPracticeDrivetrainGearboxPinion,
120 kPracticeCameraCenter};
121 break;
122 default:
123 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
124 }
125}
126
127} // namespace
128
129const Values &GetValues() {
130 static ::aos::Once<const Values> once(DoGetValues);
131 return *once.Get();
132}
133
134} // namespace constants
135} // namespace frc971