blob: 0a99b94001871f2d8ff8f4c75dad10b398a7305b [file] [log] [blame]
Ariv Diggi0af59c02023-10-07 13:15:39 -07001#include "y2023_bot3/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 "glog/logging.h"
12
13#include "aos/mutex/mutex.h"
14#include "aos/network/team_number.h"
Maxwell Henderson43684fa2023-11-06 11:08:06 -080015#include "y2023_bot3/control_loops/superstructure/pivot_joint/integral_pivot_joint_plant.h"
Ariv Diggi0af59c02023-10-07 13:15:39 -070016
17namespace y2023_bot3 {
18namespace constants {
19
20Values MakeValues(uint16_t team) {
21 LOG(INFO) << "creating a Constants for team: " << team;
22
23 Values r;
Maxwell Henderson43684fa2023-11-06 11:08:06 -080024 auto *const pivot_joint = &r.pivot_joint;
25
26 r.pivot_joint_flipped = true;
27
28 pivot_joint->subsystem_params.zeroing_voltage = 3.0;
29 pivot_joint->subsystem_params.operating_voltage = 12.0;
30 pivot_joint->subsystem_params.zeroing_profile_params = {0.5, 3.0};
Filip Kujawa35b5aad2023-11-14 21:53:19 -080031 pivot_joint->subsystem_params.default_profile_params = {5.0, 5.0};
Maxwell Henderson43684fa2023-11-06 11:08:06 -080032 pivot_joint->subsystem_params.range = Values::kPivotJointRange();
33 pivot_joint->subsystem_params.make_integral_loop =
34 control_loops::superstructure::pivot_joint::MakeIntegralPivotJointLoop;
35 pivot_joint->subsystem_params.zeroing_constants.average_filter_size =
36 Values::kZeroingSampleSize;
37 pivot_joint->subsystem_params.zeroing_constants.one_revolution_distance =
38 M_PI * 2.0 * constants::Values::kPivotJointEncoderRatio();
39 pivot_joint->subsystem_params.zeroing_constants.zeroing_threshold = 0.0005;
40 pivot_joint->subsystem_params.zeroing_constants.moving_buffer_size = 20;
41 pivot_joint->subsystem_params.zeroing_constants.allowable_encoder_error = 0.9;
42
Ariv Diggi0af59c02023-10-07 13:15:39 -070043 switch (team) {
44 // A set of constants for tests.
45 case 1:
Maxwell Henderson43684fa2023-11-06 11:08:06 -080046
Maxwell Henderson9435b5c2023-11-06 13:48:51 -080047 pivot_joint->potentiometer_offset = 0.0;
48
Maxwell Henderson43684fa2023-11-06 11:08:06 -080049 pivot_joint->subsystem_params.zeroing_constants
50 .measured_absolute_position = 0.0;
51
Ariv Diggi0af59c02023-10-07 13:15:39 -070052 break;
53
54 case kThirdRobotTeamNumber:
Filip Kujawa35b5aad2023-11-14 21:53:19 -080055 pivot_joint->subsystem_params.zeroing_constants
56 .measured_absolute_position = 0.564786179025525;
57
58 pivot_joint->potentiometer_offset = 0.304569457401797 + 2.66972311194163;
Ariv Diggi0af59c02023-10-07 13:15:39 -070059 break;
60
61 default:
62 LOG(FATAL) << "unknown team: " << team;
63 }
64
65 return r;
66}
67
68Values MakeValues() { return MakeValues(aos::network::GetTeamNumber()); }
69
70} // namespace constants
71} // namespace y2023_bot3