Daedalus (PY2026)
Codebase for the Husky Robotics 2025-2026 rover Daedalus
Loading...
Searching...
No Matches
real_world_constants.h
1#pragma once
2
3#include "../CAN/CANUtils.h"
4#include "../Constants.h"
5#include "data.h"
6
7#include <chrono>
8#include <cstdint>
9#include <unordered_map>
10#include <unordered_set>
11
12#include <frozen/unordered_map.h>
13#include <frozen/unordered_set.h>
14
15namespace robot {
16
18
20struct pidcoef_t {
21 int32_t kP, kI, kD;
22};
23
24// TODO: measure to see optimal telemetry period
27
45
58
59// clang-format off
60constexpr auto encMotors = frozen::make_unordered_map<motorid_t, encparams_t>({
61 {motorid_t::shoulder,
62 {.isInverted = true,
63 .ppjr = 4590 * 1024 * 4,
64 .limitSwitchLow = Constants::Arm::JOINT_LIMITS.at(robot::types::motorid_t::shoulder).first,
65 .limitSwitchHigh = Constants::Arm::JOINT_LIMITS.at(robot::types::motorid_t::shoulder).second,
66 .zeroCalibrationPower = 0.4}},
67});
68// clang-format on
69
70// TODO: find appropriate bounds
71constexpr auto potMotors = frozen::make_unordered_map<motorid_t, potparams_t>({
72 {motorid_t::forearm,
73 {.adc_lo = 1208, .mdeg_lo = -180 * 1000, .adc_hi = 841, .mdeg_hi = 180 * 1000}},
74 {motorid_t::wristDiffLeft,
75 {.adc_lo = 0, .mdeg_lo = -100 * 0, .adc_hi = 0, .mdeg_hi = 100 * 0}},
76 {motorid_t::wristDiffRight,
77 {.adc_lo = 0, .mdeg_lo = -100 * 0, .adc_hi = 0, .mdeg_hi = 100 * 0}},
78 {motorid_t::fourbar1, {.adc_lo = 8, .mdeg_lo = 75200, .adc_hi = 8, .mdeg_hi = 267500}},
79});
80
82constexpr auto motorSerialIDMap = frozen::make_unordered_map<motorid_t, can::deviceserial_t>(
83 {{motorid_t::leftTread, DEVICE_SERIAL_TREAD_LEFT},
84 {motorid_t::rightTread, DEVICE_SERIAL_TREAD_RIGHT},
85 {motorid_t::armBase, DEVICE_SERIAL_MOTOR_BASE},
86 {motorid_t::shoulder, DEVICE_SERIAL_MOTOR_SHOULDER},
87 {motorid_t::elbow, DEVICE_SERIAL_MOTOR_ELBOW},
88 {motorid_t::forearm, DEVICE_SERIAL_MOTOR_FOREARM},
89 {motorid_t::wristDiffLeft, DEVICE_SERIAL_MOTOR_WRIST_DIFF_LEFT},
90 {motorid_t::wristDiffRight, DEVICE_SERIAL_MOTOR_WRIST_DIFF_RIGHT},
91 {motorid_t::hand, DEVICE_SERIAL_MOTOR_HAND},
92 {motorid_t::drillActuator, DEVICE_SERIAL_DRILL_ACTUATOR},
93 {motorid_t::drillMotor, DEVICE_SERIAL_DRILL_MOTOR},
94 {motorid_t::fourbar1, DEVICE_SERIAL_FOUR_BAR_LINKAGE_1},
95 {motorid_t::fourbar2, DEVICE_SERIAL_FOUR_BAR_LINKAGE_2},
96 {motorid_t::scienceServoBoard, DEVICE_SERIAL_SCIENCE_SERVO},
97 {motorid_t::scienceStepperBoard, DEVICE_SERIAL_SCIENCE_STEPPER}});
98
99constexpr auto motorGroupMap = frozen::make_unordered_map<motorid_t, can::devicegroup_t>(
100 {{motorid_t::leftTread, can::devicegroup_t::motor},
101 {motorid_t::rightTread, can::devicegroup_t::motor},
102 {motorid_t::armBase, can::devicegroup_t::motor},
103 {motorid_t::shoulder, can::devicegroup_t::motor},
104 {motorid_t::elbow, can::devicegroup_t::motor},
105 {motorid_t::forearm, can::devicegroup_t::motor},
106 {motorid_t::wristDiffLeft, can::devicegroup_t::motor},
107 {motorid_t::wristDiffRight, can::devicegroup_t::motor},
108 {motorid_t::hand, can::devicegroup_t::motor},
109 {motorid_t::drillActuator, can::devicegroup_t::science},
110 {motorid_t::drillMotor, can::devicegroup_t::science},
111 {motorid_t::fourbar1, can::devicegroup_t::science},
112 {motorid_t::fourbar2, can::devicegroup_t::science},
113 {motorid_t::scienceServoBoard, can::devicegroup_t::science},
114 {motorid_t::scienceStepperBoard, can::devicegroup_t::science}});
115
117constexpr auto motorPIDMap =
118 frozen::make_unordered_map<motorid_t, pidcoef_t>({{motorid_t::shoulder, {70, 0, 0}}});
119
124constexpr auto positive_pwm_scales =
125 frozen::make_unordered_map<motorid_t, double>({{motorid_t::armBase, -0.25},
126 {motorid_t::shoulder, -1},
127 {motorid_t::elbow, -1},
128 {motorid_t::forearm, -0.2},
129 {motorid_t::wristDiffLeft, -0.1},
130 {motorid_t::wristDiffRight, 0.1},
131 {motorid_t::leftTread, 0.7},
132 {motorid_t::rightTread, -0.7},
133 {motorid_t::hand, -0.75},
134 {motorid_t::drillActuator, -0.5},
135 {motorid_t::drillMotor, -1.0},
136 {motorid_t::fourbar1, 0.3},
137 {motorid_t::fourbar2, 0.3},
138 {motorid_t::scienceServoBoard, 0},
139 {motorid_t::scienceStepperBoard, 0}});
144constexpr auto negative_pwm_scales =
145 frozen::make_unordered_map<motorid_t, double>({{motorid_t::armBase, -0.25},
146 {motorid_t::shoulder, -1},
147 {motorid_t::elbow, -1},
148 {motorid_t::forearm, -0.2},
149 {motorid_t::wristDiffLeft, -0.1},
150 {motorid_t::wristDiffRight, 0.1},
151 {motorid_t::leftTread, 0.7},
152 {motorid_t::rightTread, -0.7},
153 {motorid_t::hand, -0.75},
154 {motorid_t::drillActuator, -0.5},
155 {motorid_t::drillMotor, -1.0},
156 {motorid_t::fourbar1, 0.15},
157 {motorid_t::fourbar2, 0.15},
158 {motorid_t::scienceServoBoard, 0},
159 {motorid_t::scienceStepperBoard, 0}});
160
161} // namespace robot
duration< int64_t, milli > milliseconds
constexpr frozen::unordered_map< motorid_t, std::pair< int, int >, IK_MOTORS.size()> JOINT_LIMITS
Map from motor ids to min and max joint limits in millidegrees.
Definition Constants.h:67
::uint16_t uint16_t
::int32_t int32_t
motorid_t
The motors on the robot.
Definition data.h:57
Collection of functions for manipulating a motor.
Definition ArduPilotInterface.cpp:27
constexpr std::chrono::milliseconds TELEM_PERIOD(50)
The default telemetry period for motors.
constexpr auto motorSerialIDMap
A mapping of motorids to their corresponding serial number.
Definition real_world_constants.h:82
constexpr auto positive_pwm_scales
A mapping of motorids to power scale factors when commanded with positive power.
Definition real_world_constants.h:124
constexpr auto motorPIDMap
A mapping of PID controlled motors to their pid coefficients.
Definition real_world_constants.h:117
constexpr auto negative_pwm_scales
A mapping of motorids to power scale factors when commanded with negative power.
Definition real_world_constants.h:144
Definition real_world_constants.h:46
int limitSwitchHigh
Limit switch high, in millidegrees.
Definition real_world_constants.h:54
double zeroCalibrationPower
Power value set during limit switch calibration.
Definition real_world_constants.h:56
bool isInverted
Whether the encoder motor is inverted.
Definition real_world_constants.h:48
int ppjr
Encoder pulses count per joint revolution.
Definition real_world_constants.h:50
int limitSwitchLow
Limit switch low, in millidegrees.
Definition real_world_constants.h:52
A struct containing a set of PID coefficients.
Definition real_world_constants.h:20
Represents parameters defining a potentiometer scale.
Definition real_world_constants.h:35
uint16_t adc_hi
The "high" point on the ADC scale.
Definition real_world_constants.h:41
uint16_t adc_lo
The "low" point on the ADC scale.
Definition real_world_constants.h:37
int32_t mdeg_hi
The "high" point on the joint rotation scale.
Definition real_world_constants.h:43
int32_t mdeg_lo
The "low" point on the joint rotation scale.
Definition real_world_constants.h:39