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  template <typename T, typename... Ts>
50  void addModule(Ts &&... xs)
51  {
52  auto module_ptr = std::make_shared<T>(std::forward<Ts>(xs)...);
53  modules_.emplace_back(module_ptr);
54  }
55  void execute(const double current_time, const double step_time);
56 
57 private:
58  void autoSink();
59  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_;
60  std::vector<std::shared_ptr<traffic_simulator::traffic::TrafficModuleBase>> modules_;
61  const std::function<std::vector<std::string>(void)> get_entity_names_function;
62  const std::function<geometry_msgs::msg::Pose(const std::string &)> get_entity_pose_function;
63  const std::function<void(const std::string &)> despawn_function;
64 
65 public:
66  const bool auto_sink;
67 };
68 } // namespace traffic
69 } // namespace traffic_simulator
70 
71 #endif // TRAFFIC_SIMULATOR__TRAFFIC__TRAFFIC_CONTROLLER_HPP_
Definition: traffic_controller.hpp:42
const bool auto_sink
Definition: traffic_controller.hpp:66
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:38
void addModule(Ts &&... xs)
Definition: traffic_controller.hpp:50
void execute(const double current_time, const double step_time)
Definition: traffic_controller.cpp:69
Definition: cache.hpp:46
Definition: api.hpp:48
Definition: junit5.hpp:25
std::string string
Definition: junit5.hpp:26