$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/tcp_transceiver_config.hpp> // for TcpTransceiverConfiguration, ...
31 #include "osi_omni_sensor.hpp" // for SensorMockLevel
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<osii::SensorMockConf> sensor_mock_conf = std::make_shared<osii::SensorMockConf>();
102 
103  public:
104  CONFABLE_SCHEMA(VtdSensorConfig) {
105  // clang-format off
106  return cloe::Schema{
107  {"xml", cloe::Schema(&xml, "VTD module manager sensor configuration")},
108  {"protocol", cloe::Schema(&protocol, "VTD module manager sensor connection protocol ( rdb | osi )")},
109  {"mock_level", cloe::Schema(sensor_mock_conf.get(), "Sensor data mock level")},
110  };
111  // clang-format on
112  }
113 };
114 
127  std::string from;
128 
136  std::string type;
137 
146  bool override = false;
147 
148  public:
149  CONFABLE_SCHEMA(VtdComponentConfig) {
150  return cloe::Schema{
151  {"from", cloe::Schema(&from, "VTD sensor to retrieve the component data from")},
152  {"type", cloe::Schema(&type, "Component type to register")},
153  {"override", cloe::Schema(&override, "Override an existing component with the same name")},
154  };
155  };
156 };
157 
167  std::map<std::string, VtdSensorConfig> sensors;
168 
172  std::map<std::string, VtdComponentConfig> components;
173 
174  public:
175  CONFABLE_SCHEMA(VtdVehicleConfig) {
176  return cloe::Schema{
177  {"sensors", cloe::Schema(&sensors, "sensor definitions")},
178  {"components", cloe::Schema(&components, "component definitions")},
179  };
180  }
181 };
182 
192 
196  cloe::utility::TcpTransceiverFullConfiguration connection{"localhost", VTD_DEFAULT_SCP_PORT};
197 
202  std::chrono::duration<float>{0.5}};
203 
207  cloe::utility::TcpTransceiverConfiguration rdb_params{60, std::chrono::duration<float>{0.5}};
208 
217 
226  uint16_t sensor_initial_port{48196};
227 
231  std::map<std::string, VtdVehicleConfig> vehicles;
232 
233  std::string setup = "Cloe.Default";
234 
235  std::string scenario = "";
236  std::string project = "";
237 
244  bool image_generator = true;
245 
250  bool camera_third_person = true;
251 
256  std::string camera_focus_on = "";
257 
261  LabelConfiguration label_vehicle = LabelConfiguration::Text;
262 
266  std::string dat_file = "";
267 
271  std::map<std::string, std::string> scp_actions{};
272 
273  public:
274  CONFABLE_SCHEMA(VtdConfiguration) {
275  // clang-format off
276  using namespace cloe; // NOLINT(build/namespaces)
277  return Schema{
278  {"connection", Schema(&connection, "scp connection parameters")},
279  {"paramserver", Schema(&paramserver, "parameter sever connection parameters")},
280  {"task_control_params", Schema(&task_control_params, "task control connection parameters")},
281  {"rdb_params", Schema(&rdb_params, "rdb connection parameters")},
282  {"sensor_initial_port", Schema(&sensor_initial_port, "initial port for sensor communication")},
283  {"vehicles", Schema(&vehicles, "vehicle configuration like sensors and component mapping")},
284  {"configuration_retry_attempts", Schema(&configuration_retry_attempts, "attempts to retry connection on broken pipe")},
285  {"setup", Schema(&setup, "indicate which setup you are using")},
286  {"image_generator", Schema(&image_generator, "switch whether VTD should use image generator")},
287  {"scenario", Schema(&scenario, "VTD scenario to use (project must already be loaded)")},
288  {"project", Schema(&project, "indicate which project to find the scenario in (informative)")},
289  {"label_vehicle", Schema(&label_vehicle, "how to label vehicle modes in VTD [off,text,human,symbol,unicode]")},
290  {"dat_file", Schema(&dat_file, "filepath to write VTD data output to")},
291  {"scp_actions", Schema(&scp_actions, "predefined SCP actions for use by action trigger")},
292  {"camera", Schema({
293  {"third_person",Schema(&camera_third_person, "whether to use third person camera")},
294  {"focus_on", Schema(&camera_focus_on, "player to focus on")},
295  })},
296  };
297  // clang-format on
298  }
299 };
300 
301 } // namespace vtd
Definition: confable.hpp:43
Definition: schema.hpp:175
#define ENUM_SERIALIZATION(xType, xMap)
Definition: enum.hpp:51
@ Off
Disable the watchdog entirely.
Definition: tcp_transceiver_config.hpp:38
Definition: tcp_transceiver_config.hpp:82
Definition: vtd_conf.hpp:119
std::string from
Definition: vtd_conf.hpp:127
std::string type
Definition: vtd_conf.hpp:136
Definition: vtd_conf.hpp:187
cloe::utility::TcpTransceiverConfiguration task_control_params
Definition: vtd_conf.hpp:201
bool image_generator
Definition: vtd_conf.hpp:244
std::string camera_focus_on
Definition: vtd_conf.hpp:256
bool camera_third_person
Definition: vtd_conf.hpp:250
LabelConfiguration label_vehicle
Definition: vtd_conf.hpp:261
std::string dat_file
Definition: vtd_conf.hpp:266
std::map< std::string, std::string > scp_actions
Definition: vtd_conf.hpp:271
uint16_t configuration_retry_attempts
Definition: vtd_conf.hpp:216
cloe::utility::TcpTransceiverConfiguration rdb_params
Definition: vtd_conf.hpp:207
uint16_t sensor_initial_port
Definition: vtd_conf.hpp:226
cloe::utility::TcpTransceiverFullConfiguration connection
Definition: vtd_conf.hpp:196
cloe::utility::TcpTransceiverFullConfiguration paramserver
Definition: vtd_conf.hpp:191
std::map< std::string, VtdVehicleConfig > vehicles
Definition: vtd_conf.hpp:231
Definition: vtd_conf.hpp:163
std::map< std::string, VtdComponentConfig > components
Definition: vtd_conf.hpp:172
std::map< std::string, VtdSensorConfig > sensors
Definition: vtd_conf.hpp:167