Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Jul 28, 2023
1 parent 8aa3778 commit 4bafa7c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/v2i-hub/CARMAStreetsPlugin/src/CARMAStreetsPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ class CARMAStreetsPlugin: public PluginClientClockAware {
void HandleMobilityOperationMessage(tsm3Message &msg, routeable_message &routeableMsg);
void HandleMobilityPathMessage(tsm2Message &msg, routeable_message &routeableMsg);
void HandleBasicSafetyMessage(BsmMessage &msg, routeable_message &routeableMsg);
void HandleSimulatedSensorDetectedMessage(simulation::SensorDetectedObject &msg, routeable_message &routeableMsg);
/**
* @brief Handler to be invoked when the plugin received detected object, and forward the detected object to Kafka topic.
* @param msg Detected object received from TMX bus.
* @param routeableMsg routeable_message for detected object.
*/
void HandleSimulatedSensorDetectedMessage(simulation::SensorDetectedObject &msg, routeable_message &routeableMsg);
/**
* @brief Overide PluginClientClockAware HandleTimeSyncMessage to producer TimeSyncMessage to kafka for CARMA Streets Time Synchronization.
* @param msg TimeSyncMessage received by plugin when in simulation mode. Message provides current simulation time to all processes.
Expand Down
10 changes: 5 additions & 5 deletions src/v2i-hub/CDASimAdapter/src/CDASimAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace CDASimAdapter{
PLOG(logINFO) << "Simulation and local IP successfully initialized!"<< std::endl;
uint simulation_registration_port = std::stoul(sim::get_sim_config(sim::SIMULATION_REGISTRATION_PORT));
uint time_sync_port = std::stoul(sim::get_sim_config(sim::TIME_SYNC_PORT));
uint simulated_interaction_port = std::stoul(sim::get_sim_config(sim::SIM_INTERACTION_PORT));
uint simulated_interaction_port =static_cast<unsigned int>(std::stoi(sim::get_sim_config(sim::SIM_INTERACTION_PORT)));
uint v2x_port = std::stoul(sim::get_sim_config(sim::V2X_PORT));
uint sim_v2x_port = std::stoul(sim::get_sim_config(sim::SIM_V2X_PORT));
std::string infrastructure_id = sim::get_sim_config(sim::INFRASTRUCTURE_ID);
Expand Down Expand Up @@ -172,11 +172,11 @@ namespace CDASimAdapter{
PLOG(logDEBUG) << "Creating Thread Timer for simulated external object" << std::endl;
try
{
if(!external_bject_detection_thread_timer)
if(!external_object_detection_thread_timer)
{
external_bject_detection_thread_timer = std::make_unique<tmx::utils::ThreadTimer>();
external_object_detection_thread_timer = std::make_unique<tmx::utils::ThreadTimer>();
}
external_bject_detection_thread_timer->AddPeriodicTick([this](){
external_object_detection_thread_timer->AddPeriodicTick([this](){
PLOG(logDEBUG1) << "Listening for Sensor Detected Message from CDASim." << std::endl;
auto msg = connection->consume_sensor_detected_object_message();
if ( !msg.is_empty()) {
Expand All @@ -188,7 +188,7 @@ namespace CDASimAdapter{
}
}//End lambda
, std::chrono::milliseconds(100));
external_bject_detection_thread_timer->Start();
external_object_detection_thread_timer->Start();
}
catch ( const UdpServerRuntimeError &e )
{
Expand Down
8 changes: 4 additions & 4 deletions src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace CDASimAdapter{
msg.set_contents( str_msg );
}
else {
throw std::runtime_error("Time Sync UDP Server is not initialized");
throw UdpServerRuntimeError("Time Sync UDP Server is not initialized");
}
return msg;

Expand All @@ -149,7 +149,7 @@ namespace CDASimAdapter{
}
else
{
throw std::runtime_error("Simulated External Object UDP Server is not initialized.");
throw UdpServerRuntimeError("Simulated External Object UDP Server is not initialized.");
}
return externalObj;
}
Expand Down Expand Up @@ -200,7 +200,7 @@ namespace CDASimAdapter{
return msg;
}
else {
throw std::runtime_error("CARMA Simulation UDP Server is not initialized!");
throw UdpServerRuntimeError("CARMA Simulation UDP Server is not initialized!");
}
return "";

Expand All @@ -212,7 +212,7 @@ namespace CDASimAdapter{
return msg;
}
else {
throw std::runtime_error("Immediate Forward UDP Server is not initialized!");
throw UdpServerRuntimeError("Immediate Forward UDP Server is not initialized!");
}
return "";

Expand Down
2 changes: 1 addition & 1 deletion src/v2i-hub/CDASimAdapter/src/include/CDASimAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace CDASimAdapter
std::unique_ptr<CDASimConnection> connection;
// Mutex for configuration parameter thread safety
std::mutex _lock;
std::unique_ptr<tmx::utils::ThreadTimer> external_bject_detection_thread_timer;
std::unique_ptr<tmx::utils::ThreadTimer> external_object_detection_thread_timer;
// Time sync thread to forward time sync messages to PluginClientClockAware V2X-Hub plugins.
std::unique_ptr<tmx::utils::ThreadTimer> time_sync_timer;
// Time sync thread id
Expand Down
2 changes: 1 addition & 1 deletion src/v2i-hub/CDASimAdapter/src/include/CDASimConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace CDASimAdapter {
tmx::messages::TimeSyncMessage consume_time_sync_message() const;
/**
* @brief Method to consume incoming external object message.
* //To populate the simulation external object, this JSON string has to follow this specification: https://usdot-carma.atlassian.net/wiki/spaces/CRMSIM/pages/2563899417/Detected+Objects+Specification#CARMA-Street-and-V2xHub
* To populate the simulation external object, this JSON string has to follow this specification: https://usdot-carma.atlassian.net/wiki/spaces/CRMSIM/pages/2563899417/Detected+Objects+Specification#CARMA-Street-and-V2xHub
* @return simulation::SensorDetectedObject.
*/
tmx::messages::simulation::SensorDetectedObject consume_sensor_detected_object_message() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace CDASimAdapter {
class TestCARMASimulationConnection : public ::testing::Test {
protected:
void SetUp() override {
// Initialize CARMA Simulation connection with (0,0,0) location and mock kafka producer.
// Initialize CARMA Simulation connection with (0,0,0) location.
Point location;
connection = std::make_shared<CDASimConnection>("127.0.0.1", "1212", 4567, 4678, "127.0.0.1", 1213, 1214, 1215, location, sensors_file_path);
}
Expand Down

0 comments on commit 4bafa7c

Please sign in to comment.