3#include "../navtypes.h"
12#include <frozen/string.h>
13#include <frozen/unordered_map.h>
14#include <frozen/unordered_set.h>
99constexpr auto all_jointid_t = frozen::make_unordered_set<jointid_t>(
100 {jointid_t::armBase, jointid_t::shoulder, jointid_t::elbow, jointid_t::forearm,
101 jointid_t::wristRoll, jointid_t::wristPitch, jointid_t::hand, jointid_t::ikForward,
102 jointid_t::ikUp, jointid_t::fourBarLinkage, jointid_t::drillActuator, jointid_t::drillMotor});
104constexpr auto name_to_jointid = frozen::make_unordered_map<frozen::string, jointid_t>(
105 {{
"armBase", jointid_t::armBase},
106 {
"shoulder", jointid_t::shoulder},
107 {
"elbow", jointid_t::elbow},
108 {
"forearm", jointid_t::forearm},
109 {
"wristPitch", jointid_t::wristPitch},
110 {
"wristRoll", jointid_t::wristRoll},
111 {
"hand", jointid_t::hand},
112 {
"ikForward", jointid_t::ikForward},
113 {
"ikUp", jointid_t::ikUp},
114 {
"fourBarLinkage", jointid_t::fourBarLinkage},
115 {
"drillActuator", jointid_t::drillActuator},
116 {
"drillMotor", jointid_t::drillMotor}});
118enum class servoid_t {
126constexpr auto all_servoid_t = frozen::make_unordered_set<servoid_t>(
127 {servoid_t::microscope, servoid_t::syringe, servoid_t::soilBox,
128 servoid_t::cuvette, servoid_t::filter});
130constexpr auto name_to_servoid = frozen::make_unordered_map<frozen::string, servoid_t>(
131 {{
"microscope", servoid_t::microscope},
132 {
"syringe", servoid_t::syringe},
133 {
"cuvette", servoid_t::cuvette},
134 {
"filter", servoid_t::filter},
135 {
"soilBox", servoid_t::soilBox}});
137constexpr auto servoid_to_servo_num = frozen::make_unordered_map<servoid_t, int>(
138 {{servoid_t::microscope, 7},
139 {servoid_t::syringe, 9},
140 {servoid_t::cuvette, 5},
141 {servoid_t::filter, 8},
142 {servoid_t::soilBox, 6}});
144enum class stepperid_t {
152constexpr auto all_stepperid_t = frozen::make_unordered_set<stepperid_t>(
153 {stepperid_t::plunger, stepperid_t::judges, stepperid_t::mast,
154 stepperid_t::lock, stepperid_t::lazySusan});
156constexpr auto name_to_stepperid = frozen::make_unordered_map<frozen::string, stepperid_t>(
157 {{
"plunger", stepperid_t::plunger},
158 {
"judges", stepperid_t::judges},
159 {
"mast", stepperid_t::mast},
160 {
"lock", stepperid_t::lock},
161 {
"lazySusan", stepperid_t::lazySusan}});
163constexpr auto stepperid_to_stepper_num = frozen::make_unordered_map<stepperid_t, uint8_t>(
164 {{stepperid_t::plunger, 4},
165 {stepperid_t::judges, 5},
166 {stepperid_t::mast, 2},
167 {stepperid_t::lock, 1},
168 {stepperid_t::lazySusan, 6}});
208 operator bool()
const {
229 return datapoint.has_value();
239 return datapoint.value().first;
250 return datapoint.value().second;
276 template <
typename F>
289 std::optional<std::pair<datatime_t, T>> datapoint;
297constexpr int LIMIT_SWITCH_LIM_MIN_IDX = 0;
298constexpr int LIMIT_SWITCH_LIM_MAX_IDX = 1;
367std::string to_string(robot::types::jointid_t joint);
370std::string to_string(robot::types::servoid_t servo);
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
duration< int64_t, milli > milliseconds
DataPoint()
Construct an invalid DataPoint, holding no data.
Definition data.h:186
LimitSwitchData(unsigned long long data)
Construct a new LimitSwitchData object, from the given bits.
Definition data.cpp:5
Represents data measured using a sensor at a given time.
Definition data.h:181
bool isFresh(std::chrono::milliseconds duration) const
Check if this measurement was taken recently.
Definition data.h:219
DataPoint(T data)
Construct a new DataPoint object, measured now.
Definition data.h:193
T getData() const
Get the value of this data point.
Definition data.h:248
DataPoint(datatime_t time, T data)
Construct a new DataPoint object, measured at the given time.
Definition data.h:201
datatime_t getTime() const
Get the time at which the measurement was taken.
Definition data.h:238
bool isValid() const
Check if this measurement is valid.
Definition data.h:228
DataPoint()
Construct an invalid DataPoint, holding no data.
Definition data.h:186
DataPoint< std::invoke_result_t< F, T > > transform(const F &f)
Transforms the data in this datapoint by the given function.
Definition data.h:277
T getDataOrElse(T defaultData)
Get the value of this data point, defaulting to a given value if this data point is invalid.
Definition data.h:263
std::bitset< N_LIMIT_SWITCH > diff(const LimitSwitchData &other)
Check which indices differ between this data and other.
Definition data.cpp:23
LimitSwitchData(unsigned long long data)
Construct a new LimitSwitchData object, from the given bits.
Definition data.cpp:5
bool isAnyClosed()
Check if any index is closed.
Definition data.cpp:15
bool isAnyOpen()
Check if any index is open.
Definition data.cpp:19
bool isClosed(size_t idx)
Check if the given index is closed.
Definition data.cpp:11
bool isOpen(size_t idx)
Check if the given index is open.
Definition data.cpp:7
Types for use in the world interface.
Definition data.cpp:3
indication_t
An indication enum, used to command the LED to flash different signals.
Definition data.h:49
std::chrono::time_point< dataclock > datatime_t
A point in time as measured by dataclock.
Definition data.h:31
motorid_t
The motors on the robot.
Definition data.h:57
std::vector< DataPoint< navtypes::point_t > > landmarks_t
A data structure that represents when each landmark was seen.
Definition data.h:41
mountedperipheral_t
the mounted peripheral on the robot.
Definition data.h:77
std::pair< cv::Mat, uint32_t > CameraFrame
A pair of a camera frame and its corresponding frame number.
Definition data.h:44
uint32_t CameraID
The type of a camera id.
Definition data.h:46
std::chrono::steady_clock dataclock
The clock used for time measurements for data.
Definition data.h:29
constexpr size_t N_LIMIT_SWITCH
The maximum number of limit switches associated with any motor.
Definition data.h:295
A collection of utility functions and classes with common use-cases.
Definition SwerveController.cpp:145