Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
types.cpp
Go to the documentation of this file.
1#include "types.hpp"
2
3LandmarkType stringToLandmarkType(const std::string& in)
4{
6 if (in == "blue")
7 {
9 }
10 else if (in == "yellow")
11 {
13 }
14 else if (in == "small-orange" || in == "orange")
15 {
17 }
18 else if (in == "big-orange")
19 {
21 }
22 else if (in == "timekeeping")
23 {
25 }
26 else if (in == "invisible")
27 {
29 }
30 return ret;
31}
32
34{
35 LandmarkList ret;
36 // TODO: no copy for lists
37 std::vector<std::vector<Landmark>> lists { in.left_lane, in.right_lane, in.unknown };
38 for (auto& list : lists)
39 {
40 for (Landmark lm : list)
41 {
42 ret.list.push_back(lm);
43 }
44 }
45 for (auto& p : in.time_keeping_gates)
46 {
47 ret.list.push_back(p.first);
48 ret.list.push_back(p.second);
49 }
50 return ret;
51}
52
54{
55 Track ret;
56 for (auto& lm : in.list)
57 {
58 ret.unknown.push_back(lm);
59 }
60 return ret;
61}
62
63Discipline stringToDiscipline(const std::string& disciplineStr)
64{
66 if (disciplineStr == "autocross")
67 {
69 }
70 else if (disciplineStr == "trackdrive")
71 {
73 }
74 else if (disciplineStr == "acceleration")
75 {
77 }
78 else if (disciplineStr == "skidpad")
79 {
81 }
82 return discipline;
83}
std::string discipline
std::vector< Landmark > list
Definition types.hpp:51
std::vector< std::pair< Landmark, Landmark > > time_keeping_gates
Definition types.hpp:45
std::vector< Landmark > left_lane
Definition types.hpp:42
std::vector< Landmark > unknown
Definition types.hpp:44
std::vector< Landmark > right_lane
Definition types.hpp:43
Discipline stringToDiscipline(const std::string &disciplineStr)
Definition types.cpp:63
Track lmListToTrack(LandmarkList &in)
Definition types.cpp:53
LandmarkList trackToLMList(Track &in)
Definition types.cpp:33
LandmarkType stringToLandmarkType(const std::string &in)
Definition types.cpp:3
Discipline
Definition types.hpp:172
@ SKIDPAD
Definition types.hpp:176
@ AUTOCROSS
Definition types.hpp:173
@ ACCELERATION
Definition types.hpp:175
@ TRACKDRIVE
Definition types.hpp:174
LandmarkType
Definition types.hpp:9
@ BLUE
Definition types.hpp:10
@ INVISIBLE
Definition types.hpp:15
@ BIG_ORANGE
Definition types.hpp:13
@ TIMEKEEPING
Definition types.hpp:14
@ UNKNOWN
Definition types.hpp:17
@ ORANGE
Definition types.hpp:12
@ YELLOW
Definition types.hpp:11