diff --git a/src/tmx/Messages/include/SensorDetectedObject.h b/src/tmx/Messages/include/SensorDetectedObject.h index 252369874..d275bbf7e 100644 --- a/src/tmx/Messages/include/SensorDetectedObject.h +++ b/src/tmx/Messages/include/SensorDetectedObject.h @@ -12,9 +12,8 @@ namespace tmx { /** - * This SensorDetectedObject is used to communicate the sensor detected object information with various applications - * including internal infrastructure applications and external road user applications through simulated environment. - * It defines the message type and sub type and all data members. + * This SensorDetectedObject is used to communicate the sensor detected object information with various applications. + * This message is the generic representation of a sensor detection. */ class SensorDetectedObject : public tmx::message { @@ -29,13 +28,22 @@ namespace tmx static constexpr const char *MessageSubType = MSGSUBTYPE_SENSOR_DETECTED_OBJECT_STRING; // TODO: Convert this member variable to std::attributes and handle nested object and arrays. (see [CloudHeartbeatMessage.h](./CloudHearbeatMessage.h) array_attribute ) + + // Classification of detected object std::string type = ""; + // Confidence of type classification double confidence = 0.0; + // Unique indentifier of sensor reporting detection std::string sensorId = ""; + // String describing projection used to convert cartesian data to WGS84 data std::string projString = ""; + // Unique identifier of detected object int objectId = 0; + // Cartesian positiion of object. Assumed to be ENU coordinate frame. tmx::utils::Point position = tmx::utils::Point(); + // Cartesian velocity vector of object. Assumed to be ENU coordinate frame. tmx::utils::Vector3d velocity = tmx::utils::Vector3d(); + // Epoch time in milliseconds long timestamp = 0; }; diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py b/src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py index fe64bdbaa..55a8692cf 100755 --- a/src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py +++ b/src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py @@ -42,10 +42,8 @@ def move_detection(): return def create_socket(): - try: - return socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) - except socket.error as err: - print('Socket error because of %s' %(err)) + return socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) + def send_detection(sock, detection, host): try: msg = detection.to_csv() diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.cpp b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.cpp index eea0c4512..800549bc4 100644 --- a/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.cpp +++ b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.cpp @@ -25,7 +25,7 @@ namespace MUSTSensorDriverPlugin { detection.size = fromStringToDetectionSize(csv_values.at(5)); detection.confidence = std::stod(csv_values.at(6)); detection.trackID = std::stoi(csv_values.at(7)); - detection.timestamp = std::stoll(csv_values.at(8)); + detection.timestamp = std::stod(csv_values.at(8)); return detection; } @@ -35,7 +35,7 @@ namespace MUSTSensorDriverPlugin { detectedObject.position.X = detection.position_x; detectedObject.position.Y = detection.position_y; detectedObject.confidence = detection.confidence; - detectedObject.timestamp = detection.timestamp; + detectedObject.timestamp = static_cast(detection.timestamp*1000); // convert decimal seconds to int milliseconds. detectedObject.velocity = headingSpeedToVelocity(detection.heading, detection.speed); detectedObject.type = detectionClassificationToSensorDetectedObjectType(detection.cl); detectedObject.sensorId = sensorId; diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.h b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.h index 87c8e9c37..da36b7740 100644 --- a/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.h +++ b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.h @@ -64,7 +64,8 @@ namespace MUSTSensorDriverPlugin { DetectionClassification fromStringToDetectionClassification(const std::string &str) noexcept; /** - * @brief Converts DetectionClassification enumeration to string type for SensorDetectedObject + * @brief Converts DetectionClassification enumeration to string type for SensorDetectedObject. All types are + * assumed to be capitalize versions of the DetectionClassifications. * @param classifcation DetectionClassification * @return std::string type for SensorDetectedObject * @throws tmx::TmxException if DetectionClassification is not included in map. @@ -88,9 +89,9 @@ namespace MUSTSensorDriverPlugin { // Confidence in type double confidence = 0; // Unique ID - unsigned trackID = 0; + unsigned int trackID = 0; // Timestamp in seconds - unsigned long timestamp = 0; + double timestamp = 0; }; diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/test/TestMUSTSensorDetection.cpp b/src/v2i-hub/MUSTSensorDriverPlugin/test/TestMUSTSensorDetection.cpp index f37d80b49..d95df460a 100644 --- a/src/v2i-hub/MUSTSensorDriverPlugin/test/TestMUSTSensorDetection.cpp +++ b/src/v2i-hub/MUSTSensorDriverPlugin/test/TestMUSTSensorDetection.cpp @@ -56,7 +56,7 @@ TEST(TestMUSTSensorDetection, mustDetectionToSensorDetectedObject ) { detection.position_x = 10.5; detection.position_y = -20.3; detection.size = DetectionSize::SMALL; - detection.timestamp = duration_cast(system_clock::now().time_since_epoch()).count(); + detection.timestamp = 1719506355.4; detection.trackID = 324; detection.speed = 5; @@ -69,7 +69,7 @@ TEST(TestMUSTSensorDetection, mustDetectionToSensorDetectedObject ) { EXPECT_NEAR(4.33, sensorDetectedObject.velocity.Y, 0.001); EXPECT_NEAR(2.5, sensorDetectedObject.velocity.X, 0.001); EXPECT_STRCASEEQ("SEDAN", sensorDetectedObject.type.c_str()); - EXPECT_EQ(detection.timestamp, sensorDetectedObject.timestamp); + EXPECT_EQ(1719506355400, sensorDetectedObject.timestamp); EXPECT_EQ("MUSTSensor1", sensorDetectedObject.sensorId); EXPECT_EQ("PROJ String", sensorDetectedObject.projString); }