Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
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
18namespace Constants {
19// TODO: make sure these are still accurate with the new arm.
20extern const double SHOULDER_LENGTH;
21extern const double ELBOW_LENGTH;
22
26extern const float MDEG_PER_DEG;
27
28// TODO: tune these drive extern constants
29extern const double ROBOT_LENGTH;
30extern const double ROBOT_WIDTH;
34extern const double WHEEL_BASE;
39extern const double EFF_WHEEL_BASE;
40extern const double WHEEL_RADIUS;
41extern const double PWM_PER_RAD_PER_SEC;
42extern const double MAX_DRIVE_PWM;
43
50extern const double MAX_WHEEL_VEL;
57extern const double MAX_DTHETA;
58
59// TODO: We need to recalibrate the camera, since we replaced it with a different one.
60// TODO: rename cameras (in MC as well) as appropriate
61extern const CameraID MAST_CAMERA_ID;
62extern const CameraID WRIST_CAMERA_ID;
63extern const CameraID HAND_CAMERA_ID;
64
65extern const std::unordered_set<robot::types::CameraID> CAMERA_SET;
66
67extern const std::unordered_map<robot::types::CameraID, std::string> CAMERA_CONFIG_PATHS;
68
69extern const uint16_t WS_SERVER_PORT;
70
74extern const char* MC_PROTOCOL_NAME;
78extern const char* SIM_PROTOCOL_NAME;
82extern const char* DGPS_PROTOCOL_NAME;
86extern const char* ARDUPILOT_PROTOCOL_NAME;
87
88extern const std::chrono::milliseconds JOINT_POWER_REPEAT_PERIOD;
89extern const std::chrono::milliseconds ARM_IK_UPDATE_PERIOD;
90
91namespace Drive {
92// Represents the allowable error in millidegrees for steer motors to still process a drive
93// request. That is, we make sure all the wheels are close enough to their target rotation
94// before actually driving.
95extern const double STEER_EPSILON;
96} // namespace Drive
97
98namespace Nav {
99// Distance (m) we could have traveled forward in the time it takes to turn 1 radian
100extern const double RADIAN_COST;
101// Planner stays this far away from obstacles (m)
102extern const double SAFE_RADIUS;
103extern const int MAX_ITERS;
104extern const double PLAN_RESOLUTION;
105extern const double SEARCH_RADIUS_INCREMENT;
106extern const double GPS_WAYPOINT_RADIUS;
107extern const double LANDMARK_WAYPOINT_RADIUS;
108extern const double EPS;
109} // namespace Nav
110
111// Video encoding
112namespace video {
120extern const int H264_RF_CONSTANT;
121
125extern const std::unordered_map<CameraID, int> STREAM_RFS;
126} // namespace video
127
132constexpr auto JOINT_MOTOR_MAP = frozen::make_unordered_map<jointid_t, motorid_t>(
133 {{jointid_t::armBase, motorid_t::armBase},
134 {jointid_t::shoulder, motorid_t::shoulder},
135 {jointid_t::elbow, motorid_t::elbow},
136 {jointid_t::forearm, motorid_t::forearm},
137 {jointid_t::hand, motorid_t::hand},
138 {jointid_t::drillActuator, motorid_t::drillActuator},
139 {jointid_t::drillMotor, motorid_t::drillMotor}});
140
141// Arm inverse kinematics
142namespace arm {
146extern const double SAFETY_FACTOR;
147
151extern const double MAX_EE_VEL;
152extern const double IK_SOLVER_THRESH;
153
154extern const int IK_SOLVER_MAX_ITER;
155
160extern const std::array<jointid_t, 2> IK_MOTOR_JOINTS;
161
166extern const std::array<motorid_t, 2> IK_MOTORS;
167
171constexpr frozen::unordered_map<motorid_t, std::pair<int, int>, IK_MOTORS.size()> JOINT_LIMITS{
172 {motorid_t::shoulder, {18200, 152500}}, {motorid_t::elbow, {-169100, 0}}};
173
177constexpr frozen::unordered_map<motorid_t, double, IK_MOTORS.size()> SEGMENT_LENGTHS{
178 {motorid_t::shoulder, 0.3848608}, {motorid_t::elbow, 0.461264}};
179} // namespace arm
180
181namespace autonomous {
182extern const double THETA_KP;
183extern const double DRIVE_VEL;
184extern const double SLOW_DRIVE_THRESHOLD;
185extern const double DONE_THRESHOLD;
186// Duration long enough to confirm we are there, not so long that time is wasted
187extern const util::dseconds CLOSE_TO_TARGET_DUR_VAL;
188} // namespace autonomous
189
190extern const double CONTROL_HZ;
191
192} // namespace Constants
duration< int64_t, milli > milliseconds
::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