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 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame^] | 11 | #include "frc971/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h" |
| 12 | #include "frc971/control_loops/drivetrain/polydrivetrain_clutch_motor_plant.h" |
| 13 | #include "frc971/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
| 14 | #include "frc971/control_loops/drivetrain/drivetrain_clutch_motor_plant.h" |
| 15 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 16 | #ifndef M_PI |
| 17 | #define M_PI 3.14159265358979323846 |
| 18 | #endif |
| 19 | |
| 20 | namespace frc971 { |
| 21 | namespace constants { |
| 22 | namespace { |
| 23 | |
| 24 | // It has about 0.029043 of gearbox slop. |
| 25 | // For purposes of moving the end up/down by a certain amount, the wrist is 18 |
| 26 | // inches long. |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 27 | const double kCompWristHallEffectStartAngle = 1.27; |
Brian Silverman | c0faf61 | 2013-11-03 15:53:22 -0800 | [diff] [blame] | 28 | const double kPracticeWristHallEffectStartAngle = 1.182; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 29 | |
| 30 | const double kWristHallEffectStopAngle = 100 * M_PI / 180.0; |
| 31 | |
| 32 | const double kPracticeWristUpperPhysicalLimit = 1.677562; |
| 33 | const double kCompWristUpperPhysicalLimit = 1.677562; |
| 34 | |
| 35 | const double kPracticeWristLowerPhysicalLimit = -0.746128; |
| 36 | const double kCompWristLowerPhysicalLimit = -0.746128; |
| 37 | |
| 38 | const double kPracticeWristUpperLimit = 1.615385; |
| 39 | const double kCompWristUpperLimit = 1.615385; |
| 40 | |
| 41 | const double kPracticeWristLowerLimit = -0.746128; |
| 42 | const double kCompWristLowerLimit = -0.746128; |
| 43 | |
| 44 | const double kWristZeroingSpeed = 0.125; |
| 45 | const double kWristZeroingOffSpeed = 0.35; |
| 46 | |
| 47 | const int kAngleAdjustHallEffect = 2; |
| 48 | |
| 49 | // Angle measured from CAD with the top of the angle adjust at the top of the |
| 50 | // wire guide is 0.773652098 radians. |
| 51 | |
| 52 | const double kCompAngleAdjustHallEffectStartAngle[2] = {0.301170496, 1.5}; |
| 53 | const double kPracticeAngleAdjustHallEffectStartAngle[2] = {0.305172594, 1.5}; |
| 54 | |
| 55 | const double kAngleAdjustHallEffectStopAngle[2] = {0.1, 1.0}; |
| 56 | |
| 57 | const double kPracticeAngleAdjustUpperPhysicalLimit = 0.904737; |
| 58 | const double kCompAngleAdjustUpperPhysicalLimit = 0.904737; |
| 59 | |
| 60 | const double kPracticeAngleAdjustLowerPhysicalLimit = 0.270; |
| 61 | const double kCompAngleAdjustLowerPhysicalLimit = 0.302; |
| 62 | |
| 63 | const double kPracticeAngleAdjustUpperLimit = 0.87; |
| 64 | const double kCompAngleAdjustUpperLimit = 0.87; |
| 65 | |
| 66 | const double kPracticeAngleAdjustLowerLimit = 0.31; |
| 67 | const double kCompAngleAdjustLowerLimit = 0.28; |
| 68 | |
| 69 | const double kAngleAdjustZeroingSpeed = -0.2; |
| 70 | const double kAngleAdjustZeroingOffSpeed = -0.5; |
| 71 | |
| 72 | const double kPracticeAngleAdjustDeadband = 0.4; |
| 73 | const double kCompAngleAdjustDeadband = 0.65; |
| 74 | |
| 75 | const int kCompCameraCenter = -2; |
| 76 | const int kPracticeCameraCenter = -5; |
| 77 | |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 78 | const double kCompDrivetrainEncoderRatio = |
| 79 | (15.0 / 50.0) /*output reduction*/ * (36.0 / 24.0) /*encoder gears*/; |
| 80 | const double kCompLowGearRatio = 14.0 / 60.0 * 15.0 / 50.0; |
| 81 | const double kCompHighGearRatio = 30.0 / 44.0 * 15.0 / 50.0; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 82 | |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 83 | const double kPracticeDrivetrainEncoderRatio = |
| 84 | (17.0 / 50.0) /*output reduction*/ * (64.0 / 24.0) /*encoder gears*/; |
| 85 | const double kPracticeLowGearRatio = 16.0 / 60.0 * 19.0 / 50.0; |
| 86 | const double kPracticeHighGearRatio = 28.0 / 48.0 * 19.0 / 50.0; |
| 87 | |
| 88 | const ShifterHallEffect kCompLeftDriveShifter{0.8 /*TODO*/, 2.14, 1.2, 1.0}; |
| 89 | const ShifterHallEffect kCompRightDriveShifter{0.865, 2.375, 1.2, 1.0}; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 90 | |
| 91 | const ShifterHallEffect kPracticeLeftDriveShifter{2.082283, 0.834433, 0.60, |
| 92 | 0.47}; |
| 93 | const ShifterHallEffect kPracticeRightDriveShifter{2.070124, 0.838993, 0.62, |
| 94 | 0.55}; |
| 95 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 96 | const Values *DoGetValues() { |
| 97 | uint16_t team = ::aos::network::GetTeamNumber(); |
| 98 | LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team); |
| 99 | switch (team) { |
| 100 | case kCompTeamNumber: |
| 101 | return new Values{kCompWristHallEffectStartAngle, |
| 102 | kWristHallEffectStopAngle, |
| 103 | kCompWristUpperLimit, |
| 104 | kCompWristLowerLimit, |
| 105 | kCompWristUpperPhysicalLimit, |
| 106 | kCompWristLowerPhysicalLimit, |
| 107 | kWristZeroingSpeed, |
| 108 | kWristZeroingOffSpeed, |
| 109 | kCompAngleAdjustHallEffectStartAngle, |
| 110 | kAngleAdjustHallEffectStopAngle, |
| 111 | kCompAngleAdjustUpperLimit, |
| 112 | kCompAngleAdjustLowerLimit, |
| 113 | kCompAngleAdjustUpperPhysicalLimit, |
| 114 | kCompAngleAdjustLowerPhysicalLimit, |
| 115 | kAngleAdjustZeroingSpeed, |
| 116 | kAngleAdjustZeroingOffSpeed, |
| 117 | kCompAngleAdjustDeadband, |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 118 | kCompDrivetrainEncoderRatio, |
| 119 | kCompLowGearRatio, |
| 120 | kCompHighGearRatio, |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 121 | kCompLeftDriveShifter, |
| 122 | kCompRightDriveShifter, |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 123 | true, |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame^] | 124 | control_loops::MakeVClutchDrivetrainLoop, |
| 125 | control_loops::MakeClutchDrivetrainLoop, |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 126 | kCompCameraCenter}; |
| 127 | break; |
| 128 | case kPracticeTeamNumber: |
| 129 | return new Values{kPracticeWristHallEffectStartAngle, |
| 130 | kWristHallEffectStopAngle, |
| 131 | kPracticeWristUpperLimit, |
| 132 | kPracticeWristLowerLimit, |
| 133 | kPracticeWristUpperPhysicalLimit, |
| 134 | kPracticeWristLowerPhysicalLimit, |
| 135 | kWristZeroingSpeed, |
| 136 | kWristZeroingOffSpeed, |
| 137 | kPracticeAngleAdjustHallEffectStartAngle, |
| 138 | kAngleAdjustHallEffectStopAngle, |
| 139 | kPracticeAngleAdjustUpperLimit, |
| 140 | kPracticeAngleAdjustLowerLimit, |
| 141 | kPracticeAngleAdjustUpperPhysicalLimit, |
| 142 | kPracticeAngleAdjustLowerPhysicalLimit, |
| 143 | kAngleAdjustZeroingSpeed, |
| 144 | kAngleAdjustZeroingOffSpeed, |
| 145 | kPracticeAngleAdjustDeadband, |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 146 | kPracticeDrivetrainEncoderRatio, |
| 147 | kPracticeLowGearRatio, |
| 148 | kPracticeHighGearRatio, |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 149 | kPracticeLeftDriveShifter, |
| 150 | kPracticeRightDriveShifter, |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 151 | false, |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame^] | 152 | control_loops::MakeVDogDrivetrainLoop, |
| 153 | control_loops::MakeDogDrivetrainLoop, |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 154 | kPracticeCameraCenter}; |
| 155 | break; |
| 156 | default: |
| 157 | LOG(FATAL, "unknown team #%" PRIu16 "\n", team); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | } // namespace |
| 162 | |
| 163 | const Values &GetValues() { |
| 164 | static ::aos::Once<const Values> once(DoGetValues); |
| 165 | return *once.Get(); |
| 166 | } |
| 167 | |
| 168 | } // namespace constants |
| 169 | } // namespace frc971 |