Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
color.cpp
Go to the documentation of this file.
2
4const std::map<std::string, Color, std::less<>> STRING_TO_COLOR = {
5 {"blue_cone", Color::BLUE}, {"yellow_cone", Color::YELLOW},
6 {"orange_cone", Color::ORANGE}, {"large_orange_cone", Color::LARGE_ORANGE},
7 {"unknown", Color::UNKNOWN},
8};
9
10const std::map<Color, std::string> COLOR_TO_STRING = {
11 {Color::BLUE, "blue_cone"}, {Color::YELLOW, "yellow_cone"},
12 {Color::ORANGE, "orange_cone"}, {Color::LARGE_ORANGE, "large_orange_cone"},
13 {Color::UNKNOWN, "unknown"},
14};
15
16std::string get_color_string(int color) {
17 return COLOR_TO_STRING.find(static_cast<Color>(color))->second;
18}
19
20std::string get_color_string(Color color) { return COLOR_TO_STRING.find(color)->second; }
21
22Color get_color_enum(const std::string& color) { return STRING_TO_COLOR.find(color)->second; }
23
24bool operator==(const Color& color, const int& value) { return static_cast<int>(color) == value; }
25
26bool operator==(const int& value, const Color& color) { return static_cast<int>(color) == value; }
27
28} // namespace common_lib::competition_logic
const std::map< Color, std::string > COLOR_TO_STRING
Definition color.cpp:10
const std::map< std::string, Color, std::less<> > STRING_TO_COLOR
Definition color.cpp:4
bool operator==(const Color &color, const int &value)
Definition color.cpp:24
Color get_color_enum(const std::string &color)
Definition color.cpp:22
std::string get_color_string(int color)
Definition color.cpp:16