Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Jul 25, 2023
1 parent 89fb734 commit bdd7dcf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose-vscode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
- TIME_SYNC_TOPIC=time_sync
- TIME_SYNC_PORT=7575
- SIM_V2X_PORT=5757
- SIM_SENSOR_DETECTED_OBJECT_PORT=7576
- SIM_INTERACTION_PORT=7576
- V2X_PORT=8686
- INFRASTRUCTURE_ID=1
secrets:
Expand Down
2 changes: 1 addition & 1 deletion configuration/amd64/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
- TIME_SYNC_TOPIC=time_sync
- TIME_SYNC_PORT=7575
- SIM_V2X_PORT=5757
- SIM_SENSOR_DETECTED_OBJECT_PORT=7576
- SIM_INTERACTION_PORT=7576
- V2X_PORT=8686
- INFRASTRUCTURE_ID=1
- KAFKA_BROKER_ADDRESS=127.0.0.1:9092
Expand Down
2 changes: 1 addition & 1 deletion src/tmx/TmxUtils/src/simulation/SimulationEnvUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace tmx::utils::sim{
* @brief Name of environment variable for storing port for forwarding v2x messages to CDASim. Only
* necessary in SIMULATION MODE for CDASim message forwarding.
*/
constexpr inline static const char *SIM_SENSOR_DETECTED_OBJECT_PORT = "SIM_SENSOR_DETECTED_OBJECT_PORT";
constexpr inline static const char *SIM_INTERACTION_PORT= "SIM_INTERACTION_PORT";
/**
* @brief Name of environment variable for storing port for receiving v2x messages from CDASim. Only
* necessary in SIMULATION MODE for CDASim message forwarding.
Expand Down
6 changes: 3 additions & 3 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 sensor_detected_object_detection_port = std::stoul(sim::get_sim_config(sim::SIM_SENSOR_DETECTED_OBJECT_PORT));
uint simulated_interaction_port = std::stoul(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 All @@ -101,11 +101,11 @@ namespace CDASimAdapter{
" Time Sync Port: " << std::to_string( time_sync_port) << " and V2X Port: " << std::to_string(v2x_port) << std::endl;
if ( connection ) {
connection.reset(new CDASimConnection( simulation_ip, infrastructure_id, simulation_registration_port, sim_v2x_port, local_ip,
time_sync_port, sensor_detected_object_detection_port, v2x_port, location ));
time_sync_port, simulated_interaction_port, v2x_port, location ));
}
else {
connection = std::make_unique<CDASimConnection>(simulation_ip, infrastructure_id, simulation_registration_port, sim_v2x_port, local_ip,
time_sync_port, sensor_detected_object_detection_port, v2x_port, location);
time_sync_port, simulated_interaction_port, v2x_port, location);
}
}
catch (const TmxException &e) {
Expand Down
22 changes: 11 additions & 11 deletions src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ using namespace tmx::utils;

namespace CDASimAdapter{
CDASimConnection::CDASimConnection(const std::string &simulation_ip, const std::string &infrastructure_id, const uint simulation_registration_port, const uint sim_v2x_port,
const std::string &local_ip, const uint time_sync_port,const uint sensor_detected_object_detection_port, const uint v2x_port,
const std::string &local_ip, const uint time_sync_port,const uint simulated_interaction_port, const uint v2x_port,
const Point &location) :
_simulation_ip(simulation_ip), _infrastructure_id(infrastructure_id), _simulation_registration_port(simulation_registration_port),
_simulation_v2x_port(sim_v2x_port), _local_ip(local_ip), _time_sync_port(time_sync_port), _sensor_detected_object_detection_port(sensor_detected_object_detection_port),_v2x_port(v2x_port),
_simulation_v2x_port(sim_v2x_port), _local_ip(local_ip), _time_sync_port(time_sync_port), _simulated_interaction_port(simulated_interaction_port),_v2x_port(v2x_port),
_location(location) {
PLOG(logDEBUG) << "CARMA-Simulation connection initialized." << std::endl;
}
Expand All @@ -20,11 +20,11 @@ namespace CDASimAdapter{
}

bool CDASimConnection::connect() {
if (!carma_simulation_handshake(_simulation_ip, _infrastructure_id, _simulation_registration_port, _local_ip, _time_sync_port, _sensor_detected_object_detection_port, _v2x_port, _location)) {
if (!carma_simulation_handshake(_simulation_ip, _infrastructure_id, _simulation_registration_port, _local_ip, _time_sync_port, _simulated_interaction_port, _v2x_port, _location)) {
_connected = false;
return _connected;
}
if (!setup_udp_connection(_simulation_ip, _local_ip, _time_sync_port,_sensor_detected_object_detection_port, _v2x_port, _simulation_v2x_port )) {
if (!setup_udp_connection(_simulation_ip, _local_ip, _time_sync_port,_simulated_interaction_port, _v2x_port, _simulation_v2x_port )) {
_connected = false;
return _connected;
}
Expand All @@ -34,7 +34,7 @@ namespace CDASimAdapter{
}


std::string CDASimConnection::get_handshake_json(const std::string &infrastructure_id, const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port, const uint v2x_port,
std::string CDASimConnection::get_handshake_json(const std::string &infrastructure_id, const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port, const uint v2x_port,
const Point &location) const

{
Expand All @@ -45,7 +45,7 @@ namespace CDASimAdapter{
message["infrastructureId"] = infrastructure_id;
message["rxMessagePort"] = v2x_port;
message["timeSyncPort"] = time_sync_port;
message["simulatedInteractionPort"] = sensor_detected_object_detection_port;
message["simulatedInteractionPort"] = simulated_interaction_port;
message["location"]["x"] = location.X;
message["location"]["y"] = location.Y;
message["location"]["z"] = location.Z;
Expand All @@ -55,13 +55,13 @@ namespace CDASimAdapter{
}

bool CDASimConnection::carma_simulation_handshake(const std::string &simulation_ip, const std::string &infrastructure_id, const uint simulation_registration_port,
const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port, const uint v2x_port,
const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port, const uint v2x_port,
const Point &location)
{
// Create JSON message with the content
std::string payload = "";

payload = get_handshake_json(infrastructure_id, local_ip, time_sync_port, sensor_detected_object_detection_port, v2x_port, location);
payload = get_handshake_json(infrastructure_id, local_ip, time_sync_port, simulated_interaction_port, v2x_port, location);

try
{
Expand All @@ -77,7 +77,7 @@ namespace CDASimAdapter{
return true;
}

bool CDASimConnection::setup_udp_connection(const std::string &simulation_ip, const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port,
bool CDASimConnection::setup_udp_connection(const std::string &simulation_ip, const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port,
const uint v2x_port, const uint simulation_v2x_port) {
try {
// Iniitialize CARMA Simulation UDP Server and Client to foward V2X messages between CARMA simulation
Expand All @@ -95,13 +95,13 @@ namespace CDASimAdapter{
message_receiver_publisher = std::make_shared<UdpClient>( local_ip, 8765);
// Initialize UDP Server for listening for incoming CARMA-Simulation time synchronization.
PLOG(logDEBUG) << "Creating UDPServer for Time Sync Messages: " << local_ip << ":" << std::to_string(time_sync_port) << "\n"
<< "Creating UDPServer for Simulated External Object detection: " << local_ip << ":" << std::to_string(sensor_detected_object_detection_port) << "\n"
<< "Creating UDPServer for Simulated External Object detection: " << local_ip << ":" << std::to_string(simulated_interaction_port) << "\n"
<< "Creating UDPServer for CDA V2X message forwarding: " << local_ip << ":" << std::to_string(v2x_port) << "\n"
<< "Creating UDPClient for CDA V2X message forwarding: " << simulation_ip << ":" << std::to_string(simulation_v2x_port) << "\n"
<< "Creating UDPServer for Immediate Forward " << local_ip << ":" << std::to_string(5678) << "\n"
<< "Creating UDPClient for Message Receiver " << local_ip << ":" << std::to_string(8765) << std::endl;
time_sync_listener = std::make_shared<UdpServer>(local_ip,time_sync_port);
sensor_detected_object_listener = std::make_shared<UdpServer> (local_ip, sensor_detected_object_detection_port);
sensor_detected_object_listener = std::make_shared<UdpServer> (local_ip, simulated_interaction_port);
}
catch (const UdpClientRuntimeError &e) {
PLOG(logERROR) << "Encountered UDPClient Runtime error during UDP connection initialization : " << e.what() << std::endl;
Expand Down
10 changes: 5 additions & 5 deletions src/v2i-hub/CDASimAdapter/src/include/CDASimConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace CDASimAdapter {
* @param location Simulationed location of infrastructure.
*/
explicit CDASimConnection( const std::string &simulation_ip, const std::string &infrastructure_id, const uint simulation_registration_port,
const uint sim_v2x_port, const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port, const uint v2x_port,
const uint sim_v2x_port, const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port, const uint v2x_port,
const tmx::utils::Point &location);
/**
* @brief Method to forward v2x message to CARMA Simulation
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace CDASimAdapter {
* @return true if handshake successful and false if handshake unsuccessful.
*/
bool carma_simulation_handshake(const std::string &simulation_ip, const std::string &infrastructure_id, const uint simulation_registration_port,
const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port, const uint v2x_port,
const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port, const uint v2x_port,
const tmx::utils::Point &location);

/**
Expand All @@ -113,7 +113,7 @@ namespace CDASimAdapter {
* @param simulation_v2x_port port on which CARMA-Simulation is listening for incoming v2x messages.
* @return true if setup is successful and false otherwise.
*/
bool setup_udp_connection(const std::string &simulation_ip, const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port,
bool setup_udp_connection(const std::string &simulation_ip, const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port,
const uint v2x_port, const uint simulation_v2x_port);
/**
* @brief Method to attempt to establish connection between CARMA-Simulation and infrastucture. Returns true if succesful
Expand All @@ -136,13 +136,13 @@ namespace CDASimAdapter {
* @param location simulated location of infrastructure hardware.
* @return true if handshake successful and false if handshake unsuccessful.
*/
std::string get_handshake_json(const std::string &infrastructure_id, const std::string &local_ip, const uint time_sync_port, const uint sensor_detected_object_detection_port,
std::string get_handshake_json(const std::string &infrastructure_id, const std::string &local_ip, const uint time_sync_port, const uint simulated_interaction_port,
const uint v2x_port, const tmx::utils::Point &location) const;
std::string _simulation_ip;
uint _simulation_registration_port;
std::string _infrastructure_id;
uint _simulation_v2x_port;
uint _sensor_detected_object_detection_port;
uint _simulated_interaction_port;
std::string _local_ip;
uint _time_sync_port;
uint _v2x_port;
Expand Down

0 comments on commit bdd7dcf

Please sign in to comment.