scenario_simulator_v2 C++ API
traffic_controller.hpp
Go to the documentation of this file.
1 
12 // Copyright 2015 TIER IV.inc. All rights reserved.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "License");
15 // you may not use this file except in compliance with the License.
16 // You may obtain a copy of the License at
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 // See the License for the specific language governing permissions and
24 // limitations under the License.
25 
26 #ifndef TRAFFIC_SIMULATOR__TRAFFIC__TRAFFIC_CONTROLLER_HPP_
27 #define TRAFFIC_SIMULATOR__TRAFFIC__TRAFFIC_CONTROLLER_HPP_
28 
29 #include <memory>
30 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 namespace traffic_simulator
38 {
39 namespace traffic
40 {
42 {
43 public:
44  explicit TrafficController(
45  std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils,
46  const std::function<std::vector<std::string>(void)> & get_entity_names_function,
47  const std::function<geometry_msgs::msg::Pose(const std::string &)> & get_entity_pose_function,
48  const std::function<void(std::string)> & despawn_function, bool auto_sink = false);
49 
50  template <typename T, typename... Ts>
51  void addModule(Ts &&... xs)
52  {
53  auto module_ptr = std::make_shared<T>(std::forward<Ts>(xs)...);
54  modules_.emplace_back(module_ptr);
55  }
56  void execute(const double current_time, const double step_time);
57  auto makeDebugMarker() const -> const visualization_msgs::msg::MarkerArray;
58 
59 private:
60  void autoSink();
61  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_;
62  std::vector<std::shared_ptr<traffic_simulator::traffic::TrafficModuleBase>> modules_;
63  const std::function<std::vector<std::string>(void)> get_entity_names_function;
64  const std::function<geometry_msgs::msg::Pose(const std::string &)> get_entity_pose_function;
65  const std::function<void(const std::string &)> despawn_function;
66 
67 public:
68  const bool auto_sink;
69 };
70 } // namespace traffic
71 } // namespace traffic_simulator
72 
73 #endif // TRAFFIC_SIMULATOR__TRAFFIC__TRAFFIC_CONTROLLER_HPP_
Definition: traffic_controller.hpp:42
const bool auto_sink
Definition: traffic_controller.hpp:68
TrafficController(std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils, const std::function< std::vector< std::string >(void)> &get_entity_names_function, const std::function< geometry_msgs::msg::Pose(const std::string &)> &get_entity_pose_function, const std::function< void(std::string)> &despawn_function, bool auto_sink=false)
Definition: traffic_controller.cpp:39
void addModule(Ts &&... xs)
Definition: traffic_controller.hpp:51
auto makeDebugMarker() const -> const visualization_msgs::msg::MarkerArray
Definition: traffic_controller.cpp:77
void execute(const double current_time, const double step_time)
Definition: traffic_controller.cpp:70
Definition: traffic_module_base.hpp:36
Definition: cache.hpp:46
Definition: cache.hpp:27
Definition: api.hpp:49
Definition: junit5.hpp:25
std::string string
Definition: junit5.hpp:26