scenario_simulator_v2 C++ API
common_test_fixtures.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__TEST__TRAFFIC_LIGHTS__COMMON_TEST_FIXTURES_HPP_
16 #define TRAFFIC_SIMULATOR__TEST__TRAFFIC_LIGHTS__COMMON_TEST_FIXTURES_HPP_
17 
18 #include <gtest/gtest.h>
19 
20 #include <ament_index_cpp/get_package_share_directory.hpp>
22 
23 constexpr char architecture_old[] = "awf/universe/20230906";
24 constexpr char architecture_new[] = "awf/universe/20240605";
25 
26 template <typename TrafficLightsT, const char * Architecture>
28 {
29 public:
31  : lights([this] {
32  if constexpr (std::is_same_v<TrafficLightsT, traffic_simulator::ConventionalTrafficLights>) {
33  return std::make_unique<TrafficLightsT>(node_ptr, hdmap_utils_ptr);
34  } else if constexpr (std::is_same_v<TrafficLightsT, traffic_simulator::V2ITrafficLights>) {
35  return std::make_unique<TrafficLightsT>(node_ptr, hdmap_utils_ptr, Architecture);
36  }
37  }())
38  {
39  static_assert(
40  std::is_same_v<TrafficLightsT, traffic_simulator::ConventionalTrafficLights> or
41  std::is_same_v<TrafficLightsT, traffic_simulator::V2ITrafficLights>,
42  "Given TrafficLights type is not supported");
43  }
44 
45  const lanelet::Id id{34836};
46 
47  const lanelet::Id signal_id{34806};
48 
49  const rclcpp::Node::SharedPtr node_ptr = rclcpp::Node::make_shared("TrafficLightsInternalTest");
50 
51  const std::string path = ament_index_cpp::get_package_share_directory("traffic_simulator") +
52  "/map/standard_map/lanelet2_map.osm";
53 
54  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_ptr =
55  std::make_shared<hdmap_utils::HdMapUtils>(
56  path, geographic_msgs::build<geographic_msgs::msg::GeoPoint>()
57  .latitude(35.61836750154)
58  .longitude(139.78066608243)
59  .altitude(0.0));
60 
61  std::unique_ptr<TrafficLightsT> lights;
62 };
63 
64 template <typename TrafficLightsT>
66 : public TrafficLightsInternalTestArchitectureDependent<TrafficLightsT, architecture_old>
67 {
68 };
69 
70 template <typename TrafficLightsT>
72 : public TrafficLightsInternalTestArchitectureDependent<TrafficLightsT, architecture_new>
73 {
74 };
75 
77 {
78  template <typename TrafficLightsT>
79  static auto GetName(int) -> std::string
80  {
81  if constexpr (std::is_same_v<TrafficLightsT, traffic_simulator::ConventionalTrafficLights>) {
82  return "ConventionalTrafficLights";
83  } else if constexpr (std::is_same_v<TrafficLightsT, traffic_simulator::V2ITrafficLights>) {
84  return "V2ITrafficLights";
85  }
86  }
87 };
88 #endif // TRAFFIC_SIMULATOR__TEST__TRAFFIC_LIGHTS__COMMON_TEST_FIXTURES_HPP_
Definition: common_test_fixtures.hpp:28
const std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils_ptr
Definition: common_test_fixtures.hpp:54
const std::string path
Definition: common_test_fixtures.hpp:51
const rclcpp::Node::SharedPtr node_ptr
Definition: common_test_fixtures.hpp:49
std::unique_ptr< TrafficLightsT > lights
Definition: common_test_fixtures.hpp:61
const lanelet::Id signal_id
Definition: common_test_fixtures.hpp:47
TrafficLightsInternalTestArchitectureDependent()
Definition: common_test_fixtures.hpp:30
Definition: common_test_fixtures.hpp:73
Definition: common_test_fixtures.hpp:67
constexpr char architecture_old[]
Definition: common_test_fixtures.hpp:23
constexpr char architecture_new[]
Definition: common_test_fixtures.hpp:24
std::string string
Definition: junit5.hpp:26
Definition: common_test_fixtures.hpp:77
static auto GetName(int) -> std::string
Definition: common_test_fixtures.hpp:79