$darkmode
vtd_conf.hpp
1 /*
2  * Copyright 2020 Robert Bosch GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  */
22 #pragma once
23 
24 #include <chrono> // for duration<>
25 #include <map> // for map<>
26 #include <memory> // for shared_ptr<>
27 #include <string> // for string
28 
29 #include <cloe/core.hpp> // for Conf, Schema
30 #include <cloe/utility/osi_message_handler.hpp> // for SensorMockLevel
31 #include <cloe/utility/tcp_transceiver_config.hpp> // for TcpTransceiverConfiguration, ...
32 
33 // Connection / Initialization
34 #define VTD_DEFAULT_SCP_PORT 48179
35 #define VTD_PARAMSERVER_PORT 54345
36 #define VTD_INIT_SYNC_SLEEP_MS 3000
37 #define VTD_INIT_WAIT_SLEEP_MS 200
38 
39 namespace vtd {
40 
45 enum class LabelConfiguration { Off, Text, Human, Symbol, Unicode };
46 
47 // clang-format off
48 ENUM_SERIALIZATION(LabelConfiguration, ({
49  {LabelConfiguration::Off, "off"},
50  {LabelConfiguration::Text, "text"},
51  {LabelConfiguration::Human, "human"},
52  {LabelConfiguration::Symbol, "symbol"},
53  {LabelConfiguration::Unicode, "unicode"},
54 }))
55 // clang-format on
56 
57 
61 enum class ProtocolConfiguration { Rdb, Osi };
62 
63 // clang-format off
64 ENUM_SERIALIZATION(ProtocolConfiguration, ({
65  {ProtocolConfiguration::Rdb, "rdb"},
66  {ProtocolConfiguration::Osi, "osi"},
67 }))
68 // clang-format on
69 
70 
78 struct VtdSensorConfig : public cloe::Confable {
93  std::string xml = "";
94 
95  ProtocolConfiguration protocol = ProtocolConfiguration::Rdb;
96 
101  std::shared_ptr<cloe::utility::SensorMockConf> sensor_mock_conf =
102  std::make_shared<cloe::utility::SensorMockConf>();
103 
104  public:
105  CONFABLE_SCHEMA(VtdSensorConfig) {
106  // clang-format off
107  return cloe::Schema{
108  {"xml", cloe::Schema(&xml, "VTD module manager sensor configuration")},
109  {"protocol", cloe::Schema(&protocol, "VTD module manager sensor connection protocol ( rdb | osi )")},
110  {"mock_level", cloe::Schema(sensor_mock_conf.get(), "Sensor data mock level")},
111  };
112  // clang-format on
113  }
114 };
115 
128  std::string from;
129 
137  std::string type;
138 
147  bool override = false;
148 
149  public:
150  CONFABLE_SCHEMA(VtdComponentConfig) {
151  return cloe::Schema{
152  {"from", cloe::Schema(&from, "VTD sensor to retrieve the component data from")},
153  {"type", cloe::Schema(&type, "Component type to register")},
154  {"override", cloe::Schema(&override, "Override an existing component with the same name")},
155  };
156  };
157 };
158 
168  std::map<std::string, VtdSensorConfig> sensors;
169 
173  std::map<std::string, VtdComponentConfig> components;
174 
175  public:
176  CONFABLE_SCHEMA(VtdVehicleConfig) {
177  return cloe::Schema{
178  {"sensors", cloe::Schema(&sensors, "sensor definitions")},
179  {"components", cloe::Schema(&components, "component definitions")},
180  };
181  }
182 };
183 
193 
197  cloe::utility::TcpTransceiverFullConfiguration connection{"localhost", VTD_DEFAULT_SCP_PORT};
198 
203  std::chrono::duration<float>{0.5}};
204 
208  cloe::utility::TcpTransceiverConfiguration rdb_params{60, std::chrono::duration<float>{0.5}};
209 
218 
227  uint16_t sensor_initial_port{48196};
228 
232  std::map<std::string, VtdVehicleConfig> vehicles;
233 
234  std::string setup = "Cloe.Default";
235 
236  std::string scenario = "";
237  std::string project = "";
238 
245  bool image_generator = true;
246 
251  bool camera_third_person = true;
252 
257  std::string camera_focus_on = "";
258 
262  LabelConfiguration label_vehicle = LabelConfiguration::Text;
263 
267  std::string dat_file = "";
268 
272  std::map<std::string, std::string> scp_actions{};
273 
274  public:
275  CONFABLE_SCHEMA(VtdConfiguration) {
276  // clang-format off
277  using namespace cloe; // NOLINT(build/namespaces)
278  return Schema{
279  {"connection", Schema(&connection, "scp connection parameters")},
280  {"paramserver", Schema(&paramserver, "parameter sever connection parameters")},
281  {"task_control_params", Schema(&task_control_params, "task control connection parameters")},
282  {"rdb_params", Schema(&rdb_params, "rdb connection parameters")},
283  {"sensor_initial_port", Schema(&sensor_initial_port, "initial port for sensor communication")},
284  {"vehicles", Schema(&vehicles, "vehicle configuration like sensors and component mapping")},
285  {"configuration_retry_attempts", Schema(&configuration_retry_attempts, "attempts to retry connection on broken pipe")},
286  {"setup", Schema(&setup, "indicate which setup you are using")},
287  {"image_generator", Schema(&image_generator, "switch whether VTD should use image generator")},
288  {"scenario", Schema(&scenario, "VTD scenario to use (project must already be loaded)")},
289  {"project", Schema(&project, "indicate which project to find the scenario in (informative)")},
290  {"label_vehicle", Schema(&label_vehicle, "how to label vehicle modes in VTD [off,text,human,symbol,unicode]")},
291  {"dat_file", Schema(&dat_file, "filepath to write VTD data output to")},
292  {"scp_actions", Schema(&scp_actions, "predefined SCP actions for use by action trigger")},
293  {"camera", Schema({
294  {"third_person",Schema(&camera_third_person, "whether to use third person camera")},
295  {"focus_on", Schema(&camera_focus_on, "player to focus on")},
296  })},
297  };
298  // clang-format on
299  }
300 };
301 
302 } // namespace vtd
Definition: confable.hpp:98
Definition: schema.hpp:173
#define ENUM_SERIALIZATION(xType, xMap)
Definition: enum.hpp:51
Definition: tcp_transceiver_config.hpp:38
Definition: tcp_transceiver_config.hpp:82
Definition: vtd_conf.hpp:120
std::string from
Definition: vtd_conf.hpp:128
std::string type
Definition: vtd_conf.hpp:137
Definition: vtd_conf.hpp:188
cloe::utility::TcpTransceiverConfiguration task_control_params
Definition: vtd_conf.hpp:202
bool image_generator
Definition: vtd_conf.hpp:245
std::string camera_focus_on
Definition: vtd_conf.hpp:257
bool camera_third_person
Definition: vtd_conf.hpp:251
LabelConfiguration label_vehicle
Definition: vtd_conf.hpp:262
std::string dat_file
Definition: vtd_conf.hpp:267
std::map< std::string, std::string > scp_actions
Definition: vtd_conf.hpp:272
uint16_t configuration_retry_attempts
Definition: vtd_conf.hpp:217
cloe::utility::TcpTransceiverConfiguration rdb_params
Definition: vtd_conf.hpp:208
uint16_t sensor_initial_port
Definition: vtd_conf.hpp:227
cloe::utility::TcpTransceiverFullConfiguration connection
Definition: vtd_conf.hpp:197
cloe::utility::TcpTransceiverFullConfiguration paramserver
Definition: vtd_conf.hpp:192
std::map< std::string, VtdVehicleConfig > vehicles
Definition: vtd_conf.hpp:232
Definition: vtd_conf.hpp:164
std::map< std::string, VtdComponentConfig > components
Definition: vtd_conf.hpp:173
std::map< std::string, VtdSensorConfig > sensors
Definition: vtd_conf.hpp:168