|
16 | 16 | * SPDX-License-Identifier: Apache-2.0
|
17 | 17 | */
|
18 | 18 | /**
|
19 |
| - * \file osi_omni_sensor.hpp |
20 |
| - * \see osi_omni_sensor.cpp |
| 19 | + * \file osi_message_handler.hpp |
| 20 | + * \see osi_message_handler.cpp |
21 | 21 | */
|
22 | 22 |
|
23 | 23 | #pragma once
|
|
42 | 42 | #include "osi/utility/osi_transceiver.hpp" // for OsiTransceiver
|
43 | 43 | #include "osi/utility/osi_utils.hpp"
|
44 | 44 |
|
45 |
| -namespace osii { |
| 45 | +namespace cloeosi { |
46 | 46 |
|
47 | 47 | /**
|
48 | 48 | * Convert OSI timestamp to Cloe time format.
|
@@ -171,111 +171,98 @@ struct SensorMockConf : public cloe::Confable {
|
171 | 171 | /**
|
172 | 172 | * Base class for an OSI sensor which is connected via TCP.
|
173 | 173 | */
|
174 |
| -class OsiOmniSensor { |
| 174 | +class OsiMsgHandler { |
175 | 175 | public:
|
176 |
| - virtual ~OsiOmniSensor() = default; |
177 |
| - OsiOmniSensor() = delete; |
| 176 | + virtual ~OsiMsgHandler() = default; |
| 177 | + OsiMsgHandler() = delete; |
178 | 178 |
|
179 | 179 | /**
|
180 |
| - * Create a new instance of OsiOmniSensor with the given OsiTransceiver. |
| 180 | + * Create a new instance of OsiMsgHandler with the given OsiTransceiver. |
181 | 181 | */
|
182 |
| - OsiOmniSensor(std::unique_ptr<OsiTransceiver>&& osi_transceiver, uint64_t owner_id) |
| 182 | + OsiMsgHandler(std::unique_ptr<OsiTransceiver>&& osi_transceiver, uint64_t owner_id) |
183 | 183 | : osi_comm_(std::move(osi_transceiver)), owner_id_(owner_id) {
|
184 | 184 | ground_truth_ = std::make_unique<OsiGroundTruth>();
|
185 | 185 | }
|
186 | 186 |
|
187 | 187 | /**
|
188 |
| - * Create a new instance of OsiOmniSensor with the given new OsiTransceiver. |
| 188 | + * Create a new instance of OsiMsgHandler with the given new OsiTransceiver. |
189 | 189 | *
|
190 |
| - * WARNING: If you use this constructor, please realize that OsiOmniSensor |
| 190 | + * WARNING: If you use this constructor, please realize that OsiMsgHandler |
191 | 191 | * takes ownership of the pointer you pass in.
|
192 | 192 | */
|
193 |
| - OsiOmniSensor(OsiTransceiver* osi_transceiver, uint64_t owner_id) |
| 193 | + OsiMsgHandler(OsiTransceiver* osi_transceiver, uint64_t owner_id) |
194 | 194 | : osi_comm_(osi_transceiver), owner_id_(owner_id) {
|
195 | 195 | ground_truth_ = std::make_unique<OsiGroundTruth>();
|
196 | 196 | }
|
197 | 197 |
|
198 | 198 | /**
|
199 |
| - * Receive and process the incoming osi3::SensorData messages. |
| 199 | + * Receive and process the incoming osi3 messages. |
200 | 200 | */
|
201 |
| - void step_sensor_data(const cloe::Sync& s, const bool& restart, cloe::Duration& sim_time); |
202 |
| - |
203 |
| - /** |
204 |
| - * Receive and process the incoming osi3::SensorView messages. |
205 |
| - */ |
206 |
| - void step_sensor_view(const cloe::Sync& s, const bool& restart, cloe::Duration& sim_time); |
207 |
| - |
208 |
| - /** |
209 |
| - * Receive and process the incoming osi3::GroundTruth messages. |
210 |
| - */ |
211 |
| - void step_ground_truth(const cloe::Sync& s, const bool& restart, cloe::Duration& sim_time); |
212 |
| - |
213 |
| - /** |
214 |
| - * Receive and process the incoming messages. |
215 |
| - */ |
216 |
| - //virtual void step(const cloe::Sync& s, const bool& restart, cloe::Duration& sim_time) = 0; |
| 201 | + template <typename T> |
| 202 | + void process_osi_msgs(const cloe::Sync& s, const bool& restart, cloe::Duration& osi_time); |
217 | 203 |
|
218 | 204 | /**
|
219 | 205 | * Store the initial timestamp.
|
220 | 206 | * Note that the osi time does not necessarily start at zero.
|
221 | 207 | */
|
222 |
| - virtual void process(const osi3::Timestamp& timestamp); |
| 208 | + void handle_first_message(const osi3::Timestamp& timestamp); |
223 | 209 |
|
224 | 210 | /**
|
225 | 211 | * Translate OSI SensorData to Cloe data objects.
|
226 | 212 | *
|
227 | 213 | * \param osi_sd SensorData message to be processed.
|
228 |
| - * \param sim_time Simulation time to be set. |
| 214 | + * \param osi_time Timestamp of the OSI message. |
229 | 215 | */
|
230 |
| - virtual void process_received_msg(osi3::SensorData* osi_sd, cloe::Duration& sim_time); |
| 216 | + virtual void process_received_msg(osi3::SensorData* osi_sd, cloe::Duration& osi_time); |
231 | 217 |
|
232 | 218 | /**
|
233 | 219 | * Translate OSI SensorView to Cloe data objects.
|
234 | 220 | *
|
235 | 221 | * \param osi_sv SensorView message to be processed.
|
236 |
| - * \param sim_time Simulation time to be set. |
| 222 | + * \param osi_time Timestamp of the OSI message. |
237 | 223 | */
|
238 |
| - virtual void process_received_msg(osi3::SensorView* osi_sv, cloe::Duration& sim_time); |
| 224 | + virtual void process_received_msg(osi3::SensorView* osi_sv, cloe::Duration& osi_time); |
239 | 225 |
|
240 | 226 | /**
|
241 | 227 | * Translate OSI GroundTruth to Cloe data objects.
|
242 | 228 | *
|
243 | 229 | * \param osi_gt GroundTruth message to be processed.
|
244 |
| - * \param sim_time Simulation time to be set. |
| 230 | + * \param osi_time Timestamp of the OSI message. |
245 | 231 | */
|
246 |
| - virtual void process_received_msg(osi3::GroundTruth* osi_gt, cloe::Duration& sim_time); |
| 232 | + virtual void process_received_msg(osi3::GroundTruth* osi_gt, cloe::Duration& osi_time); |
247 | 233 |
|
248 | 234 | /**
|
249 | 235 | * Translate OSI GroundTruth to Cloe data objects.
|
250 | 236 | *
|
251 | 237 | * \param osi_gt GroundTruth message to be processed.
|
252 | 238 | */
|
253 |
| - virtual void process(const osi3::GroundTruth& osi_gt); |
| 239 | + virtual void convert_to_cloe_data(const osi3::GroundTruth& osi_gt); |
254 | 240 |
|
255 | 241 | /**
|
256 | 242 | * Translate OSI SensorView to Cloe data objects.
|
257 | 243 | *
|
258 | 244 | * \param osi_sv SensorView message to be processed, including ground truth.
|
259 | 245 | */
|
260 |
| - virtual void process(const osi3::SensorView& osi_sv); |
| 246 | + virtual void convert_to_cloe_data(const osi3::SensorView& osi_sv); |
261 | 247 |
|
262 | 248 | /**
|
263 | 249 | * Translate OSI ego base information made available to the sensor model
|
264 | 250 | * from other components, or use ground truth.
|
265 | 251 | * \param osi_mo MovingObject (ground truth) used as fallback.
|
266 | 252 | * \param osi_hv Pointer to HostVehicleData message to be processed (if available).
|
267 | 253 | */
|
268 |
| - virtual void process(const osi3::MovingObject& osi_ego, const osi3::HostVehicleData* osi_hv); |
| 254 | + virtual void convert_to_cloe_data(const osi3::MovingObject& osi_ego, |
| 255 | + const osi3::HostVehicleData* osi_hv); |
269 | 256 |
|
270 | 257 | /**
|
271 | 258 | * Translate OSI detected moving object information to Cloe data objects.
|
272 | 259 | *
|
273 | 260 | * \param osi_eh DetectedEntityHeader message to be processed (if available).
|
274 | 261 | * \param osi_mo DetectedMovingObject message to be processed.
|
275 | 262 | */
|
276 |
| - virtual void process(const bool has_eh, |
277 |
| - const osi3::DetectedEntityHeader& osi_eh, |
278 |
| - const osi3::DetectedMovingObject& osi_mo); |
| 263 | + virtual void convert_to_cloe_data(const bool has_eh, |
| 264 | + const osi3::DetectedEntityHeader& osi_eh, |
| 265 | + const osi3::DetectedMovingObject& osi_mo); |
279 | 266 |
|
280 | 267 | void detected_moving_objects_from_ground_truth();
|
281 | 268 |
|
@@ -334,7 +321,7 @@ class OsiOmniSensor {
|
334 | 321 | */
|
335 | 322 | virtual void clear_cache() { osi_comm_->clear_cache(); }
|
336 | 323 |
|
337 |
| - friend void to_json(cloe::Json& j, const OsiOmniSensor& c) { |
| 324 | + friend void to_json(cloe::Json& j, const OsiMsgHandler& c) { |
338 | 325 | j = cloe::Json{
|
339 | 326 | {"osi_connection", *c.osi_comm_},
|
340 | 327 | };
|
@@ -363,4 +350,4 @@ class OsiOmniSensor {
|
363 | 350 | /// Use alternative source for required data or overwrite incoming data, if requested.
|
364 | 351 | std::shared_ptr<const SensorMockConf> mock_{nullptr};
|
365 | 352 | };
|
366 |
| -} // namespace osii |
| 353 | +} // namespace cloeosi |
0 commit comments