Skip to content

Commit

Permalink
Update CDASimAdapter to accomadate changes in SensorConfig file
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Sep 3, 2024
1 parent dd1a417 commit 1a42b0e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ namespace CDASimAdapter{
{
PLOG(logERROR) << "Error parsing sensors from string: " << json_str << std::endl;
}
return json_v;
Json::Value sensors_registration;
for ( int index = 0; index < json_v.size(); ++index ) {
Json::Value sensor;
sensor["sensorId"] = json_v[index]["sensorId"];
sensor["type"] = json_v[index]["type"];
if ( json_v[index]["ref"]["type"] != "CARTESIAN" ){
PLOG(logWARNING) << "Skipping sensor configuration for " + sensor["sensorId"].asString() + ". Invalid ref type! Only CARTESIAN ref type currently supported for CDASim!" ;
continue;
}
sensor["location"] = json_v[index]["ref"]["location"];
sensor["orientation"] =json_v[index]["ref"]["orientation"];
sensors_registration[index] = sensor;
}

return sensors_registration;
}
}
2 changes: 1 addition & 1 deletion src/v2i-hub/CDASimAdapter/test/TestCDASimConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace CDASimAdapter {
}
public:
std::shared_ptr<CDASimConnection> connection;
std::string sensors_file_path = "../../CDASimAdapter/test/sensors.json";
std::string sensors_file_path = "../../CDASimAdapter/test/sensors_new.json";


};
Expand Down
36 changes: 36 additions & 0 deletions src/v2i-hub/CDASimAdapter/test/sensors_new.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"sensorId": "SomeID",
"type": "SemanticLidar",
"ref": {
"type": "CARTESIAN",
"location": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"orientation": {
"yaw": 0.0,
"pitch": 0.0,
"roll": 0.0
}
}
},
{
"sensorId": "SomeID2",
"type": "SemanticLidar",
"ref": {
"type": "CARTESIAN",
"location": {
"x": 1.0,
"y": 2.0,
"z": 0.0
},
"orientation": {
"yaw": 23.0,
"pitch": 0.0,
"roll": 0.0
}
}
}
]

0 comments on commit 1a42b0e

Please sign in to comment.