-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CARMA Cloud ambassador integration (#200)
<!-- Thanks for the contribution, this is awesome. --> # PR Details ## Description This PR primarily focuses on merging a branch into develop, which encompasses the integration testing of CARMA Cloud with CDASim. The purpose of this integration test was to assess the communication between CARMA Cloud and CDASim, ensuring that: All components operate correctly within CDASim without encountering any significant problems. CARMA Cloud successfully registers with Ambassador. CARMA Cloud receives and processes time synchronization messages. ## Related GitHub Issue <!--- This project only accepts pull requests related to open GitHub issues or Jira Keys --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please DO NOT name partially fixed issues, instead open an issue specific to this fix --> <!--- Please link to the issue here: --> ## Related Jira Key [CXC-10](https://usdot-carma.atlassian.net/jira/software/c/projects/CXC/issues/CXC-10) <!-- e.g. CAR-123 --> ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Defect fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have added any new packages to the sonar-scanner.properties file - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] I have read the [**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) document. - [ ] I have added tests to cover my changes. - [ ] All new and existing tests passed. [CXC-10]: https://usdot-carma.atlassian.net/browse/CXC-10?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Cheng Yuan <cheng.yuan@leidos.com> Co-authored-by: Kyle Rush <kyle.rush@leidos.com> Co-authored-by: Cheng Yuan <84340069+chengyuan0124@users.noreply.github.com>
- Loading branch information
1 parent
9e6494c
commit caac2ff
Showing
34 changed files
with
1,177 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...arios/Town04_test/carla/carla_config.json → ...own04_carma_cloud/carla/carla_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"updateInterval": 100, | ||
"carlaUE4Path": "/opt/carla/", | ||
"bridgePath": "/opt/carma-simulation/scenarios/Town04_test/carla; bridge.sh", | ||
"bridgePath": "/opt/carma-simulation/scenarios/Town04_carma_cloud/carla; bridge.sh", | ||
"carlaConnectionPort": 8913, | ||
"carlaCDASimAdapterUrl":"http://127.0.0.1:8090/RPC2" | ||
} |
3 changes: 3 additions & 0 deletions
3
...e/src/assembly/resources/scenarios/Town04_carma_cloud/carma-cloud/carma-cloud_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"updateInterval": 100 | ||
} |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...assembly/resources/scenarios/Town04_carma_cloud/infrastructure/infrastructure_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"updateInterval": 100 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-parent</artifactId> | ||
<version>22.1-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>mosaic-carma-cloud</artifactId> | ||
<name>CARMA Cloud Ambassador</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-rti-api</artifactId> | ||
<version>${mosaic.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-objects</artifactId> | ||
<version>${mosaic.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-objects</artifactId> | ||
<version>${mosaic.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>gov.dot.fhwa.saxton</groupId> | ||
<artifactId>mosaic-carma-utils</artifactId> | ||
<version>${mosaic.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-interactions</artifactId> | ||
<version>${mosaic.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-utils</artifactId> | ||
<version>${mosaic.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-geomath</artifactId> | ||
<version>${mosaic.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.mosaic</groupId> | ||
<artifactId>mosaic-application</artifactId> | ||
<version>22.1-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.xml.bind</groupId> | ||
<artifactId>jakarta.xml.bind-api</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jaxb</groupId> | ||
<artifactId>jaxb-runtime</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>skip-carma-cloud-tests</id> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
93 changes: 93 additions & 0 deletions
93
...-cloud/src/main/java/org/eclipse/mosaic/fed/carmacloud/ambassador/CarmaCloudInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (C) 2023 LEIDOS. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.eclipse.mosaic.fed.carmacloud.ambassador; | ||
|
||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.net.HttpURLConnection; | ||
import com.google.gson.Gson; | ||
import gov.dot.fhwa.saxton.TimeSyncMessage; | ||
|
||
|
||
/** | ||
* CarmaCloudInstance class represents a physical instance of an | ||
* CARMA Cloud in the simulated environment. | ||
* It contains information about the instance such as its id and target address | ||
*/ | ||
public class CarmaCloudInstance | ||
{ | ||
// unique simulation identifier for the CARMA Cloud instance | ||
private final String carmaCloudId; | ||
// URL endpoint where to send simulation time sync messages | ||
private final String carmaCloudUrl; | ||
|
||
|
||
/** | ||
* Constructor for CarmaCloudInstance | ||
* | ||
* @param sId the ID of the CARMA Cloud instance. | ||
* @param sUrl the receive time synchronization message port of the infrastructure. | ||
*/ | ||
public CarmaCloudInstance(String sId, String sUrl) | ||
{ | ||
carmaCloudId = sId; | ||
carmaCloudUrl = sUrl; | ||
} | ||
|
||
|
||
/** | ||
* Returns the URL endpoint of the CARMA Cloud instance | ||
* | ||
* @return String URL endpoint of the CARMA Cloud instance | ||
*/ | ||
public String getCarmaCloudUrl() | ||
{ | ||
return carmaCloudUrl; | ||
} | ||
|
||
|
||
/** | ||
* Returns the ID of the CARMA Cloud instance | ||
* | ||
* @return String the ID of the CARMA Cloud instance | ||
*/ | ||
public String getCarmaCloudId() | ||
{ | ||
return carmaCloudId; | ||
} | ||
|
||
|
||
/** | ||
* Sends time sync data to the CARMA Cloud Instance | ||
* | ||
* @param oMsg the JSON time sync state to transmit | ||
* @throws IOException if there is an issue with the underlying URL connection | ||
*/ | ||
public void sendTimeSyncMsg(TimeSyncMessage oMsg) | ||
throws IOException | ||
{ | ||
HttpURLConnection oHttp = (HttpURLConnection)new URL(carmaCloudUrl).openConnection(); | ||
oHttp.setRequestMethod("POST"); | ||
oHttp.setDoOutput(true); | ||
try (DataOutputStream oOut = new DataOutputStream(oHttp.getOutputStream())) | ||
{ | ||
oOut.write(new Gson().toJson(oMsg).getBytes()); | ||
} | ||
if (oHttp.getResponseCode() != 200) | ||
throw new IOException(String.format("CARMA Cloud failure %d %s", oHttp.getResponseCode(), oHttp.getResponseMessage())); | ||
} | ||
} |
Oops, something went wrong.