Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 1 | #include "y2023/constants.h" |
| 2 | |
| 3 | #include <cinttypes> |
| 4 | #include <map> |
| 5 | |
| 6 | #if __has_feature(address_sanitizer) |
| 7 | #include "sanitizer/lsan_interface.h" |
| 8 | #endif |
| 9 | |
| 10 | #include "absl/base/call_once.h" |
| 11 | #include "aos/mutex/mutex.h" |
| 12 | #include "aos/network/team_number.h" |
| 13 | #include "glog/logging.h" |
| 14 | |
| 15 | namespace y2023 { |
| 16 | namespace constants { |
| 17 | |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 18 | Values MakeValues(uint16_t team) { |
| 19 | LOG(INFO) << "creating a Constants for team: " << team; |
| 20 | |
| 21 | Values r; |
| 22 | |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 23 | auto *const arm_proximal = &r.arm_proximal; |
| 24 | auto *const arm_distal = &r.arm_distal; |
| 25 | |
| 26 | arm_proximal->zeroing.average_filter_size = Values::kZeroingSampleSize; |
| 27 | arm_proximal->zeroing.one_revolution_distance = |
| 28 | M_PI * 2.0 * constants::Values::kProximalEncoderRatio(); |
| 29 | arm_proximal->zeroing.zeroing_threshold = 0.0005; |
| 30 | arm_proximal->zeroing.moving_buffer_size = 20; |
| 31 | arm_proximal->zeroing.allowable_encoder_error = 0.9; |
| 32 | |
| 33 | arm_distal->zeroing.average_filter_size = Values::kZeroingSampleSize; |
| 34 | arm_distal->zeroing.one_revolution_distance = |
| 35 | M_PI * 2.0 * constants::Values::kDistalEncoderRatio(); |
| 36 | arm_distal->zeroing.zeroing_threshold = 0.0005; |
| 37 | arm_distal->zeroing.moving_buffer_size = 20; |
| 38 | arm_distal->zeroing.allowable_encoder_error = 0.9; |
| 39 | |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 40 | switch (team) { |
| 41 | // A set of constants for tests. |
| 42 | case 1: |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 43 | arm_proximal->zeroing.measured_absolute_position = 0.0; |
| 44 | arm_proximal->potentiometer_offset = 0.0; |
| 45 | |
| 46 | arm_distal->zeroing.measured_absolute_position = 0.0; |
| 47 | arm_distal->potentiometer_offset = 0.0; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 48 | break; |
| 49 | |
| 50 | case kCompTeamNumber: |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 51 | arm_proximal->zeroing.measured_absolute_position = 0.0; |
| 52 | arm_proximal->potentiometer_offset = 0.0; |
| 53 | |
| 54 | arm_distal->zeroing.measured_absolute_position = 0.0; |
| 55 | arm_distal->potentiometer_offset = 0.0; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 56 | break; |
| 57 | |
| 58 | case kPracticeTeamNumber: |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 59 | arm_proximal->zeroing.measured_absolute_position = 0.0; |
| 60 | arm_proximal->potentiometer_offset = 0.0; |
| 61 | |
| 62 | arm_distal->zeroing.measured_absolute_position = 0.0; |
| 63 | arm_distal->potentiometer_offset = 0.0; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 64 | break; |
| 65 | |
| 66 | case kCodingRobotTeamNumber: |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 67 | arm_proximal->zeroing.measured_absolute_position = 0.0; |
| 68 | arm_proximal->potentiometer_offset = 0.0; |
| 69 | |
| 70 | arm_distal->zeroing.measured_absolute_position = 0.0; |
| 71 | arm_distal->potentiometer_offset = 0.0; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 72 | break; |
| 73 | |
| 74 | default: |
| 75 | LOG(FATAL) << "unknown team: " << team; |
| 76 | } |
| 77 | |
| 78 | return r; |
| 79 | } |
| 80 | |
| 81 | Values MakeValues() { return MakeValues(aos::network::GetTeamNumber()); } |
| 82 | |
| 83 | } // namespace constants |
| 84 | } // namespace y2023 |