Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame^] | 1 | #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 | |
| 15 | namespace frc971 { |
| 16 | namespace constants { |
| 17 | namespace { |
| 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. |
| 22 | const double kCompWristHallEffectStartAngle = 1.285; |
| 23 | const double kPracticeWristHallEffectStartAngle = 1.175; |
| 24 | |
| 25 | const double kWristHallEffectStopAngle = 100 * M_PI / 180.0; |
| 26 | |
| 27 | const double kPracticeWristUpperPhysicalLimit = 1.677562; |
| 28 | const double kCompWristUpperPhysicalLimit = 1.677562; |
| 29 | |
| 30 | const double kPracticeWristLowerPhysicalLimit = -0.746128; |
| 31 | const double kCompWristLowerPhysicalLimit = -0.746128; |
| 32 | |
| 33 | const double kPracticeWristUpperLimit = 1.615385; |
| 34 | const double kCompWristUpperLimit = 1.615385; |
| 35 | |
| 36 | const double kPracticeWristLowerLimit = -0.746128; |
| 37 | const double kCompWristLowerLimit = -0.746128; |
| 38 | |
| 39 | const double kWristZeroingSpeed = 0.125; |
| 40 | const double kWristZeroingOffSpeed = 0.35; |
| 41 | |
| 42 | const 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 | |
| 47 | const double kCompAngleAdjustHallEffectStartAngle[2] = {0.301170496, 1.5}; |
| 48 | const double kPracticeAngleAdjustHallEffectStartAngle[2] = {0.305172594, 1.5}; |
| 49 | |
| 50 | const double kAngleAdjustHallEffectStopAngle[2] = {0.1, 1.0}; |
| 51 | |
| 52 | const double kPracticeAngleAdjustUpperPhysicalLimit = 0.904737; |
| 53 | const double kCompAngleAdjustUpperPhysicalLimit = 0.904737; |
| 54 | |
| 55 | const double kPracticeAngleAdjustLowerPhysicalLimit = 0.270; |
| 56 | const double kCompAngleAdjustLowerPhysicalLimit = 0.302; |
| 57 | |
| 58 | const double kPracticeAngleAdjustUpperLimit = 0.87; |
| 59 | const double kCompAngleAdjustUpperLimit = 0.87; |
| 60 | |
| 61 | const double kPracticeAngleAdjustLowerLimit = 0.31; |
| 62 | const double kCompAngleAdjustLowerLimit = 0.28; |
| 63 | |
| 64 | const double kAngleAdjustZeroingSpeed = -0.2; |
| 65 | const double kAngleAdjustZeroingOffSpeed = -0.5; |
| 66 | |
| 67 | const double kPracticeAngleAdjustDeadband = 0.4; |
| 68 | const double kCompAngleAdjustDeadband = 0.65; |
| 69 | |
| 70 | const int kCompCameraCenter = -2; |
| 71 | const int kPracticeCameraCenter = -5; |
| 72 | |
| 73 | const int kCompDrivetrainGearboxPinion = 19; |
| 74 | const int kPracticeDrivetrainGearboxPinion = 17; |
| 75 | |
| 76 | const 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 | |
| 129 | const Values &GetValues() { |
| 130 | static ::aos::Once<const Values> once(DoGetValues); |
| 131 | return *once.Get(); |
| 132 | } |
| 133 | |
| 134 | } // namespace constants |
| 135 | } // namespace frc971 |