Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jun 23, 2024
1 parent 90a9c81 commit 8d9aa04
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/tmx/TmxUtils/src/UdpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ namespace tmx::utils {
return -1;
}

std::string UdpServer::stringTimedReceive() {
std::string UdpServer::stringTimedReceive(int maxWait_ms) {
std::vector<char> msg(4000);
int num_of_bytes = this->TimedReceive(msg.data(),4000, 5);
int num_of_bytes = this->TimedReceive(msg.data(),4000, maxWait_ms);
if (num_of_bytes > 0 ) {
msg.resize(num_of_bytes);
std::string ret(msg.data());
Expand Down
2 changes: 1 addition & 1 deletion src/tmx/TmxUtils/src/UdpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UdpServer
virtual int Receive(char *msg, size_t maxSize);
virtual int TimedReceive(char *msg, size_t maxSize, int maxWait_ms);

virtual std::string stringTimedReceive();
virtual std::string stringTimedReceive(int maxWait_ms=5);

private:
int _socket;
Expand Down
2 changes: 1 addition & 1 deletion src/v2i-hub/MUSTSensorDriverPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

[MUST](https://www.aiwaysion.com/technology) (Mobile Unit for Sensing Traffic) Sensor from AI Waysion is a camera based sensor, planned to be used for cooperative perception in freight use cases.<Some sentence about what ever university is developing the detection algorythms for this sensor>. The MUST Sensor provides detections via UDP packets made up of CSV (Comma Separated Values) string data. The V2X-Hub MUST Sensor Driver Plugin will then consume these messages and translate them to **Sensor Detected Object** messages, which is V2X-Hub's generic detection message. This message is consumable by the **CARMA Streets [Sensor Data Sharing Service](https://github.com/usdot-fhwa-stol/carma-streets/blob/develop/sensor_data_sharing_service/README.md)** which will generate **Sensor Data Sharing Message**s according to the J3224 standard for broadcast to other traffic actors in the area.
[MUST](https://www.aiwaysion.com/technology) (Mobile Unit for Sensing Traffic) Sensor from AI Waysion is a camera based sensor, planned to be used for cooperative perception in freight use cases. The MUST Sensor provides detections via UDP packets made up of CSV (Comma Separated Values) string data. The V2X-Hub MUST Sensor Driver Plugin will then consume these messages and translate them to **Sensor Detected Object** messages, which is V2X-Hub's generic detection message. This message is consumable by the **CARMA Streets [Sensor Data Sharing Service](https://github.com/usdot-fhwa-stol/carma-streets/blob/develop/sensor_data_sharing_service/README.md)** which will generate **Sensor Data Sharing Message**s according to the J3224 standard for broadcast to other traffic actors in the area.

## Related Plugins

Expand Down
6 changes: 3 additions & 3 deletions src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class MUSTDetection:
track_id: int
timestamp: int

def to_csv():
return f'{self.classification},{self.x},{self.y},{self.heading},{self.speed},{self.size},{self.confidence},{self.track_id},{self.timstamp}'
def to_csv(self):
return f'{self.classification.value},{self.x},{self.y},{self.heading},{self.speed},{self.size.value},{self.confidence},{self.track_id},{self.timestamp}'

def move_detection():
return
Expand All @@ -48,7 +48,7 @@ def create_socket():
print('Socket error because of %s' %(err))
def send_detection(sock, detection, host):
try:
msg = detection
msg = detection.to_csv()
encoded_msg = str.encode(msg)
sock.sendto(encoded_msg,host)
print( encoded_msg.decode(encoding= 'UTF-8'), 'was sent to ', host)
Expand Down
21 changes: 16 additions & 5 deletions src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ namespace MUSTSensorDriverPlugin {
SubscribeToMessages();
}


void MUSTSensorDriverPlugin::OnStateChange(IvpPluginState state) {
PluginClientClockAware::OnStateChange(state);
if (state == IvpPluginState_registered) {
UpdateConfigSettings();
}
}

void MUSTSensorDriverPlugin::UpdateConfigSettings()
{
Expand All @@ -44,7 +49,7 @@ namespace MUSTSensorDriverPlugin {
GetConfigValue<std::string>("DetectionReceiverIP", ip_address);
GetConfigValue<uint>("DetectionReceiverPort", port);
createUdpServer(ip_address, port);
SetStatus(keyMUSTSensorConnectionStatus, "IDLE", true);
SetStatus(keyMUSTSensorConnectionStatus, "IDLE");

mustSensorPacketReceiverThreadId = mustSensorPacketReceiverThread->AddPeriodicTick([this]() {
this->processMUSTSensorDetection();
Expand All @@ -60,18 +65,24 @@ namespace MUSTSensorDriverPlugin {
MUSTSensorDetection detection = csvToDectection(mustSensorPacketReceiver->stringTimedReceive());
if ( !connected ) {
connected = true;
SetStatus(keyMUSTSensorConnectionStatus, "CONNECTED", true);
SetStatus(keyMUSTSensorConnectionStatus, "CONNECTED");
}
tmx::messages::SensorDetectedObject msg = mustDetectionToSensorDetectedObject(detection, sensorId, projString);
PLOG(logDEBUG1) << "Sending Simulated SensorDetectedObject Message " << msg << std::endl;
this->BroadcastMessage<tmx::messages::SensorDetectedObject>(msg, _name, 0 , IvpMsgFlags_None);
}
catch( const tmx::utils::UdpServerRuntimeError &e) {
SetStatus(keyMUSTSensorConnectionStatus, "DISCONNECTED", true);
PLOG(logERROR) << "Error occurred processing MUSTSensorDetection" << e << std::endl;
SetStatus(keyMUSTSensorConnectionStatus, "DISCONNECTED");
connected = false;
}
catch ( const std::runtime_error &e){
PLOG(logERROR) << "Error occurred processing MUSTSensorDetection" << e.what() << std::endl;
SetStatus(keyMUSTSensorConnectionStatus, "DISCONNECTED");
connected = false;
}
}else {
SetStatus(keyMUSTSensorConnectionStatus, "DISCONNECTED", true);
SetStatus(keyMUSTSensorConnectionStatus, "DISCONNECTED");
connected = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace MUSTSensorDriverPlugin
void UpdateConfigSettings();
void OnConfigChanged(const char *key, const char *value) override;
void createUdpServer(const std::string &address, unsigned int port);

void OnStateChange(IvpPluginState state);
void processMUSTSensorDetection();

public:
Expand Down

0 comments on commit 8d9aa04

Please sign in to comment.