Skip to content

Commit bdf616f

Browse files
tobifalkcassava
authored andcommitted
osi: Skip polygonal objects
1 parent a5d5f7e commit bdf616f

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

osi/src/cloe/utility/osi_message_handler.cpp

+35-5
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const std::map<int, LaneBoundary::Color> osi_lane_bdry_color_map = {
137137

138138
Duration osi_timestamp_to_time(const osi3::Timestamp& timestamp) {
139139
return std::chrono::duration_cast<Duration>(std::chrono::seconds(timestamp.seconds()) +
140-
std::chrono::nanoseconds(timestamp.nanos()));
140+
std::chrono::nanoseconds(timestamp.nanos()));
141141
}
142142

143143
Duration OsiMsgHandler::osi_timestamp_to_simtime(const osi3::Timestamp& timestamp) const {
@@ -355,8 +355,7 @@ void transform_obj_coord_from_osi_data(const Eigen::Isometry3d& sensor_pose,
355355
}
356356

357357
template <typename T>
358-
void OsiMsgHandler::process_osi_msgs(const Sync& s, const bool& restart,
359-
Duration& osi_time) {
358+
void OsiMsgHandler::process_osi_msgs(const Sync& s, const bool& restart, Duration& osi_time) {
360359
this->clear_cache();
361360
// Cycle until osi message has been received.
362361
int n_msg{0};
@@ -733,8 +732,7 @@ void OsiMsgHandler::convert_to_cloe_data(const bool has_eh,
733732
break;
734733
}
735734
case SensorMockLevel::OverwriteAll: {
736-
throw ModelError(
737-
"OSI SensorMockLevel::OverwriteAll not available for DetectedMovingObject");
735+
throw ModelError("OSI SensorMockLevel::OverwriteAll not available for DetectedMovingObject");
738736
break;
739737
}
740738
}
@@ -766,13 +764,41 @@ void OsiMsgHandler::convert_to_cloe_data(const bool has_eh,
766764
store_object(obj);
767765
}
768766

767+
template <typename TOsiObject>
768+
bool skip_polygonal_objects(const TOsiObject& obj) {
769+
// TODO: Implement support for polygonal objects.
770+
//
771+
// At the moment, we expect objects to be represented as bounding boxes,
772+
// since we don't have a use for higher fidelity object representation.
773+
//
774+
// OSI allows objects to take different forms:
775+
//
776+
// https://opensimulationinterface.github.io/osi-antora-generator/asamosi/V3.5.0/gen/structosi3_1_1BaseStationary.html
777+
//
778+
// If you need support for Polygons please create an issue so we can plan this:
779+
//
780+
// https://github.com/eclipse/cloe/issues/new
781+
//
782+
if (!obj.base().has_orientation() && !obj.base().base_polygon().empty()) {
783+
osi_logger()->warn(
784+
"OsiMsgHandler: Objects defined by polygon are not supported yet. Skipping object "
785+
"{}.",
786+
osi_identifier(obj.id()));
787+
return true;
788+
}
789+
return false;
790+
}
791+
769792
void OsiMsgHandler::detected_moving_objects_from_ground_truth() {
770793
const auto& osi_gt = ground_truth_->get_gt();
771794
// Set moving object data.
772795
for (const auto& osi_obj : osi_gt.moving_object()) {
773796
osi_require("GroundTruth-MovingObject::id", osi_obj.has_id());
774797
int id = osi_identifier(osi_obj.id());
775798
if (id != static_cast<int>(owner_id_)) {
799+
if (skip_polygonal_objects(osi_obj)) {
800+
continue;
801+
}
776802
auto obj = std::make_shared<Object>();
777803
// Set existence probability.
778804
obj->exist_prob = 1.0;
@@ -852,6 +878,10 @@ void OsiMsgHandler::detected_static_objects_from_ground_truth() {
852878
// Set static object data.
853879
for (const auto& osi_obj : osi_gt.stationary_object()) {
854880
osi_require("GroundTruth-StationaryObject::id", osi_obj.has_id());
881+
if (skip_polygonal_objects(osi_obj)) {
882+
continue;
883+
}
884+
855885
auto obj = std::make_shared<Object>();
856886
// Set existence probability.
857887
obj->exist_prob = 1.0;

0 commit comments

Comments
 (0)