scenario_simulator_v2 C++ API
traffic_light.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_HPP_
16 #define TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_HPP_
17 
18 #include <simulation_api_schema.pb.h>
19 
20 #include <color_names/color_names.hpp>
21 #include <cstdint>
22 #include <geometry_msgs/msg/point.hpp>
23 #include <iostream>
24 #include <limits>
25 #include <memory>
26 #include <optional>
27 #include <regex>
29 #include <set>
30 #include <stdexcept>
32 #include <traffic_simulator_msgs/msg/traffic_light_array_v1.hpp>
33 #include <tuple>
34 #include <type_traits>
35 #include <unordered_map>
36 #include <utility>
37 #include <vector>
38 
39 namespace traffic_simulator
40 {
42 {
43  struct Color
44  {
45  enum Value : std::uint8_t {
48  red,
50  } value;
51 
52  // clang-format off
53  static_assert(static_cast<std::uint8_t>(green ) == 0b0000'0000);
54  static_assert(static_cast<std::uint8_t>(yellow) == 0b0000'0001);
55  static_assert(static_cast<std::uint8_t>(red ) == 0b0000'0010);
56  static_assert(static_cast<std::uint8_t>(white ) == 0b0000'0011);
57  // clang-format on
58 
59  constexpr Color(const Value value = green) : value(value) {}
60 
61  Color(const std::string & name) : value(make(name)) {}
62 
63  static inline const std::unordered_map<std::string, Value> table{
64  std::make_pair("amber", yellow),
65  std::make_pair("green", green),
66  std::make_pair("red", red),
67  std::make_pair("white", white),
68  std::make_pair("yellow", yellow),
69 
70  // BACKWARD COMPATIBILITY
71  std::make_pair("Green", green),
72  std::make_pair("Red", red),
73  std::make_pair("Yellow", yellow),
74  };
75 
76  static auto make(const std::string & name) -> Color;
77 
78  constexpr auto is(const Color given) const { return value == given; }
79 
80  constexpr operator Value() const noexcept { return value; }
81 
82  friend auto operator>>(std::istream & is, Color & color) -> std::istream &;
83 
84  friend auto operator<<(std::ostream & os, const Color & color) -> std::ostream &;
85  };
86 
87  struct Status
88  {
89  enum Value : std::uint8_t {
94  } value;
95 
96  // clang-format off
97  static_assert(static_cast<std::uint8_t>(solid_on ) == 0b0000'0000);
98  static_assert(static_cast<std::uint8_t>(solid_off) == 0b0000'0001);
99  static_assert(static_cast<std::uint8_t>(flashing ) == 0b0000'0010);
100  static_assert(static_cast<std::uint8_t>(unknown ) == 0b0000'0011);
101  // clang-format on
102 
103  constexpr Status(const Value value = solid_on) : value(value) {}
104 
105  Status(const std::string & name) : value(make(name)) {}
106 
107  static inline const std::unordered_map<std::string, Value> table{
108  std::make_pair("solidOn", solid_on),
109  std::make_pair("solidOff", solid_off),
110  std::make_pair("flashing", flashing),
111  std::make_pair("unknown", unknown),
112 
113  // BACKWARD COMPATIBILITY
114  std::make_pair("Blank", solid_off),
115  std::make_pair("none", solid_off),
116  };
117 
118  static auto make(const std::string & name) -> Status;
119 
120  constexpr auto is(const Value given) const { return value == given; }
121 
122  constexpr operator bool() const { return value == solid_on or value == flashing; }
123 
124  constexpr operator Value() const noexcept { return value; }
125 
126  friend auto operator>>(std::istream & is, Status & status) -> std::istream &;
127 
128  friend auto operator<<(std::ostream & os, const Status & status) -> std::ostream &;
129  };
130 
131  struct Shape
132  {
133  enum class Category : std::uint8_t {
134  circle,
135  cross,
136  arrow,
137  };
138 
139  // clang-format off
140  static_assert(static_cast<std::uint8_t>(Category::circle) == 0b0000'0000);
141  static_assert(static_cast<std::uint8_t>(Category::cross ) == 0b0000'0001);
142  static_assert(static_cast<std::uint8_t>(Category::arrow ) == 0b0000'0010);
143  // clang-format on
144 
145  enum Value : std::uint16_t {
146  // clang-format off
147  circle = static_cast<std::uint8_t>(Category::circle),
148  cross = static_cast<std::uint8_t>(Category::cross ),
149  left = (0b0000'1000 << 8) | static_cast<std::uint8_t>(Category::arrow ),
150  down = (0b0000'0100 << 8) | static_cast<std::uint8_t>(Category::arrow ),
151  up = (0b0000'0010 << 8) | static_cast<std::uint8_t>(Category::arrow ),
152  right = (0b0000'0001 << 8) | static_cast<std::uint8_t>(Category::arrow ),
153  lower_left = (0b0000'1100 << 8) | static_cast<std::uint8_t>(Category::arrow ),
154  upper_left = (0b0000'1010 << 8) | static_cast<std::uint8_t>(Category::arrow ),
155  lower_right = (0b0000'0101 << 8) | static_cast<std::uint8_t>(Category::arrow ),
156  upper_right = (0b0000'0011 << 8) | static_cast<std::uint8_t>(Category::arrow ),
157  // clang-format on
158  } value;
159 
160  // clang-format off
161  static_assert(static_cast<std::uint16_t>(circle ) == 0b0000'0000'0000'0000);
162  static_assert(static_cast<std::uint16_t>(cross ) == 0b0000'0000'0000'0001);
163  static_assert(static_cast<std::uint16_t>(left ) == 0b0000'1000'0000'0010);
164  static_assert(static_cast<std::uint16_t>(down ) == 0b0000'0100'0000'0010);
165  static_assert(static_cast<std::uint16_t>(up ) == 0b0000'0010'0000'0010);
166  static_assert(static_cast<std::uint16_t>(right ) == 0b0000'0001'0000'0010);
167  static_assert(static_cast<std::uint16_t>(lower_left ) == 0b0000'1100'0000'0010);
168  static_assert(static_cast<std::uint16_t>(upper_left ) == 0b0000'1010'0000'0010);
169  static_assert(static_cast<std::uint16_t>(lower_right) == 0b0000'0101'0000'0010);
170  static_assert(static_cast<std::uint16_t>(upper_right) == 0b0000'0011'0000'0010);
171  // clang-format on
172 
173  constexpr Shape(const Value value = circle) : value(value) {}
174 
175  Shape(const std::string & name) : value(make(name)) {}
176 
177  static inline const std::unordered_map<std::string, Shape::Value> table{
178  std::make_pair("circle", Shape::circle),
179  std::make_pair("cross", Shape::cross),
180  std::make_pair("left", Shape::left),
181  std::make_pair("down", Shape::down),
182  std::make_pair("up", Shape::up),
183  std::make_pair("right", Shape::right),
184  std::make_pair("lowerLeft", Shape::lower_left),
185  std::make_pair("upperLeft", Shape::upper_left),
186  std::make_pair("lowerRight", Shape::lower_right),
187  std::make_pair("upperRight", Shape::upper_right),
188 
189  // BACKWARD COMPATIBILITY
190  std::make_pair("straight", Shape::up),
191  };
192 
193  static auto make(const std::string & name) -> Shape;
194 
195  constexpr auto category() const
196  {
197  return static_cast<Category>(static_cast<std::uint16_t>(value) & 0b1111'1111);
198  }
199 
200  constexpr auto is(const Value given) const { return value == given; }
201 
202  constexpr auto is(const Category given) const { return category() == given; }
203 
204  constexpr operator Value() const noexcept { return value; }
205 
206  friend auto operator>>(std::istream & is, Shape & shape) -> std::istream &;
207 
208  friend auto operator<<(std::ostream & os, const Shape & shape) -> std::ostream &;
209  };
210 
211  struct Bulb
212  {
213  using Value = std::tuple<Color, Status, Shape>;
214 
215  const Value value;
216 
217  using Hash = std::uint32_t; // (Color::Value << 8 + 16) | (Status::Value << 16) | Shape::Value
218 
219  constexpr Bulb(const Value value) : value(value) {}
220 
221  constexpr Bulb(const Color color = {}, const Status status = {}, const Shape shape = {})
222  : Bulb(std::forward_as_tuple(color, status, shape))
223  {
224  }
225 
226  Bulb(const std::string & name) : Bulb(make(name)) {}
227 
228  auto make(const std::string & s) -> Value;
229 
230  constexpr auto is(const Color color) const { return std::get<Color>(value).is(color); }
231 
232  constexpr auto is(const Status status) const { return std::get<Status>(value).is(status); }
233 
234  constexpr auto is(const Shape shape) const { return std::get<Shape>(value).is(shape); }
235 
236  constexpr auto is(const Shape::Category category) const
237  {
238  return std::get<Shape>(value).is(category);
239  }
240 
241  constexpr auto hash() const -> Hash
242  {
243  return (static_cast<Hash>(std::get<Color>(value).value) << 24) |
244  (static_cast<Hash>(std::get<Status>(value).value) << 16) |
245  static_cast<Hash>(std::get<Shape>(value).value);
246  }
247 
248  friend constexpr auto operator<(const Bulb & lhs, const Bulb & rhs) -> bool
249  {
250  return lhs.hash() < rhs.hash();
251  }
252 
253  friend auto operator<<(std::ostream & os, const Bulb & bulb) -> std::ostream &;
254 
255  explicit operator simulation_api_schema::TrafficLight() const
256  {
257  const auto color = [this]() {
258  auto color_message = simulation_api_schema::TrafficLight_Color_UNKNOWN_COLOR;
259  switch (std::get<Color>(value).value) {
260  case Color::green:
261  color_message = simulation_api_schema::TrafficLight_Color_GREEN;
262  break;
263  case Color::yellow:
264  color_message = simulation_api_schema::TrafficLight_Color_AMBER;
265  break;
266  case Color::red:
267  color_message = simulation_api_schema::TrafficLight_Color_RED;
268  break;
269  case Color::white:
270  color_message = simulation_api_schema::TrafficLight_Color_WHITE;
271  break;
272  }
273  return color_message;
274  };
275 
276  const auto status = [this]() {
277  auto status_message = simulation_api_schema::TrafficLight_Status_UNKNOWN_STATUS;
278  switch (std::get<Status>(value).value) {
279  case Status::solid_on:
280  status_message = simulation_api_schema::TrafficLight_Status_SOLID_ON;
281  break;
282  case Status::solid_off:
283  status_message = simulation_api_schema::TrafficLight_Status_SOLID_OFF;
284  break;
285  case Status::flashing:
286  status_message = simulation_api_schema::TrafficLight_Status_FLASHING;
287  break;
288  case Status::unknown:
289  status_message = simulation_api_schema::TrafficLight_Status_UNKNOWN_STATUS;
290  break;
291  }
292  return status_message;
293  };
294 
295  const auto shape = [this]() {
296  auto shape_message = simulation_api_schema::TrafficLight_Shape_UNKNOWN_SHAPE;
297  switch (std::get<Shape>(value).value) {
298  case Shape::circle:
299  shape_message = simulation_api_schema::TrafficLight_Shape_CIRCLE;
300  break;
301  case Shape::cross:
302  shape_message = simulation_api_schema::TrafficLight_Shape_CROSS;
303  break;
304  case Shape::left:
305  shape_message = simulation_api_schema::TrafficLight_Shape_LEFT_ARROW;
306  break;
307  case Shape::down:
308  shape_message = simulation_api_schema::TrafficLight_Shape_DOWN_ARROW;
309  break;
310  case Shape::up:
311  shape_message = simulation_api_schema::TrafficLight_Shape_UP_ARROW;
312  break;
313  case Shape::right:
314  shape_message = simulation_api_schema::TrafficLight_Shape_RIGHT_ARROW;
315  break;
316  case Shape::lower_left:
317  shape_message = simulation_api_schema::TrafficLight_Shape_DOWN_LEFT_ARROW;
318  break;
319  case Shape::lower_right:
320  shape_message = simulation_api_schema::TrafficLight_Shape_DOWN_RIGHT_ARROW;
321  break;
322  case Shape::upper_left:
323  shape_message = simulation_api_schema::TrafficLight_Shape_UP_LEFT_ARROW;
324  break;
325  case Shape::upper_right:
326  shape_message = simulation_api_schema::TrafficLight_Shape_UP_RIGHT_ARROW;
327  break;
328  }
329  return shape_message;
330  };
331 
332  simulation_api_schema::TrafficLight traffic_light_bulb_proto;
333  traffic_light_bulb_proto.set_status(status());
334  traffic_light_bulb_proto.set_shape(shape());
335  traffic_light_bulb_proto.set_color(color());
336  // NOTE: confidence will be overwritten in TrafficLight::operator simulation_api_schema::TrafficSignal()
337  traffic_light_bulb_proto.set_confidence(1.0);
338 
339  return traffic_light_bulb_proto;
340  }
341 
342  explicit operator traffic_simulator_msgs::msg::TrafficLightBulbV1() const
343  {
344  const auto color = [this] {
345  auto color_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UNKNOWN;
346  switch (std::get<Color>(value).value) {
347  case Color::green:
348  color_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::GREEN;
349  break;
350  case Color::yellow:
351  color_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::AMBER;
352  break;
353  case Color::red:
354  color_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::RED;
355  break;
356  case Color::white:
357  color_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::WHITE;
358  break;
359  }
360  return color_message;
361  };
362 
363  const auto status = [this] {
364  auto status_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UNKNOWN;
365  switch (std::get<Status>(value).value) {
366  case Status::solid_on:
367  status_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::SOLID_ON;
368  break;
369  case Status::solid_off:
370  status_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::SOLID_OFF;
371  break;
372  case Status::flashing:
373  status_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::FLASHING;
374  break;
375  case Status::unknown:
376  status_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UNKNOWN;
377  break;
378  }
379  return status_message;
380  };
381 
382  const auto shape = [this] {
383  auto shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UNKNOWN;
384  switch (std::get<Shape>(value).value) {
385  case Shape::circle:
386  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::CIRCLE;
387  break;
388  case Shape::cross:
389  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::CROSS;
390  break;
391  case Shape::left:
392  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::LEFT_ARROW;
393  break;
394  case Shape::down:
395  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::DOWN_ARROW;
396  break;
397  case Shape::up:
398  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UP_ARROW;
399  break;
400  case Shape::right:
401  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::RIGHT_ARROW;
402  break;
403  case Shape::lower_left:
404  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::DOWN_LEFT_ARROW;
405  break;
406  case Shape::lower_right:
407  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::DOWN_RIGHT_ARROW;
408  break;
409  case Shape::upper_left:
410  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UP_LEFT_ARROW;
411  break;
412  case Shape::upper_right:
413  shape_message = traffic_simulator_msgs::msg::TrafficLightBulbV1::UP_RIGHT_ARROW;
414  break;
415  }
416  return shape_message;
417  };
418 
419  traffic_simulator_msgs::msg::TrafficLightBulbV1 msg;
420  msg.color = color();
421  msg.status = status();
422  msg.shape = shape();
423  // NOTE: confidence will be overwritten
424  msg.confidence = 1.0;
425  // NOTE: unused data member 'enum_revision' for
426  // traffic_simulator_msgs::msg::TrafficLightBulbV1
427  return msg;
428  }
429  };
430 
431  explicit TrafficLight(const lanelet::Id, const hdmap_utils::HdMapUtils &);
432 
433  const lanelet::Id way_id;
434 
435  const lanelet::Ids regulatory_elements_ids;
436 
437  double confidence = 1.0;
438 
439  std::set<Bulb> bulbs;
440 
441  const std::map<Bulb::Hash, std::optional<geometry_msgs::msg::Point>> positions;
442 
443  auto clear() { bulbs.clear(); }
444 
445  auto contains(const Bulb & bulb) const { return bulbs.find(bulb) != std::end(bulbs); }
446 
447  auto contains(const Color & color, const Status & status, const Shape & shape) const
448  {
449  return contains(Bulb(color, status, shape));
450  }
451 
452  auto contains(const std::string & name) const { return contains(Bulb(name)); }
453 
454  template <typename Markers, typename Now>
455  auto draw(Markers & markers, const Now & now, const std::string & frame_id) const
456  {
457  auto optional_position = [this](auto && bulb) {
458  try {
459  return positions.at(bulb.hash() & 0b1111'0000'1111'1111); // NOTE: Ignore status
460  } catch (const std::out_of_range &) {
461  return std::optional<geometry_msgs::msg::Point>(std::nullopt);
462  }
463  };
464 
465  for (const auto & bulb : bulbs) {
466  if (optional_position(bulb).has_value() and bulb.is(Shape::Category::circle)) {
467  visualization_msgs::msg::Marker marker;
468  marker.header.stamp = now;
469  marker.header.frame_id = frame_id;
470  marker.action = marker.ADD;
471  marker.ns = "bulb";
472  marker.id = way_id;
473  marker.type = marker.SPHERE;
474  marker.pose.position = optional_position(bulb).value();
475  marker.pose.orientation = geometry_msgs::msg::Quaternion();
476  marker.scale.x = 0.3;
477  marker.scale.y = 0.3;
478  marker.scale.z = 0.3;
479  marker.color =
480  color_names::makeColorMsg(boost::lexical_cast<std::string>(std::get<Color>(bulb.value)));
481  markers.push_back(marker);
482  }
483  }
484  }
485 
486  template <typename... Ts>
487  auto emplace(Ts &&... xs)
488  {
489  bulbs.emplace(std::forward<decltype(xs)>(xs)...);
490  }
491 
492  auto empty() const { return bulbs.empty(); }
493 
494  auto set(const std::string & states) -> void;
495 
496  friend auto operator<<(std::ostream & os, const TrafficLight & traffic_light) -> std::ostream &;
497 
498  explicit operator simulation_api_schema::TrafficSignal() const
499  {
500  simulation_api_schema::TrafficSignal traffic_signal_proto;
501 
502  traffic_signal_proto.set_id(way_id);
503  for (const auto & bulb : bulbs) {
504  auto traffic_light_bulb_proto = static_cast<simulation_api_schema::TrafficLight>(bulb);
505  traffic_light_bulb_proto.set_confidence(confidence);
506  *traffic_signal_proto.add_traffic_light_status() = traffic_light_bulb_proto;
507  }
508  return traffic_signal_proto;
509  }
510 
511  explicit operator traffic_simulator_msgs::msg::TrafficLightV1() const
512  {
513  traffic_simulator_msgs::msg::TrafficLightV1 traffic_signal;
514  traffic_signal.lanelet_way_id = way_id;
515  for (const auto & bulb : bulbs) {
516  auto traffic_light_bulb = static_cast<traffic_simulator_msgs::msg::TrafficLightBulbV1>(bulb);
517  traffic_light_bulb.confidence = confidence;
518  traffic_signal.traffic_light_bulbs.push_back(traffic_light_bulb);
519  }
520  return traffic_signal;
521  }
522 };
523 } // namespace traffic_simulator
524 
525 #endif // TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_HPP_
Definition: hdmap_utils.hpp:62
Definition: api.hpp:49
Definition: junit5.hpp:25
std::string string
Definition: junit5.hpp:26
Definition: traffic_light.hpp:212
constexpr auto is(const Shape shape) const
Definition: traffic_light.hpp:234
std::tuple< Color, Status, Shape > Value
Definition: traffic_light.hpp:213
constexpr auto hash() const -> Hash
Definition: traffic_light.hpp:241
constexpr Bulb(const Value value)
Definition: traffic_light.hpp:219
constexpr Bulb(const Color color={}, const Status status={}, const Shape shape={})
Definition: traffic_light.hpp:221
Bulb(const std::string &name)
Definition: traffic_light.hpp:226
constexpr friend auto operator<(const Bulb &lhs, const Bulb &rhs) -> bool
Definition: traffic_light.hpp:248
constexpr auto is(const Color color) const
Definition: traffic_light.hpp:230
friend auto operator<<(std::ostream &os, const Bulb &bulb) -> std::ostream &
Definition: traffic_light.cpp:156
auto make(const std::string &s) -> Value
Definition: traffic_light.cpp:130
constexpr auto is(const Shape::Category category) const
Definition: traffic_light.hpp:236
const Value value
Definition: traffic_light.hpp:215
std::uint32_t Hash
Definition: traffic_light.hpp:217
constexpr auto is(const Status status) const
Definition: traffic_light.hpp:232
Definition: traffic_light.hpp:44
Value
Definition: traffic_light.hpp:45
@ white
Definition: traffic_light.hpp:49
@ green
Definition: traffic_light.hpp:46
@ red
Definition: traffic_light.hpp:48
@ yellow
Definition: traffic_light.hpp:47
friend auto operator<<(std::ostream &os, const Color &color) -> std::ostream &
Definition: traffic_light.cpp:37
constexpr Color(const Value value=green)
Definition: traffic_light.hpp:59
Color(const std::string &name)
Definition: traffic_light.hpp:61
static const std::unordered_map< std::string, Value > table
Definition: traffic_light.hpp:63
enum traffic_simulator::TrafficLight::Color::Value value
friend auto operator>>(std::istream &is, Color &color) -> std::istream &
Definition: traffic_light.cpp:29
static auto make(const std::string &name) -> Color
Definition: traffic_light.cpp:20
constexpr auto is(const Color given) const
Definition: traffic_light.hpp:78
Definition: traffic_light.hpp:132
Value
Definition: traffic_light.hpp:145
@ up
Definition: traffic_light.hpp:151
@ upper_right
Definition: traffic_light.hpp:156
@ left
Definition: traffic_light.hpp:149
@ cross
Definition: traffic_light.hpp:148
@ lower_right
Definition: traffic_light.hpp:155
@ upper_left
Definition: traffic_light.hpp:154
@ lower_left
Definition: traffic_light.hpp:153
@ down
Definition: traffic_light.hpp:150
@ circle
Definition: traffic_light.hpp:147
@ right
Definition: traffic_light.hpp:152
constexpr auto category() const
Definition: traffic_light.hpp:195
enum traffic_simulator::TrafficLight::Shape::Value value
static auto make(const std::string &name) -> Shape
Definition: traffic_light.cpp:85
constexpr auto is(const Category given) const
Definition: traffic_light.hpp:202
friend auto operator>>(std::istream &is, Shape &shape) -> std::istream &
Definition: traffic_light.cpp:94
Category
Definition: traffic_light.hpp:133
friend auto operator<<(std::ostream &os, const Shape &shape) -> std::ostream &
Definition: traffic_light.cpp:102
constexpr auto is(const Value given) const
Definition: traffic_light.hpp:200
constexpr Shape(const Value value=circle)
Definition: traffic_light.hpp:173
static const std::unordered_map< std::string, Shape::Value > table
Definition: traffic_light.hpp:177
Shape(const std::string &name)
Definition: traffic_light.hpp:175
Definition: traffic_light.hpp:88
constexpr auto is(const Value given) const
Definition: traffic_light.hpp:120
constexpr Status(const Value value=solid_on)
Definition: traffic_light.hpp:103
static const std::unordered_map< std::string, Value > table
Definition: traffic_light.hpp:107
Status(const std::string &name)
Definition: traffic_light.hpp:105
Value
Definition: traffic_light.hpp:89
@ solid_off
Definition: traffic_light.hpp:91
@ unknown
Definition: traffic_light.hpp:93
@ solid_on
Definition: traffic_light.hpp:90
@ flashing
Definition: traffic_light.hpp:92
friend auto operator<<(std::ostream &os, const Status &status) -> std::ostream &
Definition: traffic_light.cpp:70
enum traffic_simulator::TrafficLight::Status::Value value
static auto make(const std::string &name) -> Status
Definition: traffic_light.cpp:53
friend auto operator>>(std::istream &is, Status &status) -> std::istream &
Definition: traffic_light.cpp:62
Definition: traffic_light.hpp:42
auto clear()
Definition: traffic_light.hpp:443
const lanelet::Ids regulatory_elements_ids
Definition: traffic_light.hpp:435
double confidence
Definition: traffic_light.hpp:437
const lanelet::Id way_id
Definition: traffic_light.hpp:433
TrafficLight(const lanelet::Id, const hdmap_utils::HdMapUtils &)
Definition: traffic_light.cpp:163
const std::map< Bulb::Hash, std::optional< geometry_msgs::msg::Point > > positions
Definition: traffic_light.hpp:441
auto empty() const
Definition: traffic_light.hpp:492
auto contains(const Color &color, const Status &status, const Shape &shape) const
Definition: traffic_light.hpp:447
std::set< Bulb > bulbs
Definition: traffic_light.hpp:439
auto set(const std::string &states) -> void
Definition: traffic_light.cpp:197
auto contains(const std::string &name) const
Definition: traffic_light.hpp:452
auto draw(Markers &markers, const Now &now, const std::string &frame_id) const
Definition: traffic_light.hpp:455
friend auto operator<<(std::ostream &os, const TrafficLight &traffic_light) -> std::ostream &
Definition: traffic_light.cpp:215
auto contains(const Bulb &bulb) const
Definition: traffic_light.hpp:445
auto emplace(Ts &&... xs)
Definition: traffic_light.hpp:487
traffic_simulator::TrafficLight TrafficLight
Definition: test_traffic_light.cpp:23
TrafficLight::Bulb Bulb
Definition: test_traffic_light.cpp:27