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
13namespace Constants {
14// TODO: make sure these are still accurate with the new arm.
15extern const double SHOULDER_LENGTH;
16extern const double ELBOW_LENGTH;
17
21extern const float MDEG_PER_DEG;
22
23// TODO: tune these drive extern constants
24extern const double ROBOT_LENGTH;
25extern const double ROBOT_WIDTH;
29extern const double WHEEL_BASE;
34extern const double EFF_WHEEL_BASE;
35extern const double WHEEL_RADIUS;
36extern const double PWM_PER_RAD_PER_SEC;
37extern const double MAX_DRIVE_PWM;
38
45extern const double MAX_WHEEL_VEL;
52extern const double MAX_DTHETA;
53
54// TODO: We need to recalibrate the camera, since we replaced it with a different one.
55// TODO: rename cameras (in MC as well) as appropriate
56extern const char* MAST_CAMERA_CONFIG_PATH;
57extern const robot::types::CameraID MAST_CAMERA_ID;
58
59extern const char* FOREARM_CAMERA_CONFIG_PATH;
60extern const robot::types::CameraID FOREARM_CAMERA_ID;
61
62extern const char* HAND_CAMERA_CONFIG_PATH;
63extern const robot::types::CameraID HAND_CAMERA_ID;
64
65extern const uint16_t WS_SERVER_PORT;
66
70extern const char* MC_PROTOCOL_NAME;
74extern const char* SIM_PROTOCOL_NAME;
78extern const char* DGPS_PROTOCOL_NAME;
82extern const char* ARDUPILOT_PROTOCOL_NAME;
83
84extern const std::chrono::milliseconds JOINT_POWER_REPEAT_PERIOD;
85extern const std::chrono::milliseconds ARM_IK_UPDATE_PERIOD;
86
87namespace Drive {
88// Represents the allowable error in millidegrees for steer motors to still process a drive
89// request. That is, we make sure all the wheels are close enough to their target rotation
90// before actually driving.
91extern const double STEER_EPSILON;
92} // namespace Drive
93
94namespace Nav {
95// Distance (m) we could have traveled forward in the time it takes to turn 1 radian
96extern const double RADIAN_COST;
97// Planner stays this far away from obstacles (m)
98extern const double SAFE_RADIUS;
99extern const int MAX_ITERS;
100extern const double PLAN_RESOLUTION;
101extern const double SEARCH_RADIUS_INCREMENT;
102extern const double GPS_WAYPOINT_RADIUS;
103extern const double LANDMARK_WAYPOINT_RADIUS;
104extern const double EPS;
105} // namespace Nav
106
107// Lidar
108namespace Lidar {
109extern const std::string RP_PATH;
110extern const double MM_PER_M;
111extern const uint32_t RPLIDAR_A1_BAUDRATE;
112extern const uint32_t RPLIDAR_S1_BAUDRATE;
113} // namespace Lidar
114
115// Video encoding
116namespace video {
124extern const int H264_RF_CONSTANT;
125
129extern const std::unordered_map<robot::types::CameraID, int> STREAM_RFS;
130} // namespace video
131
136constexpr auto JOINT_MOTOR_MAP =
137 frozen::make_unordered_map<robot::types::jointid_t, robot::types::motorid_t>(
138 {{robot::types::jointid_t::frontLeftSwerve, robot::types::motorid_t::frontLeftSwerve},
139 {robot::types::jointid_t::frontRightSwerve,
140 robot::types::motorid_t::frontRightSwerve},
141 {robot::types::jointid_t::rearLeftSwerve, robot::types::motorid_t::rearLeftSwerve},
142 {robot::types::jointid_t::rearRightSwerve, robot::types::motorid_t::rearRightSwerve},
143 {robot::types::jointid_t::armBase, robot::types::motorid_t::armBase},
144 {robot::types::jointid_t::shoulder, robot::types::motorid_t::shoulder},
145 {robot::types::jointid_t::elbow, robot::types::motorid_t::elbow},
146 {robot::types::jointid_t::forearm, robot::types::motorid_t::forearm},
147 {robot::types::jointid_t::hand, robot::types::motorid_t::hand},
148 {robot::types::jointid_t::activeSuspension,
149 robot::types::motorid_t::activeSuspension}});
150
151// Arm inverse kinematics
152namespace arm {
156extern const double SAFETY_FACTOR;
157
161extern const double MAX_EE_VEL;
162extern const double IK_SOLVER_THRESH;
163
164extern const int IK_SOLVER_MAX_ITER;
165
170extern const std::array<robot::types::jointid_t, 2> IK_MOTOR_JOINTS;
171
176extern const std::array<robot::types::motorid_t, 2> IK_MOTORS;
177
181constexpr frozen::unordered_map<robot::types::motorid_t, std::pair<int, int>, IK_MOTORS.size()>
182 JOINT_LIMITS{{robot::types::motorid_t::shoulder, {18200, 152500}},
183 {robot::types::motorid_t::elbow, {-169100, 0}}};
184
188constexpr frozen::unordered_map<robot::types::motorid_t, double, IK_MOTORS.size()>
189 SEGMENT_LENGTHS{{robot::types::motorid_t::shoulder, 0.3848608},
190 {robot::types::motorid_t::elbow, 0.461264}};
191} // namespace arm
192
193namespace autonomous {
194extern const double THETA_KP;
195extern const double DRIVE_VEL;
196extern const double SLOW_DRIVE_THRESHOLD;
197extern const double DONE_THRESHOLD;
198// Duration long enough to confirm we are there, not so long that time is wasted
199extern const util::dseconds CLOSE_TO_TARGET_DUR_VAL;
200} // namespace autonomous
201
202extern const double CONTROL_HZ;
203
204} // namespace Constants
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
duration< int64_t, milli > milliseconds
::uint32_t uint32_t
::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