scenario_simulator_v2 C++ API
openscenario_preprocessor.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 OPENSCENARIO_PREPROCESSOR__OPENSCENARIO_PREPROCESSOR_HPP_
16 #define OPENSCENARIO_PREPROCESSOR__OPENSCENARIO_PREPROCESSOR_HPP_
17 
18 #include <concealer/execute.hpp>
19 #include <deque>
20 #include <memory>
22 #include <openscenario_preprocessor_msgs/srv/check_derivative_remained.hpp>
23 #include <openscenario_preprocessor_msgs/srv/derive.hpp>
24 #include <openscenario_preprocessor_msgs/srv/load.hpp>
25 #include <rclcpp/rclcpp.hpp>
26 
28 {
30 {
31  ScenarioSet() = default;
32 
34  {
35  path = load_request.path;
36  frame_rate = load_request.frame_rate;
37  }
38 
39  auto getDeriveResponse() -> openscenario_preprocessor_msgs::srv::Derive::Response
40  {
41  openscenario_preprocessor_msgs::srv::Derive::Response response;
42  response.path = path;
43  response.frame_rate = frame_rate;
44  return response;
45  }
46 
48 
49  float frame_rate;
50 };
51 
52 class Preprocessor : public rclcpp::Node
53 {
54 public:
55  explicit Preprocessor(const rclcpp::NodeOptions &);
56 
57 private:
58  void preprocessScenario(ScenarioSet &);
59 
60  [[nodiscard]] bool validateXOSC(const boost::filesystem::path &, bool);
61 
62  rclcpp::Service<openscenario_preprocessor_msgs::srv::Load>::SharedPtr load_server;
63 
64  rclcpp::Service<openscenario_preprocessor_msgs::srv::Derive>::SharedPtr derive_server;
65 
66  rclcpp::Service<openscenario_preprocessor_msgs::srv::CheckDerivativeRemained>::SharedPtr
67  check_server;
68 
69  std::deque<ScenarioSet> preprocessed_scenarios;
70 
71  std::mutex preprocessed_scenarios_mutex;
72 };
73 } // namespace openscenario_preprocessor
74 
75 #endif // OPENSCENARIO_PREPROCESSOR__OPENSCENARIO_PREPROCESSOR_HPP_
Definition: openscenario_preprocessor.hpp:53
Preprocessor(const rclcpp::NodeOptions &)
Definition: openscenario_preprocessor.cpp:23
Definition: openscenario_preprocessor.hpp:28
Request
Definition: behavior.hpp:25
std::string string
Definition: junit5.hpp:26
Definition: openscenario_preprocessor.hpp:30
std::string path
Definition: openscenario_preprocessor.hpp:47
ScenarioSet(openscenario_preprocessor_msgs::srv::Load::Request &load_request)
Definition: openscenario_preprocessor.hpp:33
auto getDeriveResponse() -> openscenario_preprocessor_msgs::srv::Derive::Response
Definition: openscenario_preprocessor.hpp:39
float frame_rate
Definition: openscenario_preprocessor.hpp:49