-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streets MOSAIC integration: CDASimAdapter register with Simulation ambassador and send sensors information #554
Changes from 22 commits
d0a5fbc
c96db25
c4474a8
950a211
297e147
4a76dd0
a7ffaa6
680b94e
f9b2190
f5840ff
7a1fc37
44685f3
9ae8603
c1c334f
85280e4
9abb47b
55221e3
e1825e7
646168a
b2ba7b9
d3c8d53
0db0b59
fa44458
f438b05
11a36d6
0c615eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import socket | ||
''' | ||
Purpose: This script is to launch a UDP server and used to test the CDASimAdapter simulation registration. | ||
Usage: Run this script first, it shall open a socket listenning to port 6767. | ||
Launch the v2xhub and enable the CDASimAdapter plugin. Upon the plugin startup, | ||
it sends registration message to port 6767. This UDP server shall receive the registration message, | ||
and print this message on the terminal. | ||
Run command: python3 udp_socket_server.py | ||
''' | ||
UDP_IP = "127.0.0.1" | ||
UDP_SOCKET_PORT_SIM_REGISTRATION = 6767 | ||
|
||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
sock.bind((UDP_IP, UDP_SOCKET_PORT_SIM_REGISTRATION)) | ||
print("Server Listenning on port: %s" % UDP_SOCKET_PORT_SIM_REGISTRATION) | ||
|
||
while True: | ||
data, addr = sock.recvfrom(1024) | ||
print("recevied message: %s" % data) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#include <WGS84Point.h> | ||
#include <MockUdpClient.h> | ||
#include <MockUdpServer.h> | ||
#include <filesystem> | ||
|
||
|
||
using testing::_; | ||
|
@@ -23,13 +24,14 @@ namespace CDASimAdapter { | |
void SetUp() override { | ||
// 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, location); | ||
connection = std::make_shared<CDASimConnection>("127.0.0.1", "1212", 4567, 4678, "127.0.0.1", 1213, 1214, location, sensors_file_path); | ||
} | ||
void TearDown() override { | ||
|
||
} | ||
public: | ||
std::shared_ptr<CDASimConnection> connection; | ||
std::string sensors_file_path = "../../CDASimAdapter/test/sensors.json"; | ||
|
||
|
||
}; | ||
|
@@ -85,10 +87,13 @@ namespace CDASimAdapter { | |
location.X = 1000; | ||
location.Y = 38.955; | ||
location.Z = -77.149; | ||
|
||
ASSERT_EQ(connection->get_handshake_json("4566", "127.0.0.1", 4567, 4568, location), | ||
"{\n \"infrastructureId\" : \"4566\",\n \"location\" : {\n \"x\" : 1000.0,\n \"y\" : 38.954999999999998,\n \"z\" : -77.149000000000001\n },\n \"rxMessageIpAddress\" : \"127.0.0.1\",\n \"rxMessagePort\" : 4568,\n \"timeSyncPort\" : 4567\n}\n"); | ||
|
||
std::ifstream in_strm; | ||
in_strm.open(sensors_file_path, std::ifstream::binary); | ||
if(in_strm.is_open()) | ||
{ | ||
ASSERT_EQ(connection->get_handshake_json("4566", "127.0.0.1", 4567, 4568, location), | ||
"{\n \"infrastructureId\" : \"4566\",\n \"location\" : {\n \"x\" : 1000.0,\n \"y\" : 38.954999999999998,\n \"z\" : -77.149000000000001\n },\n \"rxMessageIpAddress\" : \"127.0.0.1\",\n \"rxMessagePort\" : 4568,\n \"sensors\" : [\n {\n \"location\" : {\n \"x\" : 0.0,\n \"y\" : 0.0,\n \"z\" : 0.0\n },\n \"orientation\" : {\n \"x\" : 0.0,\n \"y\" : 0.0,\n \"z\" : 0.0\n },\n \"sensorId\" : \"SomeID\",\n \"type\" : \"SematicLidar\"\n },\n {\n \"location\" : {\n \"x\" : 1.0,\n \"y\" : 2.0,\n \"z\" : 0.0\n },\n \"orientation\" : {\n \"x\" : 23.0,\n \"y\" : 0.0,\n \"z\" : 0.0\n },\n \"sensorId\" : \"SomeID2\",\n \"type\" : \"LIDAR\"\n }\n ],\n \"timeSyncPort\" : 4567\n}\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lastly orientation should be
|
||
} | ||
} | ||
|
||
TEST_F( TestCARMASimulationConnection, carma_simulation_handshake) { | ||
|
@@ -101,4 +106,23 @@ namespace CDASimAdapter { | |
TEST_F(TestCARMASimulationConnection, connect) { | ||
ASSERT_TRUE(connection->connect()); | ||
} | ||
|
||
TEST_F(TestCARMASimulationConnection, read_json_file) | ||
{ | ||
auto sensorJsonV = connection->read_json_file("Invalid_file_path" ); | ||
ASSERT_TRUE(sensorJsonV.empty()); | ||
std::ifstream in_strm; | ||
in_strm.open(sensors_file_path, std::ifstream::binary); | ||
if(in_strm.is_open()) | ||
{ | ||
sensorJsonV = connection->read_json_file(sensors_file_path ); | ||
ASSERT_FALSE(sensorJsonV.empty()); | ||
} | ||
} | ||
|
||
TEST_F(TestCARMASimulationConnection, string_to_json) | ||
{ | ||
auto sensorJsonV = connection->string_to_json("Invalid Json"); | ||
ASSERT_TRUE(sensorJsonV.empty()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"sensorId": "SomeID", | ||
"type": "SematicLidar", | ||
"location": { | ||
"x": 0.0, | ||
"y": 0.0, | ||
"z": 0.0 | ||
}, | ||
"orientation": { | ||
"x": 0.0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment about about yaw, pitch, roll |
||
"y": 0.0, | ||
"z": 0.0 | ||
} | ||
}, | ||
{ | ||
"sensorId": "SomeID2", | ||
"type": "LIDAR", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will only support SemanticLidar type for right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
"location": { | ||
"x": 1.0, | ||
"y": 2.0, | ||
"z": 0.0 | ||
}, | ||
"orientation": { | ||
"x": 23.0, | ||
"y": 0.0, | ||
"z": 0.0 | ||
} | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was your reasoning for including this as an environment variable instead of a plugin configuration similar to location. Just curious, I think we need to define a clear line between what we use as environment variables and what ew configure in the plugin. Simulation configurations are good to have in as environment variables because they do not require configuration and can be read easily at startup. They are also unlikely to change dynamically. I think that makes sense for the sensor configuration file as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you answer your own question? Yeah, I agree that the file path for sensors shall not change constantly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah just wanted to bring it up, that we give thought to what is an environment variable and what is a configuration parameter.