Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jun 27, 2024
1 parent 96664bd commit 4fd36ec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
14 changes: 11 additions & 3 deletions src/tmx/Messages/include/SensorDetectedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;

};
Expand Down
6 changes: 2 additions & 4 deletions src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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<long>(detection.timestamp*1000); // convert decimal seconds to int milliseconds.
detectedObject.velocity = headingSpeedToVelocity(detection.heading, detection.speed);
detectedObject.type = detectionClassificationToSensorDetectedObjectType(detection.cl);
detectedObject.sensorId = sensorId;
Expand Down
7 changes: 4 additions & 3 deletions src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<milliseconds>(system_clock::now().time_since_epoch()).count();
detection.timestamp = 1719506355.4;
detection.trackID = 324;
detection.speed = 5;

Expand All @@ -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);
}
Expand Down

0 comments on commit 4fd36ec

Please sign in to comment.