Daedalus (PY2026)
Codebase for the Husky Robotics 2025-2026 rover Daedalus
Loading...
Searching...
No Matches
Constants.h
1#pragma once
2
3#include "utils/time.h"
4#include "world_interface/data.h"
5
6#include <array>
7#include <chrono>
8#include <cmath>
9#include <string>
10#include <unordered_set>
11
12#include <frozen/unordered_map.h>
13
15using robot::types::jointid_t;
17
22namespace Constants {
23
28namespace Arm {
32extern const double SHOULDER_LENGTH;
36extern const double ELBOW_LENGTH;
37
41extern const double SAFETY_FACTOR;
42
46extern const double MAX_EE_VEL;
47extern const double IK_SOLVER_THRESH;
48extern const int IK_SOLVER_MAX_ITER;
49
55extern const std::array<jointid_t, 2> IK_MOTOR_JOINTS;
56
62extern const std::array<motorid_t, 2> IK_MOTORS;
63
67constexpr frozen::unordered_map<motorid_t, std::pair<int, int>, IK_MOTORS.size()> JOINT_LIMITS{
68 {motorid_t::shoulder, {18200, 152500}}, {motorid_t::elbow, {-169100, 0}}};
69
73constexpr frozen::unordered_map<motorid_t, double, IK_MOTORS.size()> SEGMENT_LENGTHS{
74 {motorid_t::shoulder, 0.3848608}, {motorid_t::elbow, 0.461264}};
75
76} // namespace Arm
77
78
83namespace Drive {
84extern const double ROBOT_LENGTH;
85extern const double ROBOT_WIDTH;
86
90extern const double WHEEL_BASE;
97extern const double EFF_WHEEL_BASE;
98extern const double WHEEL_RADIUS;
99extern const double PWM_PER_RAD_PER_SEC;
105extern const double MAX_DRIVE_PWM;
106
113extern const double MAX_WHEEL_VEL;
120extern const double MAX_DTHETA;
121
127extern const double STEER_EPSILON;
128
129} // namespace Drive
130
131
136namespace Camera {
137extern const CameraID MAST_CAMERA_ID;
138extern const CameraID WRIST_CAMERA_ID;
139extern const CameraID HAND_CAMERA_ID;
140
141extern const std::unordered_set<robot::types::CameraID> CAMERA_SET;
142extern const std::unordered_map<robot::types::CameraID, std::string> CAMERA_CONFIG_PATHS;
143
151extern const int H264_RF_CONSTANT;
152
156extern const std::unordered_map<CameraID, int> STREAM_RFS;
157
158} // namespace Camera
159
160
165namespace Network {
166extern const uint16_t WS_SERVER_PORT;
167
171extern const char* MC_PROTOCOL_NAME;
175extern const char* SIM_PROTOCOL_NAME;
179extern const char* ARDUPILOT_PROTOCOL_NAME;
180
181} // namespace Network
182
183
188namespace Nav {
192extern const double RADIAN_COST;
196extern const double SAFE_RADIUS;
200extern const int MAX_ITERS;
204extern const double PLAN_RESOLUTION;
205extern const double SEARCH_RADIUS_INCREMENT;
206extern const double GPS_WAYPOINT_RADIUS;
207extern const double LANDMARK_WAYPOINT_RADIUS;
211extern const double EPS;
212
213extern const double THETA_KP;
214extern const double DRIVE_VEL;
215extern const double SLOW_DRIVE_THRESHOLD;
216extern const double DONE_THRESHOLD;
220extern const util::dseconds CLOSE_TO_TARGET_DUR_VAL;
221
222} // namespace Nav
223
224
229constexpr auto JOINT_MOTOR_MAP = frozen::make_unordered_map<jointid_t, motorid_t>(
230 {{jointid_t::armBase, motorid_t::armBase},
231 {jointid_t::shoulder, motorid_t::shoulder},
232 {jointid_t::elbow, motorid_t::elbow},
233 {jointid_t::forearm, motorid_t::forearm},
234 {jointid_t::hand, motorid_t::hand},
235 {jointid_t::drillActuator, motorid_t::drillActuator},
236 {jointid_t::drillMotor, motorid_t::drillMotor}});
237
238extern const double CONTROL_HZ;
239
240extern const std::chrono::milliseconds JOINT_POWER_REPEAT_PERIOD;
241extern const std::chrono::milliseconds ARM_IK_UPDATE_PERIOD;
242
243} // namespace Constants
duration< int64_t, milli > milliseconds
Arm constants.
Definition Constants.cpp:7
const double ELBOW_LENGTH
Length of the Elbow link, in meters.
Definition Constants.cpp:9
const double SAFETY_FACTOR
Percentage of fully extended overall arm length to limit arm extension within.
Definition Constants.cpp:10
const double SHOULDER_LENGTH
Length of the Shoulder link, in meters.
Definition Constants.cpp:8
const std::array< robot::types::jointid_t, 2 > IK_MOTOR_JOINTS
The joints corresponding to the motors used for IK in the arm.
Definition Constants.cpp:15
const std::array< robot::types::motorid_t, 2 > IK_MOTORS
The motors used in IK.
Definition Constants.cpp:18
constexpr frozen::unordered_map< motorid_t, double, IK_MOTORS.size()> SEGMENT_LENGTHS
Map from motor ids to segment length in meters.
Definition Constants.h:73
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
const double MAX_EE_VEL
Maximum commanded end-effector velocity, in m/s.
Definition Constants.cpp:11
Camera constants.
Definition Constants.cpp:46
const std::unordered_map< robot::types::CameraID, int > STREAM_RFS
Stream-specific RF constants.
Definition Constants.cpp:64
const int H264_RF_CONSTANT
Default RF constant for H264 streams, if not specified in STREAM_RFS.
Definition Constants.cpp:63
const double MAX_WHEEL_VEL
Maximum tangential velocity for the rover's wheels.
Definition Constants.cpp:37
const double MAX_DRIVE_PWM
Can be up to 2^15 - 1 (32767), but we have limited it because driving at full speed draws a massive a...
Definition Constants.cpp:35
const double EFF_WHEEL_BASE
Effective distance between wheels.
Definition Constants.cpp:32
const double MAX_DTHETA
Maximum angular velocity (i.e.
Definition Constants.cpp:39
const double WHEEL_BASE
Distance between left and right wheels.
Definition Constants.cpp:31
const double STEER_EPSILON
Represents the allowable error in millidegrees for steer motors to still process a drive request.
Definition Constants.cpp:42
Navigation constants.
Definition Constants.cpp:78
const int MAX_ITERS
Max number of nodes expanded during A* search.
Definition Constants.cpp:82
const double RADIAN_COST
Distance (m) we could have traveled forward in the time it takes to turn 1 radian.
Definition Constants.cpp:80
const double PLAN_RESOLUTION
In meters.
Definition Constants.cpp:83
const double SAFE_RADIUS
Planner stays this far away from obstacles (m)
Definition Constants.cpp:81
const util::dseconds CLOSE_TO_TARGET_DUR_VAL
Duration long enough to confirm we are there, not so long that time is wasted.
Definition Constants.cpp:93
const double EPS
Heuristic weight for weighted A*.
Definition Constants.cpp:87
Network constants.
Definition Constants.cpp:69
const char * ARDUPILOT_PROTOCOL_NAME
Websocket server endpoint for ArduPilot protocol.
Definition Constants.cpp:74
const char * SIM_PROTOCOL_NAME
WebSocket server endpoint for the simulator protocol.
Definition Constants.cpp:73
const char * MC_PROTOCOL_NAME
WebSocket server endpoint for the mission control protocol.
Definition Constants.cpp:72
Collection of all constants used.
Definition Constants.cpp:5
constexpr auto JOINT_MOTOR_MAP
A map that pairs each of the joints to its corresponding motor.
Definition Constants.h:229
::uint16_t uint16_t
std::string CameraID
The type of a camera id.
Definition data.h:46
motorid_t
The motors on the robot.
Definition data.h:57