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
11#include <frozen/unordered_map.h>
12
14using robot::types::jointid_t;
16
17namespace Constants {
18// TODO: make sure these are still accurate with the new arm.
19extern const double SHOULDER_LENGTH;
20extern const double ELBOW_LENGTH;
21
25extern const float MDEG_PER_DEG;
26
27// TODO: tune these drive extern constants
28extern const double ROBOT_LENGTH;
29extern const double ROBOT_WIDTH;
33extern const double WHEEL_BASE;
38extern const double EFF_WHEEL_BASE;
39extern const double WHEEL_RADIUS;
40extern const double PWM_PER_RAD_PER_SEC;
41extern const double MAX_DRIVE_PWM;
42
49extern const double MAX_WHEEL_VEL;
56extern const double MAX_DTHETA;
57
58// TODO: We need to recalibrate the camera, since we replaced it with a different one.
59// TODO: rename cameras (in MC as well) as appropriate
60extern const CameraID MAST_CAMERA_ID;
61extern const CameraID WRIST_CAMERA_ID;
62extern const CameraID HAND_CAMERA_ID;
63extern const CameraID RAND_CAMERA_ID;
64extern const CameraID CJ1_CAMERA_ID;
65extern const CameraID BOX_CAMERA_ID;
66extern const CameraID CJ3_CAMERA_ID;
67extern const CameraID DRILL_CAMERA_ID;
68extern const CameraID MICROSCOPE_ID;
69
70extern const std::unordered_map<robot::types::CameraID, std::string> CAMERA_CONFIG_PATHS;
71
72extern const uint16_t WS_SERVER_PORT;
73
77extern const char* MC_PROTOCOL_NAME;
81extern const char* SIM_PROTOCOL_NAME;
85extern const char* DGPS_PROTOCOL_NAME;
89extern const char* ARDUPILOT_PROTOCOL_NAME;
90
91extern const std::chrono::milliseconds JOINT_POWER_REPEAT_PERIOD;
92extern const std::chrono::milliseconds ARM_IK_UPDATE_PERIOD;
93
94namespace Drive {
95// Represents the allowable error in millidegrees for steer motors to still process a drive
96// request. That is, we make sure all the wheels are close enough to their target rotation
97// before actually driving.
98extern const double STEER_EPSILON;
99} // namespace Drive
100
101namespace Nav {
102// Distance (m) we could have traveled forward in the time it takes to turn 1 radian
103extern const double RADIAN_COST;
104// Planner stays this far away from obstacles (m)
105extern const double SAFE_RADIUS;
106extern const int MAX_ITERS;
107extern const double PLAN_RESOLUTION;
108extern const double SEARCH_RADIUS_INCREMENT;
109extern const double GPS_WAYPOINT_RADIUS;
110extern const double LANDMARK_WAYPOINT_RADIUS;
111extern const double EPS;
112} // namespace Nav
113
114// Video encoding
115namespace video {
123extern const int H264_RF_CONSTANT;
124
128extern const std::unordered_map<CameraID, int> STREAM_RFS;
129} // namespace video
130
135constexpr auto JOINT_MOTOR_MAP = frozen::make_unordered_map<jointid_t, motorid_t>(
136 {{jointid_t::armBase, motorid_t::armBase},
137 {jointid_t::shoulder, motorid_t::shoulder},
138 {jointid_t::elbow, motorid_t::elbow},
139 {jointid_t::forearm, motorid_t::forearm},
140 {jointid_t::hand, motorid_t::hand},
141 {jointid_t::drillActuator, motorid_t::drillActuator},
142 {jointid_t::drillMotor, motorid_t::drillMotor}});
143
144// Arm inverse kinematics
145namespace arm {
149extern const double SAFETY_FACTOR;
150
154extern const double MAX_EE_VEL;
155extern const double IK_SOLVER_THRESH;
156
157extern const int IK_SOLVER_MAX_ITER;
158
163extern const std::array<jointid_t, 2> IK_MOTOR_JOINTS;
164
169extern const std::array<motorid_t, 2> IK_MOTORS;
170
174constexpr frozen::unordered_map<motorid_t, std::pair<int, int>, IK_MOTORS.size()> JOINT_LIMITS{
175 {motorid_t::shoulder, {18200, 152500}}, {motorid_t::elbow, {-169100, 0}}};
176
180constexpr frozen::unordered_map<motorid_t, double, IK_MOTORS.size()> SEGMENT_LENGTHS{
181 {motorid_t::shoulder, 0.3848608}, {motorid_t::elbow, 0.461264}};
182} // namespace arm
183
184namespace autonomous {
185extern const double THETA_KP;
186extern const double DRIVE_VEL;
187extern const double SLOW_DRIVE_THRESHOLD;
188extern const double DONE_THRESHOLD;
189// Duration long enough to confirm we are there, not so long that time is wasted
190extern const util::dseconds CLOSE_TO_TARGET_DUR_VAL;
191} // namespace autonomous
192
193extern const double CONTROL_HZ;
194
195} // namespace Constants
duration< int64_t, milli > milliseconds
::uint16_t uint16_t
motorid_t
The motors on the robot.
Definition data.h:57
uint32_t CameraID
The type of a camera id.
Definition data.h:46