Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWeiss David2020-08-24 13:56:26 +0000
committerBiegel Reinhard2020-09-25 10:19:19 +0000
commit971ed018ca0592a6e25af880036e6e8103cb8c3b (patch)
tree6297b798c5b61862e81da8cdf10df2823f298e6e
parent1f042e4c2d57d15094cc8ec7f88d724b9d35afb5 (diff)
downloadsimopenpass-971ed018ca0592a6e25af880036e6e8103cb8c3b.tar.gz
simopenpass-971ed018ca0592a6e25af880036e6e8103cb8c3b.tar.xz
simopenpass-971ed018ca0592a6e25af880036e6e8103cb8c3b.zip
mod(Sensor_OSI): Move methods to common base
-rw-r--r--sim/src/components/Sensor_OSI/src/objectDetectorBase.cpp69
-rw-r--r--sim/src/components/Sensor_OSI/src/objectDetectorBase.h27
-rw-r--r--sim/src/components/Sensor_OSI/src/sensorGeometric2D.cpp69
-rw-r--r--sim/src/components/Sensor_OSI/src/sensorGeometric2D.h24
-rw-r--r--sim/tests/unitTests/components/Sensor_OSI/CMakeLists.txt1
-rw-r--r--sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.cpp127
-rw-r--r--sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.pro3
-rw-r--r--sim/tests/unitTests/components/Sensor_OSI/sensorOSI_TestsCommon.h122
-rw-r--r--sim/tests/unitTests/core/slave/profilesImporter_Tests.cpp10
9 files changed, 227 insertions, 225 deletions
diff --git a/sim/src/components/Sensor_OSI/src/objectDetectorBase.cpp b/sim/src/components/Sensor_OSI/src/objectDetectorBase.cpp
index 25390d1e..ddc1e160 100644
--- a/sim/src/components/Sensor_OSI/src/objectDetectorBase.cpp
+++ b/sim/src/components/Sensor_OSI/src/objectDetectorBase.cpp
@@ -104,6 +104,45 @@ void ObjectDetectorBase::UpdateOutput(int localLinkId, std::shared_ptr<SignalInt
}
}
+void ObjectDetectorBase::AddMovingObjectToSensorData(osi3::MovingObject object, point_t ownVelocity, point_t ownAcceleration, point_t ownPosition, double yaw, double yawRate)
+{
+ point_t objectReferencePointGlobal{object.base().position().x(), object.base().position().y()};
+ point_t objectReferencePointLocal = TransformPointToLocalCoordinates(objectReferencePointGlobal, ownPosition, yaw);
+
+ osi3::DetectedMovingObject* detectedObject = sensorData.add_moving_object();
+ detectedObject->mutable_header()->add_ground_truth_id()->set_value(object.id().value());
+ detectedObject->mutable_header()->add_sensor_id()->set_value(id);
+ detectedObject->mutable_base()->mutable_dimension()->CopyFrom(object.base().dimension());
+
+ detectedObject->mutable_base()->mutable_position()->set_x(objectReferencePointLocal.x());
+ detectedObject->mutable_base()->mutable_position()->set_y(objectReferencePointLocal.y());
+ detectedObject->mutable_base()->mutable_orientation()->set_yaw(object.base().orientation().yaw() - yaw);
+ detectedObject->mutable_base()->mutable_orientation_rate()->set_yaw(object.base().orientation_rate().yaw() - yawRate);
+ point_t objectVelocity{object.base().velocity().x(), object.base().velocity().y()};
+ point_t relativeVelocity = CalculateRelativeVector(objectVelocity, ownVelocity, yaw);
+ detectedObject->mutable_base()->mutable_velocity()->set_x(relativeVelocity.x());
+ detectedObject->mutable_base()->mutable_velocity()->set_y(relativeVelocity.y());
+ point_t objectAcceleration{object.base().acceleration().x(), object.base().acceleration().y()};
+ point_t relativeAcceleration = CalculateRelativeVector(objectAcceleration, ownAcceleration, yaw);
+ detectedObject->mutable_base()->mutable_acceleration()->set_x(relativeAcceleration.x());
+ detectedObject->mutable_base()->mutable_acceleration()->set_y(relativeAcceleration.y());
+}
+
+void ObjectDetectorBase::AddStationaryObjectToSensorData(osi3::StationaryObject object, point_t ownPosition, double yaw)
+{
+ point_t objectReferencePointGlobal{object.base().position().x(), object.base().position().y()};
+ point_t objectReferencePointLocal = TransformPointToLocalCoordinates(objectReferencePointGlobal, ownPosition, yaw);
+
+ osi3::DetectedStationaryObject* detectedObject = sensorData.add_stationary_object();
+ detectedObject->mutable_header()->add_ground_truth_id()->set_value(object.id().value());
+ detectedObject->mutable_header()->add_sensor_id()->set_value(id);
+ detectedObject->mutable_base()->mutable_dimension()->CopyFrom(object.base().dimension());
+
+ detectedObject->mutable_base()->mutable_position()->set_x(objectReferencePointLocal.x());
+ detectedObject->mutable_base()->mutable_position()->set_y(objectReferencePointLocal.y());
+ detectedObject->mutable_base()->mutable_orientation()->set_yaw(object.base().orientation().yaw() - yaw);
+}
+
Position ObjectDetectorBase::GetAbsolutePosition()
{
Position absolutePosition;
@@ -269,3 +308,33 @@ void ObjectDetectorBase::ParseBasicParameter()
position.yaw = doubleParameters.at("Yaw");
position.roll = doubleParameters.at("Roll");
}
+
+const osi3::MovingObject* ObjectDetectorBase::FindHostVehicleInSensorView(const osi3::SensorView& sensorView)
+{
+ const auto hostVehicleIt = std::find_if(sensorView.global_ground_truth().moving_object().cbegin(),
+ sensorView.global_ground_truth().moving_object().cend(),
+ [&sensorView](const osi3::MovingObject& object)
+ {
+ return object.id().value() == sensorView.host_vehicle_id().value();
+ });
+
+ if (hostVehicleIt == sensorView.global_ground_truth().moving_object().cend())
+ {
+ throw std::runtime_error("Host vehicle not in SensorView");
+ }
+
+ return &(*hostVehicleIt);
+}
+
+point_t ObjectDetectorBase::GetHostVehiclePosition(const osi3::MovingObject* hostVehicle) const
+{
+ point_t bbCenterToRear{hostVehicle->vehicle_attributes().bbcenter_to_rear().x(), hostVehicle->vehicle_attributes().bbcenter_to_rear().y()};
+ bt::rotate_transformer<bg::radian, double, 2, 2> rotate(-hostVehicle->base().orientation().yaw());
+ bt::translate_transformer<double, 2, 2> bbCenter(hostVehicle->base().position().x(), hostVehicle->base().position().y());
+ point_t rotatedBbCenterToRear;
+ point_t ownPosition;
+ bg::transform(bbCenterToRear, rotatedBbCenterToRear, rotate);
+ bg::transform(rotatedBbCenterToRear, ownPosition, bbCenter);
+
+ return ownPosition;
+}
diff --git a/sim/src/components/Sensor_OSI/src/objectDetectorBase.h b/sim/src/components/Sensor_OSI/src/objectDetectorBase.h
index 45e8b1f2..6472c81f 100644
--- a/sim/src/components/Sensor_OSI/src/objectDetectorBase.h
+++ b/sim/src/components/Sensor_OSI/src/objectDetectorBase.h
@@ -134,6 +134,27 @@ public:
protected:
/*!
+ * \brief Adds the information of a detected moving object as DetectedMovingObject to the sensor data
+ *
+ * \param object detected moving object
+ * \param ownVelocity velocity of own vehicle in global coordinates
+ * \param ownAcceleration acceleration of own vehicle in global coordinates
+ * \param ownPosition position of own vehicle in global coordinates
+ * \param yaw yaw of own vehicle in global coordinates
+ * \param yawRate yawRate of own vehicle in global coordinates
+ */
+ void AddMovingObjectToSensorData (osi3::MovingObject object, point_t ownVelocity, point_t ownAcceleration, point_t ownPosition, double yaw, double yawRate);
+
+ /*!
+ * \brief Adds the information of a detected stationary object as DetectedStationaryObject to the sensor data
+ *
+ * \param object stationary moving object
+ * \param ownPosition position of own vehicle in global coordinates
+ * \param yaw yaw of own vehicle in global coordinates
+ */
+ void AddStationaryObjectToSensorData (osi3::StationaryObject object, point_t ownPosition, double yaw);
+
+ /*!
* \brief Returns the absolute position of the sensor
*
* This method calculates and returns the absolute position of the sensor by adding the agent's position
@@ -226,6 +247,12 @@ protected:
*/
virtual point_t CalculateRelativeVector(const point_t absolute, const point_t own, double yaw);
+ //! Returns the MovingObject in the sensor view which was defined as host vehicle (by id)
+ static const osi3::MovingObject* FindHostVehicleInSensorView(const osi3::SensorView& sensorView);
+
+ //! Returns the world coordinate position of the host vehicle
+ point_t GetHostVehiclePosition(const osi3::MovingObject* hostVehicle) const;
+
std::list<std::pair<int, osi3::SensorData>> detectedObjectsBuffer;
osi3::SensorData sensorData;
diff --git a/sim/src/components/Sensor_OSI/src/sensorGeometric2D.cpp b/sim/src/components/Sensor_OSI/src/sensorGeometric2D.cpp
index 55bda331..aec47718 100644
--- a/sim/src/components/Sensor_OSI/src/sensorGeometric2D.cpp
+++ b/sim/src/components/Sensor_OSI/src/sensorGeometric2D.cpp
@@ -221,19 +221,6 @@ polygon_t SensorGeometric2D::CreateFivePointDetectionField() const
return detectionField;
}
-point_t SensorGeometric2D::GetHostVehiclePosition(const osi3::MovingObject* hostVehicle) const
-{
- point_t bbCenterToRear{hostVehicle->vehicle_attributes().bbcenter_to_rear().x(), hostVehicle->vehicle_attributes().bbcenter_to_rear().y()};
- bt::rotate_transformer<bg::radian, double, 2, 2> rotate(-hostVehicle->base().orientation().yaw());
- bt::translate_transformer<double, 2, 2> bbCenter(hostVehicle->base().position().x(), hostVehicle->base().position().y());
- point_t rotatedBbCenterToRear;
- point_t ownPosition;
- bg::transform(bbCenterToRear, rotatedBbCenterToRear, rotate);
- bg::transform(rotatedBbCenterToRear, ownPosition, bbCenter);
-
- return ownPosition;
-}
-
std::pair<point_t, polygon_t> SensorGeometric2D::CreateSensorDetectionField(const osi3::MovingObject* hostVehicle) const
{
polygon_t detectionField;
@@ -326,23 +313,6 @@ SensorDetectionResults SensorGeometric2D::DetectObjects()
return results;
}
-const osi3::MovingObject* SensorGeometric2D::FindHostVehicleInSensorView(const osi3::SensorView& sensorView)
-{
- const auto hostVehicleIt = std::find_if(sensorView.global_ground_truth().moving_object().cbegin(),
- sensorView.global_ground_truth().moving_object().cend(),
- [&sensorView](const osi3::MovingObject& object)
- {
- return object.id().value() == sensorView.host_vehicle_id().value();
- });
-
- if (hostVehicleIt == sensorView.global_ground_truth().moving_object().cend())
- {
- throw std::runtime_error("Host vehicle not in SensorView");
- }
-
- return &(*hostVehicleIt);
-}
-
std::pair<std::vector<const osi3::MovingObject*>, std::vector<const osi3::StationaryObject*>> SensorGeometric2D::GetObjectsInDetectionAreaFromSensorView(const osi3::SensorView& sensorView,
const point_t& sensorPositionGlobal,
const polygon_t& detectionField) const
@@ -439,45 +409,6 @@ std::pair<std::vector<T>, std::vector<T>> SensorGeometric2D::CalcVisualObstructi
return std::make_pair(visibleObjects, detectedObjects);
}
-void SensorGeometric2D::AddMovingObjectToSensorData(osi3::MovingObject object, point_t ownVelocity, point_t ownAcceleration, point_t ownPosition, double yaw, double yawRate)
-{
- point_t objectReferencePointGlobal{object.base().position().x(), object.base().position().y()};
- point_t objectReferencePointLocal = TransformPointToLocalCoordinates(objectReferencePointGlobal, ownPosition, yaw);
-
- osi3::DetectedMovingObject* detectedObject = sensorData.add_moving_object();
- detectedObject->mutable_header()->add_ground_truth_id()->set_value(object.id().value());
- detectedObject->mutable_header()->add_sensor_id()->set_value(id);
- detectedObject->mutable_base()->mutable_dimension()->CopyFrom(object.base().dimension());
-
- detectedObject->mutable_base()->mutable_position()->set_x(objectReferencePointLocal.x());
- detectedObject->mutable_base()->mutable_position()->set_y(objectReferencePointLocal.y());
- detectedObject->mutable_base()->mutable_orientation()->set_yaw(object.base().orientation().yaw() - yaw);
- detectedObject->mutable_base()->mutable_orientation_rate()->set_yaw(object.base().orientation_rate().yaw() - yawRate);
- point_t objectVelocity{object.base().velocity().x(), object.base().velocity().y()};
- point_t relativeVelocity = CalculateRelativeVector(objectVelocity, ownVelocity, yaw);
- detectedObject->mutable_base()->mutable_velocity()->set_x(relativeVelocity.x());
- detectedObject->mutable_base()->mutable_velocity()->set_y(relativeVelocity.y());
- point_t objectAcceleration{object.base().acceleration().x(), object.base().acceleration().y()};
- point_t relativeAcceleration = CalculateRelativeVector(objectAcceleration, ownAcceleration, yaw);
- detectedObject->mutable_base()->mutable_acceleration()->set_x(relativeAcceleration.x());
- detectedObject->mutable_base()->mutable_acceleration()->set_y(relativeAcceleration.y());
-}
-
-void SensorGeometric2D::AddStationaryObjectToSensorData(osi3::StationaryObject object, point_t ownPosition, double yaw)
-{
- point_t objectReferencePointGlobal{object.base().position().x(), object.base().position().y()};
- point_t objectReferencePointLocal = TransformPointToLocalCoordinates(objectReferencePointGlobal, ownPosition, yaw);
-
- osi3::DetectedStationaryObject* detectedObject = sensorData.add_stationary_object();
- detectedObject->mutable_header()->add_ground_truth_id()->set_value(object.id().value());
- detectedObject->mutable_header()->add_sensor_id()->set_value(id);
- detectedObject->mutable_base()->mutable_dimension()->CopyFrom(object.base().dimension());
-
- detectedObject->mutable_base()->mutable_position()->set_x(objectReferencePointLocal.x());
- detectedObject->mutable_base()->mutable_position()->set_y(objectReferencePointLocal.y());
- detectedObject->mutable_base()->mutable_orientation()->set_yaw(object.base().orientation().yaw() - yaw);
-}
-
polygon_t SensorGeometric2D::CalcInitialBrightArea(point_t sensorPosition)
{
const double stepSize = 0.1;
diff --git a/sim/src/components/Sensor_OSI/src/sensorGeometric2D.h b/sim/src/components/Sensor_OSI/src/sensorGeometric2D.h
index 10ebd8e7..50badd91 100644
--- a/sim/src/components/Sensor_OSI/src/sensorGeometric2D.h
+++ b/sim/src/components/Sensor_OSI/src/sensorGeometric2D.h
@@ -130,27 +130,6 @@ private:
static double CalcObjectVisibilityPercentage(const polygon_t& boundingBox, const multi_polygon_t &brightArea);
/*!
- * \brief Adds the information of a detected moving object as DetectedMovingObject to the sensor data
- *
- * \param object detected moving object
- * \param ownVelocity velocity of own vehicle in global coordinates
- * \param ownAcceleration acceleration of own vehicle in global coordinates
- * \param ownPosition position of own vehicle in global coordinates
- * \param yaw yaw of own vehicle in global coordinates
- * \param yawRate yawRate of own vehicle in global coordinates
- */
- void AddMovingObjectToSensorData (osi3::MovingObject object, point_t ownVelocity, point_t ownAcceleration, point_t ownPosition, double yaw, double yawRate);
-
- /*!
- * \brief Adds the information of a detected stationary object as DetectedStationaryObject to the sensor data
- *
- * \param object stationary moving object
- * \param ownPosition position of own vehicle in global coordinates
- * \param yaw yaw of own vehicle in global coordinates
- */
- void AddStationaryObjectToSensorData (osi3::StationaryObject object, point_t ownPosition, double yaw);
-
- /*!
* \brief Returns true if opening angle is smaller than pi
*/
bool OpeningAngleWithinHalfCircle() const;
@@ -170,8 +149,6 @@ private:
*/
polygon_t CreateFivePointDetectionField() const;
- point_t GetHostVehiclePosition(const osi3::MovingObject* hostVehicle) const;
-
std::pair<point_t, polygon_t> CreateSensorDetectionField(const osi3::MovingObject* hostVehicle) const;
template<typename T>
static void ApplyVisualObstructionToDetectionArea(multi_polygon_t& brightArea,
@@ -186,7 +163,6 @@ private:
const point_t& sensorPositionGlobal,
const polygon_t& detectionField) const;
- static const osi3::MovingObject* FindHostVehicleInSensorView(const osi3::SensorView& sensorView);
std::string CreateAgentIdListString(const std::vector<OWL::Id>& owlIds) const;
bool enableVisualObstruction = false;
diff --git a/sim/tests/unitTests/components/Sensor_OSI/CMakeLists.txt b/sim/tests/unitTests/components/Sensor_OSI/CMakeLists.txt
index 64039a1d..c696684a 100644
--- a/sim/tests/unitTests/components/Sensor_OSI/CMakeLists.txt
+++ b/sim/tests/unitTests/components/Sensor_OSI/CMakeLists.txt
@@ -18,6 +18,7 @@ add_openpass_target(
HEADERS
sensorOSI_Tests.h
+ sensorOSI_TestsCommon.h
${COMPONENT_SOURCE_DIR}/objectDetectorBase.h
${COMPONENT_SOURCE_DIR}/sensorGeometric2D.h
${OPENPASS_SIMCORE_DIR}/core/slave/modules/World_OSI/OWL/DataTypes.h
diff --git a/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.cpp b/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.cpp
index 6857000d..a638ab79 100644
--- a/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.cpp
+++ b/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.cpp
@@ -21,7 +21,7 @@
#include "fakeWorldData.h"
#include "sensorGeometric2D.h"
-
+#include "sensorOSI_TestsCommon.h"
#include "common/boostGeometryCommon.h"
using ::testing::_;
@@ -33,131 +33,6 @@ using ::testing::ReturnRef;
using ::testing::StrEq;
using ::testing::Ne;
-double constexpr EPSILON = 1e-9;
-
-bool IsEqual(double lhs, double rhs)
-{
- return std::abs(lhs - rhs) < EPSILON;
-}
-
-class MovingObjectParameter
-{
-public:
- MovingObjectParameter(unsigned int id,
- Common::Vector2d position,
- Common::Vector2d velocity,
- Common::Vector2d acceleration,
- double yaw) :
- id(id),
- position(position),
- velocity(velocity),
- acceleration(acceleration),
- yaw(yaw)
- {}
-
- MovingObjectParameter (const osi3::DetectedMovingObject& movingObject)
- {
- id = movingObject.header().ground_truth_id(0).value();
- position = Common::Vector2d(movingObject.base().position().x(), movingObject.base().position().y());
- velocity = Common::Vector2d(movingObject.base().velocity().x(), movingObject.base().velocity().y());
- acceleration = Common::Vector2d(movingObject.base().acceleration().x(), movingObject.base().acceleration().y());
- yaw = movingObject.base().orientation().yaw();
- }
-
- bool operator==(const MovingObjectParameter& rhs) const
- {
- if (id != rhs.id)
- {
- return false;
- }
-
- if (position != rhs.position ||
- velocity != rhs.velocity ||
- acceleration != rhs.acceleration)
- {
- return false;
- }
-
- if (!IsEqual(yaw, rhs.yaw))
- {
- return false;
- }
-
- return true;
- }
-
- /// \brief This stream will be shown in case the test fails
- friend std::ostream& operator<<(std::ostream& os, const MovingObjectParameter& obj)
- {
- os << "id: " << obj.id << ", "
- << "position: (" << obj.position.x << ", " << obj.position.y << "), "
- << "velocity: (" << obj.velocity.x << ", " << obj.velocity.y << "), "
- << "acceleration: (" << obj.acceleration.x << ", " << obj.acceleration.y << "), "
- << "yaw: " << obj.yaw;
-
- return os;
- }
-
- unsigned int id;
- Common::Vector2d position;
- Common::Vector2d velocity;
- Common::Vector2d acceleration;
- double yaw;
-};
-
-class StationaryObjectParameter
-{
-public:
- StationaryObjectParameter(unsigned int id,
- Common::Vector2d position,
- double yaw) :
- id(id),
- position(position),
- yaw(yaw)
- {}
-
- StationaryObjectParameter (const osi3::DetectedStationaryObject& stationaryObject)
- {
- id = stationaryObject.header().ground_truth_id(0).value();
- position = Common::Vector2d(stationaryObject.base().position().x(), stationaryObject.base().position().y());
- yaw = stationaryObject.base().orientation().yaw();
- }
-
- bool operator==(const StationaryObjectParameter& rhs)
- {
- if (id != rhs.id)
- {
- return false;
- }
-
- if (position != rhs.position)
- {
- return false;
- }
-
- if (!IsEqual(yaw, rhs.yaw))
- {
- return false;
- }
-
- return true;
- }
-
- /// \brief This stream will be shown in case the test fails
- friend std::ostream& operator<<(std::ostream& os, const StationaryObjectParameter& obj)
- {
- os << "id: " << obj.id << ", "
- << "position: (" << obj.position.x << ", " << obj.position.y << "), "
- << "yaw: " << obj.yaw;
-
- return os;
- }
-
- unsigned int id;
- Common::Vector2d position;
- double yaw;
-};
-
class DetectObjects_Data
{
public:
diff --git a/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.pro b/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.pro
index 3cf3ae80..4d749dce 100644
--- a/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.pro
+++ b/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_Tests.pro
@@ -32,7 +32,8 @@ HEADERS += \
$$WORLD_OSI/OWL/OpenDriveTypeMapper.h \
$$WORLD_OSI/WorldObjectAdapter.h \
$$WORLD_OSI/WorldData.h \
- $$WORLD_OSI/WorldDataException.h
+ $$WORLD_OSI/WorldDataException.h \
+ sensorOSI_TestsCommon.h
SOURCES += \
$$UNIT_UNDER_TEST/sensorGeometric2D.cpp \
diff --git a/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_TestsCommon.h b/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_TestsCommon.h
new file mode 100644
index 00000000..7357bd5f
--- /dev/null
+++ b/sim/tests/unitTests/components/Sensor_OSI/sensorOSI_TestsCommon.h
@@ -0,0 +1,122 @@
+#include "common/vector2d.h"
+#include "osi3/osi_detectedobject.pb.h"
+
+double constexpr EPSILON = 1e-9;
+
+class MovingObjectParameter
+{
+public:
+ MovingObjectParameter(unsigned int id,
+ Common::Vector2d position,
+ Common::Vector2d velocity,
+ Common::Vector2d acceleration,
+ double yaw) :
+ id(id),
+ position(position),
+ velocity(velocity),
+ acceleration(acceleration),
+ yaw(yaw)
+ {}
+
+ MovingObjectParameter (const osi3::DetectedMovingObject& movingObject)
+ {
+ id = movingObject.header().ground_truth_id(0).value();
+ position = Common::Vector2d(movingObject.base().position().x(), movingObject.base().position().y());
+ velocity = Common::Vector2d(movingObject.base().velocity().x(), movingObject.base().velocity().y());
+ acceleration = Common::Vector2d(movingObject.base().acceleration().x(), movingObject.base().acceleration().y());
+ yaw = movingObject.base().orientation().yaw();
+ }
+
+ bool operator==(const MovingObjectParameter& rhs) const
+ {
+ if (id != rhs.id)
+ {
+ return false;
+ }
+
+ if (position != rhs.position ||
+ velocity != rhs.velocity ||
+ acceleration != rhs.acceleration)
+ {
+ return false;
+ }
+
+ if ((yaw - rhs.yaw) > EPSILON)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /// \brief This stream will be shown in case the test fails
+ friend std::ostream& operator<<(std::ostream& os, const MovingObjectParameter& obj)
+ {
+ os << "id: " << obj.id << ", "
+ << "position: (" << obj.position.x << ", " << obj.position.y << "), "
+ << "velocity: (" << obj.velocity.x << ", " << obj.velocity.y << "), "
+ << "acceleration: (" << obj.acceleration.x << ", " << obj.acceleration.y << "), "
+ << "yaw: " << obj.yaw;
+
+ return os;
+ }
+
+ unsigned int id;
+ Common::Vector2d position;
+ Common::Vector2d velocity;
+ Common::Vector2d acceleration;
+ double yaw;
+};
+
+class StationaryObjectParameter
+{
+public:
+ StationaryObjectParameter(unsigned int id,
+ Common::Vector2d position,
+ double yaw) :
+ id(id),
+ position(position),
+ yaw(yaw)
+ {}
+
+ StationaryObjectParameter (const osi3::DetectedStationaryObject& stationaryObject)
+ {
+ id = stationaryObject.header().ground_truth_id(0).value();
+ position = Common::Vector2d(stationaryObject.base().position().x(), stationaryObject.base().position().y());
+ yaw = stationaryObject.base().orientation().yaw();
+ }
+
+ bool operator==(const StationaryObjectParameter& rhs)
+ {
+ if (id != rhs.id)
+ {
+ return false;
+ }
+
+ if (position != rhs.position)
+ {
+ return false;
+ }
+
+ if ((yaw - rhs.yaw) > EPSILON)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /// \brief This stream will be shown in case the test fails
+ friend std::ostream& operator<<(std::ostream& os, const StationaryObjectParameter& obj)
+ {
+ os << "id: " << obj.id << ", "
+ << "position: (" << obj.position.x << ", " << obj.position.y << "), "
+ << "yaw: " << obj.yaw;
+
+ return os;
+ }
+
+ unsigned int id;
+ Common::Vector2d position;
+ double yaw;
+};
diff --git a/sim/tests/unitTests/core/slave/profilesImporter_Tests.cpp b/sim/tests/unitTests/core/slave/profilesImporter_Tests.cpp
index 86736db3..681ce1fb 100644
--- a/sim/tests/unitTests/core/slave/profilesImporter_Tests.cpp
+++ b/sim/tests/unitTests/core/slave/profilesImporter_Tests.cpp
@@ -33,7 +33,7 @@ TEST(ProfilesImporter_ImportAllVehicleComponentsOfVehicleProfile, GivenValidXml_
"</Profiles>"
"<SensorLinks>"
"<SensorLink SensorId=\"0\" InputId=\"Camera\"/>"
- "<SensorLink SensorId=\"1\" InputId=\"DrivingCorridor\"/>"
+ "<SensorLink SensorId=\"1\" InputId=\"OtherSensor\"/>"
"<SensorLink SensorId=\"2\" InputId=\"Camera\"/>"
"</SensorLinks>"
"</Component>"
@@ -64,7 +64,7 @@ TEST(ProfilesImporter_ImportAllVehicleComponentsOfVehicleProfile, WithMissingCom
"</Profiles>"
"<SensorLinks>"
"<SensorLink SensorId=\"0\" InputId=\"Camera\"/>"
- "<SensorLink SensorId=\"1\" InputId=\"DrivingCorridor\"/>"
+ "<SensorLink SensorId=\"1\" InputId=\"OtherSensor\"/>"
"<SensorLink SensorId=\"2\" InputId=\"Camera\"/>"
"</SensorLinks>"
"</Component>"
@@ -87,7 +87,7 @@ TEST(ProfilesImporter_ImportAllVehicleComponentsOfVehicleProfile, SumOfProbabili
"</Profiles>"
"<SensorLinks>"
"<SensorLink SensorId=\"0\" InputId=\"Camera\"/>"
- "<SensorLink SensorId=\"1\" InputId=\"DrivingCorridor\"/>"
+ "<SensorLink SensorId=\"1\" InputId=\"OtherSensor\"/>"
"<SensorLink SensorId=\"2\" InputId=\"Camera\"/>"
"</SensorLinks>"
"</Component>"
@@ -110,7 +110,7 @@ TEST(ProfilesImporter_ImportAllSensorsOfVehicleProfile, GivenValidXml_ImportsVal
"</Sensor>"
"<Sensor Id=\"1\">"
"<Position Name=\"Somewhere\" Longitudinal=\"0.0\" Lateral=\"0.0\" Height=\"0.5\" Pitch=\"0.0\" Yaw=\"0.0\" Roll=\"0.0\"/>"
- "<Profile Type=\"DrivingCorridor\" Name=\"Camera\"/>"
+ "<Profile Type=\"OtherSensor\" Name=\"Camera\"/>"
"</Sensor>"
"</Sensors>"
"</root>"
@@ -149,7 +149,7 @@ TEST(ProfilesImporter_ImportAllSensorsOfVehicleProfile, SensorsTagMissing_Throws
"</Sensor>"
"<Sensor Id=\"1\">"
"<Position Name=\"Somewhere\" Longitudinal=\"0.0\" Lateral=\"0.0\" Height=\"0.5\" Pitch=\"0.0\" Yaw=\"0.0\" Roll=\"0.0\"/>"
- "<Profile Type=\"DrivingCorridor\" Name=\"Camera\"/>"
+ "<Profile Type=\"OtherSensor\" Name=\"Camera\"/>"
"</Sensor>"
"</root>"
);

Back to the top