diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..601c80a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +CARLA_*.tar.gz diff --git a/Dockerfile b/Dockerfile index f05c82d6..e6195008 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,126 +18,41 @@ MAINTAINER Leidos, Inc. LABEL Description="Dockerised Simulation of Carla_Sumo_Mosaic" ENV SUMO_HOME /usr/share/sumo -ENV SUMO_USER carla_sumo_mosaic - - -ENV CARLA_HOME /CARLA_0.9.10/ -RUN export CARLA_HOME - -RUN apt-get update && \ - apt-get install -y openjdk-8-jdk && \ - apt-get install -y ant && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/ && \ - rm -rf /var/cache/oracle-jdk8-installer; +ENV SUMO_USER carma + +ARG VERSION +ARG VCS_REF +ARG BUILD_DATE + +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.name="carma-simulation" +LABEL org.label-schema.description="XIL Simulation environment for evaluation and testing of the CARMA Platform" +LABEL org.label-schema.vendor="Leidos" +LABEL org.label-schema.version=${VERSION} +LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations/CARMA" +LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-stol/carma-simulation/" +LABEL org.label-schema.vcs-ref=${VCS_REF} +LABEL org.label-schema.build-date=${BUILD_DATE} ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ RUN export JAVA_HOME -RUN apt-get -y update - -RUN apt-get install x11-xserver-utils dconf-editor dbus-x11 -y - -RUN apt-get update && apt-get upgrade -y && apt-get clean - -# Python package management and basic dependencies -RUN apt-get install -y curl python3.7 python3.7-dev python3.7-distutils - -# Register the version in alternatives -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 - -# Set python 3 as the default python -RUN update-alternatives --set python /usr/bin/python3.7 - -RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \ - python get-pip.py --force-reinstall && \ - rm get-pip.py - -RUN pip3.7 install lxml - -# Dependencies for glvnd and X11. -RUN apt-get update \ - && apt-get install -y -qq --no-install-recommends \ - libglvnd0 \ - libgl1 \ - libglx0 \ - libegl1 \ - libxext6 \ - libx11-6 \ - && rm -rf /var/lib/apt/lists/* - # Env vars for the nvidia-container-runtime. ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute -RUN apt-get update && \ - apt-get install -y software-properties-common && \ - rm -rf /var/lib/apt/lists/* - -# Install python3.6 for NS-3 installation -RUN add-apt-repository ppa:deadsnakes/ppa && \ - apt update && \ - apt install python3.6 - -# Install other dependencies -RUN apt-get update && \ - apt-get install -y g++ gcc unzip tar python3-dev && \ - apt-get install -y autoconf automake libtool curl make && \ - apt-get install -y libxml2 libsqlite3-dev && \ - apt-get install -y libxml2-dev - -RUN \ - apt-get update && \ - apt-get install -y --allow-unauthenticated \ - build-essential \ - pkg-config \ - lbzip2 \ - libprotobuf-dev \ - libsqlite3-dev \ - protobuf-compiler \ - patch \ - rsync \ - wget - -# Install vim as text editor -RUN apt-get install -y vim - -RUN apt-get install -y nano - -RUN apt-get install -y xterm - -RUN apt install -y default-jdk - -# Install SUMO -RUN add-apt-repository ppa:sumo/stable - -RUN apt-get update - -RUN apt-get install -y \ - sumo \ - sumo-tools \ - sumo-doc - RUN adduser $SUMO_USER --disabled-password # Enable sudo RUN apt-get update && apt-get install -y sudo - +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN adduser $SUMO_USER sudo --disabled-password -COPY co-simulation/traci_update/connection.py ./usr/share/sumo/tools/traci/ -COPY co-simulation/traci_update/constants.py ./usr/share/sumo/tools/traci/ -COPY co-simulation/traci_update/main.py ./usr/share/sumo/tools/traci/ - -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> \ -/etc/sudoers - - -### Docker (Optional) ### -# RUN apt-get update && \ -# apt-get -qy full-upgrade && \ -# apt-get install -qy curl && \ -# apt-get install -qy curl && \ -# curl -sSL https://get.docker.com/ | sh +COPY --chown=carma:carma . /home/carma/src +USER carma +WORKDIR /home/carma/src +COPY --chown=carma:carma docker/env.sh /home/carma/.base-image/ +RUN docker/install.sh -# RUN adduser $SUMO_USER docker --disabled-password +ENTRYPOINT [ "/home/carma/src/docker/entrypoint.sh" ] +CMD [ "mosaic.sh", "-s", "HelloWorld" ] diff --git a/Instruction/Build Docker Image Instruction/README.md b/Instruction/Build Docker Image Instruction/README.md deleted file mode 100644 index b380489f..00000000 --- a/Instruction/Build Docker Image Instruction/README.md +++ /dev/null @@ -1,159 +0,0 @@ -# Running CARLA-SUMO-MOSAIC Co-Simulation Tool with NS-3 Integration in Docker - -This is the tutorial to run CARLA-SUMO-MOSAIC co-simulation tool in a docker container. It is recommended to run the co-simulation tool on a **high-performance** computer. - -## Test Platform - -- Operating System: Ubuntu 20.04.2 LTS -- CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60 GHz -- RAM: 16 GB -- Graphics: NVIDIA GeForce RTX 2070 Super 8 GB - -## Prerequisites - -- NVIDIA GPU with at least 8 GB -- NVIDIA drivers > 361.93 -- Free Disk Space > 30 GB -- NVIDIA Container Toolkit -- Docker - -If you do not have Docker installed, please refer to this [link](https://usdot-carma.atlassian.net/wiki/spaces/CRMPLT/pages/486178841/Setup+CARMA+Platform+Prerequisites#Install-docker-using-docker-install.sh-in-CARMA-Platform-repo) for installation. - -If you do not have NVIDIA Container Toolkit installed, please refer to this [link](https://usdot-carma.atlassian.net/wiki/spaces/CRMPLT/pages/486178841/Setup+CARMA+Platform+Prerequisites#CUDA-11.2-(Non-VM-installation)) for installation. - -## Build/Pull Docker Image of Co-Simulation Tool - -There are two ways to get co-simulation docker image. You can either choose to pull the co-simulation tool docker image from DockerHub or build the image by yourself. - -#### Option 1, Pull Docker Image - -To pull the co-simulation tool from DockerHub, make sure that you have been installed the docker tool into your system and have been login your personal account. - -##### Step 1: Simply type the command to pull the docker image: - -```sh -docker pull usdotfhwastol/carma-xil-cosimulation:[tag] -``` - -The tag information could be found from [usdotfhwastol Dockerhub](https://hub.docker.com/repository/docker/usdotfhwastol/carma-xil-cosimulation/tags?page=1&ordering=last_updated) - -##### Step 2: Run docker image with a container: - -```sh -cd /docker && ./run.sh -v [version] -``` - -Once you access the conainer, skip the option 2 and go to the `Run carma-xil-cosimulation` step to test the co-simulation - -#### Option 2, Build Docker Image -##### Prerequisites - -To build the co-simulation tool docker image, the executable `carla_sumo_mosaic` file should be created firstly. The executable zip file located at the co-simulation folder as the name `carla-sumo-mosaic-[version].zip`. Extract the all contents into an empty folder with the name `carla_sumo_mosaic` then remember the directory of the folder for the later usage - -##### Step 1: Build image from Dockerfile by using following command: - -```sh -cd /docker && ./build-image.sh -v [version] -``` - -##### Step 2: Run docker image with a docker container - -```sh -cd /docker && ./run.sh -v [version] -``` - -##### Step 3: Copy CARLA and Co-Simulation tool - -Copy `CARLA_0.9.10`, executable `carla_sumo_mosaic` and `bridge` into the container. - -``` -docker cp /CARLA_0.9.10 :./ -docker cp /carla_sumo_mosaic :./ -docker cp /co-simulation/bridge :./ -``` - -##### Step 4: Unzip scenarios from sample_scenario.zip at co-simulation folder and copy to docker - -``` -docker cp /Town04_20 :./carla_sumo_mosaic/scenarios -``` - -### Modify files in Docker Container - -#### Step 1: Modify `ns3_installer.sh` - -In Docker container, type: - -```sh -cd carla_sumo_mosaic/bin/fed/ns3 -``` - -Then modify `ns3_installer.sh` by: - -``` -vim ns3_installer.sh -``` - -(If you see a message `vim: command not found`, please use `sudo apt-get install vim` to install vim as text editor) - -In the `build_ns3()` function, after `CXXFLAGS="-Wno-error" python3.6 ./build.py --disable-netanim`, add the following command - -``` -sudo cp -ar ns-3.28/build/ns3 /usr/include/ -``` - -#### Step 2: Build NS-3 - -In directory `carla_sumo_mosaic/bin/fed/ns3`, type: - -``` -./ns3_installer.sh -``` - -Once all 1947 files are compiled and a successful message shows up, it means NS-3 is successful installed. - -#### Step 3: Add NS-3 as environment variable - -``` -export NS3_HOME='/carla_sumo_mosaic/bin/fed/ns3' -``` - -Use `printenv` to check if NS-3 is successful added to environment variable. - -#### Step 4: Modify `run.sh` - -In directory `carla_sumo_mosaic/bin/fed/ns3`, type: - -``` -vim run.sh -``` - -Change line 11 to: - -``` -LD_LIBRARY_PATH=/carla_sumo_mosaic/bin/fed/ns3/ns-allinone-3.28/ns-3.28/build /carla_sumo_mosaic/bin/fed/ns3/ns-allinone-3.28/ns-3.28/build/scratch/mosaic_starter --port=$port --cmdPort=$cmdport --configFile=scratch/ns3_federate_config.xml -``` - -## Run Co-Simulation Tool - -Once everything is ready, under directory `/carla_sumo_mosaic`, simply type: - -``` -./mosaic.sh -s Town04_20 -``` - -The command will start CARLA, SUMO and x-terminal showing the CALRA-MOSAIC loading status - -![carla_sumo_mosaic_ready](../../co-simulation/doc/gif/ready.gif) - -When the x-terminal showing the CARLA-MOSAIC status is connected, simply click the SUMO play button to start the program - -![carla_sumo_mosaic](../../co-simulation/doc/gif/carla_sumo_mosaic_demo.gif) - -***Note: Current CARMA XIL Version has a known issue with a port conflict between NS-3 and CARMA-CARLA integration see [#39](https://github.com/usdot-fhwa-stol/carma-simulation/issues/39). The recommended workaround is to run exclusively one or the other module.*** - -### Commit the container back to image -After the run if there is no issue, commit docker container to docker image -``` -docker container commit usdotfhwastol/carma-xil-cosimulation:[tag] -``` diff --git a/Instruction/Build MOSAIC Instruction/README.md b/Instruction/Build MOSAIC Instruction/README.md deleted file mode 100644 index d7d448e3..00000000 --- a/Instruction/Build MOSAIC Instruction/README.md +++ /dev/null @@ -1,623 +0,0 @@ - - -# Carla-Sumo-Mosaic Co-Simulation Tool - -This user guide intends to provide users instructions on how to install the prerequisite software, configure the system environment variable, and run a Co-simulation tool developed for supporting the cooperative driving automation research on **Linux systems Ubuntu 16.04** and **Windows 10 systems**. This co-simulation tool is developed based on the open-source concept. Specifically, it is based on [Eclipse MOSAIC framework](https://www.eclipse.org/mosaic/) and consists of an open-source traffic simulator, namely [SUMO](https://www.eclipse.org/sumo/), an autonomous driving simulator, namely [CARLA](http://carla.org/), an open-source network simulator, namely [ns-3](https://www.nsnam.org/). The co-simulation tool can simulate V2X communication among vehicles and infrastructure using the ns-3 network simulator. - -## **Prerequisites** - -For a successful running of the co-simulation tool, the following software must be installed or updated: - -- CARLA simulator 0.9.10 -- JAVA 8 or 11 - Recommend using the [Adopt OpenJDK](https://adoptium.net/?variant=openjdk8). The environment variable **JAVA_HOME** needs be configured to the location of JDK. -- Python 3.7 - If the users use different version of Python other than 3.7, the users need to copy the CARLA library .egg file to the folder bridge/ PythonAPI /carla/dist. In addition, the package `lxml==4.5.0` needs to be installed. -- SUMO 1.8.0 - The environment variable **`SUMO_HOME`** **must be configured to define the installation directory of SUMO**. -- ns-3 simulator -- TraCI library has to be updated. - -Moreover, a high performance computer is needed to run the co-simulation tool. The configuration of a recommended system is in the following. - -- **CPU**: Intel i7 gen 9th - 11th / Intel i9 gen 9th - 11th / AMD ryzen 7 / AMD ryzen 9 -- **RAM memory:** minimum 16GB -- **Graphics card:** NVIDIA RTX 2070 / RTX 2080 / RTX 3070 / RTX 3080 - -## Installation of Prerequisites - -### 1. Installation of ns-3 3.28 - -#### a. Linux system - -##### Installation of dependencies for ns-3 - -- Install gcc, g++, python 3.6 and other dependencies - -``` -sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test -sudo apt-get update && sudo apt-get install gcc-7 g++-7 -sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20 --slave /usr/bin/g++ g++ /usr/bin/g++-7 -sudo add-apt-repository ppa:deadsnakes/ppa -sudo apt update && sudo apt install python3.6 -sudo apt-get update && sudo apt-get install unzip tar python3.6-dev pkg-config sqlite3 autoconf automake libtool curl make libxml2 libsqlite3-dev libxml2-dev -``` - -- Install protobuff - -``` -curl -OL "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.3.0.tar.gz" -tar xvf v3.3.0.tar.gz -cd protobuf-3.3.0 -./autogen.sh - ./configure --prefix=/usr -make -make check -sudo make install -``` - -##### Installation of ns-3 federate - -First go to the root folder of co-simulation tool and then go to **/bin/fed/ns3**, find **ns3_installer.sh** file. - -- Run the following command to make ns3_installer.sh executable. - -``` -chmod a+x ns3_installer.sh -``` - -- Open ns3_installer.sh, add the following command before **log "Build ns3-federate"** in function **build_ns3()**. - -``` -sudo cp -ar ns-3.28/build/ns3 /usr/include/ -``` - -- Run the following command to install ns-3 federate. - -``` -./ns3_installer.sh -``` - -- After installation, open run.sh in **/bin/fed/ns3** and change the relative path to the absolute path in LD_LIBRARY_PATH. - -- Set environment variable **NS3_HOME** to the root folder of run.sh. - - ``` - export NS3_HOME=path_to_run.sh - ``` - -#### b. Windows system - -Since ns-3 is primarily developed on and for GNU/Linux platforms, users can execute ns-3 within a docker container. - -- Install Docker ≥ 1.13 on windows systems by following the [link](https://docs.docker.com/desktop/windows/install/) - -- Switch to the location of the ns-3 Dockerfile in **/bin/fed/ns3** and run the following command on command line. A docker image named ns3-federate will be generated. - - ``` - docker build -t ns3-federate . - ``` - -- Open etc/runtime.json, enter the name of the ns-3 docker in the ns3-section into the property dockerImage: - - ``` - "federates": [ - ... - { - "id": "ns3", - "dockerImage": "ns3-federate", - ... - }, - ... - ] - ``` - -### 2. Installation of Adopt OpenJDK - -#### a. Linux system - -- Install JAVA 11 using the following commands - - ``` - wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add - - sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ - sudo apt update && sudo apt install adoptopenjdk-11-hotspot - ``` - -- Set **JAVA_HOME** to the root folder of Java JDK - - ``` - export JAVA_HOME=path_to_java JDK - ``` - -#### b. Windows system - -- Download prebuilt OpenJDK from this [link](https://adoptium.net/?variant=openjdk11). -- Open the package to install it. Follow the instructions and select **Set JAVA_HOME variable**. - -### 3. Installation of SUMO-1.8.0 - -#### a. Linux system - -- Install the required tools and libraries - - ``` - sudo apt-get install cmake libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev libgl2ps-dev - ``` - -- Install SUMO-1.8.0 - - ``` - curl -OL https://github.com/eclipse/sumo/archive/refs/tags/v1_8_0.tar.gz" - tar xvf v1_8_0.tar.gz - cd sumo-1_8_0 - mkdir build/cmake-build && cd build/cmake-build - cmake ../.. - make -j$(nproc) - sudo make install - ``` - -- Set environment variable SUMO_HOME and add installation path to the PATH - - ``` - export SUMO_HOME=/usr/local/share/sumo - export PATH=/usr/local/share/sumo/bin:$PATH - export PATH=/usr/local/share/sumo/tools:$PATH - ``` - -#### b. Windows system - -- Download the binaries from this [link](https://sourceforge.net/projects/sumo/files/sumo/version 1.8.0/) - -- Open the installer and follow the instruction to install it. Select **set SUMO_HOME.** - -- And add the SUMO bin folder and tool folder to the Path environment variable. - - ``` - C:\Program Files (x86)\Eclipse\Sumo\bin\ - C:\Program Files (x86)\Eclipse\Sumo\tools\ - ``` - -### 4. Update TraCI library - -#### a. Linux system - -Go to **bin/fed/ns3 folder, copy constants.py, connection.py, and main.py** to traci folder of SUMO using following commands. - -``` -sudo \cp constants.py /usr/local/share/sumo/tools/traci -sudo \cp connection.py /usr/local/share/sumo/tools/traci -sudo \cp main.py /usr/local/share/sumo/tools/traci -``` - -#### b. Windows system - -Go to **bin/fed/ns3** folder of executable co-simulation tool, copy **constants.py, connection.py, and main.py** to traci folder of SUMO (**C:\Program Files (x86)\Eclipse\Sumo\tools\traci**). - -### 5. Installation of CARLA 0.9.10 - -#### a. Linux system - - *Since there is no CARLA executable binary on Ubuntu 16.04.* please refer to CARLA documentation to build the executable binary of CARLA 0.9.10. - -#### b. Windows system - -- Download the binaries from this [link](https://github.com/carla-simulator/carla/releases/tag/0.9.10). -- Extract compressed files and a folder named carla-0.9.10 will be generated. - -### 6. Installation of python 3.7 and lxml - -#### a. Linux system - -- Install python 3.7 - - ``` - sudo add-apt-repository ppa:deadsnakes/ppa - sudo apt update && sudo apt install python3.7 - ``` - -- Install lxml - - ``` - sudo apt install python3-pip - python3.7 -m pip install pip - pip3.7 install lxml==4.5.0 - ``` - -#### b. Windows system - -- Download the executable installer from [link](https://www.python.org/downloads/release/python-379/). -- Open the installer and follow the instruction to install it. Select Add Python 3.7 to PATH and customize installation. - -- Install lxml==4.5.0 by using the following command in Windows terminal. - - ``` - pip install lxml==4.5.0 - ``` - -## Installation of Co-simulation Tool - -### **1.** **Executable Bundle File** - -Download the co-simulation tool bundle file and extract it to an arbitrary path. - -### **2.** **Installation from Source Code** - -For a successfully build the co-simulation tool, Apache Maven needs to be installed. If Maven 3.1.x or higher has not been installed, please use the following steps to install it. - -#### a. Installation of Maven - -**Linux system** - -- Download the binary distribution archive **apache-maven-3.8.3** from this [link](https://maven.apache.org/download.cgi). - -- Installation extract distribution archive in any directory - - ``` - tar xzvf apache-maven-3.8.3-bin.tar.gz - ``` - -- Add the **bin** directory of the created directory **apache-maven-3.8.3** to the **PATH** environment variable. - - ``` - export PATH=path_to_apache_maven-3.8.3/apache-maven-3.8.3/bin:$PATH - ``` - - -- Verify the installation by running **mvn -v** in a new terminal. - -**Windows system** - -- Download the binary distribution archive **apache-maven-3.8.3** from this [link](https://dlcdn.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip). -- Extract compressed files and a folder named apache-maven-3.8.3 will be generated. -- Add the bin directory of the created directory apache-maven-3.8.3 to the PATH environment variable. -- Verify the installation by running **mvn -v** in a new terminal. - -#### b. Build Co-simulation Tool - -- Download zip file of Co-simulation tool or clone the code from this [link](https://github.com/usdot-fhwa-stol/carma-simulation/tree/feature/mosaic-carla-sumo-ambassadors). - - - ``` - git clone https://github.com/usdot-fhwa-stol/carma-simulation.git - ``` - -- If you use git clone the code, you need to use the following command to go to the co-simulation tool branch. - - ``` - git checkout feature/mosaic-carla-sumo-ambassadors - ``` - -- Go to co-simulation folder and build co-simulation tool using the following command - - ``` - cd 'co-simulation tool' - mvn clean install - ``` - -- The above mvn command executes all tests as well. In order to skip test execution, run the following command: - - ``` - mvn clean install -DskipTests - ``` - - - -- After building, go to bundle\target directory, a zip file of co-simulation bundle "**carla-sumo-mosaic-21.2.zip**" can be found. - -- Extract the bundle to an arbitrary path. The installation folder is referenced as ``. - -## **Folder Content** - -The folder structure of `` is described in the following. - - -``` -└─ - ├─ bridge ................ Directory with bridge file for connecting CARLA ambassador and CARLA simulator. - | ├─ bridge.bat ......... An example of bridge script for a scenario on Windows systems. - | ├─ bridge.sh .......... An example of bridge Script for a scenario on Linux systems. - ├─ etc - | ├─ hosts.json ......... Configuration of the execution host, e.g., temporary directory. - | ├─ logback.xml ........ Configuration of log files and levels. - | └─ runtime.json ....... Configuration of all Ambassadors and Federates coupled with the MOSAIC. - ├─ lib ................... Directory with all Java compiled libraries required for MOSAIC. - ├─ scenarios ............. Directory containing all simulation scenarios. - ├─ tools ................. Additional tools, like the HTML Visualizer. - ├─ CONTRIBUTING.md - ├─ LICENSE - ├─ mosaic.bat ............ Start script for Windows systems. - └─ mosaic.sh ............. Start script for GNU/Linux systems. - -``` - -## **Co-Simulation Scenario** - -To run the co-simulation tool, you need to prepare a co-simulation scenario. The following file structure shows the setup of a typical co-simulation scenario. - - -``` -└─ - ├─ application - └─ .db................ Scenario database file - └─xx.jar............................ Application jar file - ├─ carla - | └─ carla_config.json ................. CARLA configuration file - | └─ bridge.sh/bridge.bat .............. Bridge file - ├─ carma - | └─ carma_config.json ................. CARMA configuration file - ├─ infrastructure - | └─ infrastructure_config.json .......... Infrastructure configuration file - ├─ mapping - | └─ mapping_config.json ............... Mapping configuration file - ├─ ns3 - | └─ ns3_config.json ...................... ns-3 configuration file - | └─ ns3_federate_config.xml .............. ns-3 federate configuration file - ├─ sumo - | └─ .net.xml ............ SUMO network file - | └─ .rou.xml ............ SUMO route file - | └─ .sumocfg ............ SUMO configuration file - └─ scenario_config.json ................ Basic configuration of the simulation scenario - -``` - - -Here the scenario configuration file, the CARLA configuration file, CARMA configuration file, Infrastructure configuration file, and bridge file are introduced in detail below. For other configuration files and scenario creation, refer to the documentation of Eclipse MOSAIC [[link](https://www.eclipse.org/mosaic/docs/)]. Moreover, the CARLA 3D maps corresponding to the scenarios must be generated for co-simulation scenarios. - -### **1.** **Scenario configuration file** - -The **scenario_config.json** is the main configuration file of a co-simulation scenario. A co-simulation scenario file looks like the following example. - - - -```json -{ - "simulation": { - "id": "co-simulation", - "duration": "400s", - "randomSeed": 212323853, - "projection": { - "centerCoordinates": { - "latitude": 52.63, - "longitude": 13.56 - }, - "cartesianOffset": { - "x": -395635.35, - "y": -5826456.24 - } - }, - "network": { - "netMask": "255.255.0.0", - "vehicleNet": "10.1.0.0", - "rsuNet": "10.2.0.0", - "tlNet": "10.3.0.0", - "csNet": "10.4.0.0", - "serverNet": "10.5.0.0", - "tmcNet": "10.6.0.0", - "carmaVehicleNet": "10.7.0.0", - "carlaVehicleNet": "10.8.0.0" - } - }, - "federates": { - "application": true, - "cell": false, - "environment": false, - "sns": false, - "ns3": true, - "omnetpp": false, - "output": false, - "carla": true, - "carma": true, - "sumo": true, - "infrastructure": true - } -} -``` - -The federate tags show which simulators are used in the simulation. For the co-simulation scenarios, CARLA and SUMO federate must be enabled. If the CARLA federate is disabled, the simulation of SUMO and MOSAIC will be run. - -### **2.** **Carla configuration file** - -The CARLA ambassador can be configured with the carla configuration file. The specific path is **/carla/carla_config.json**. The example configuration files of CARLA ambassador on Linux systems and on Windows systems are shown in the following, respectively. - -**Linux** - -```json -{ - "updateInterval": 100, - "carlaUE4Path": "/CARLA_0.9.10/", - "bridgePath": "./scenarios/co-simulation/carla; bridge.sh", - "carlaConnectionPort": 8913 -} -``` - -**Windows** - -```json -{ - "updateInterval": 100, - "carlaUE4Path": "D:/CARLA_0.9.10/", - "bridgePath": "./scenarios/co-simulation/carla; bridge.bat", - "carlaConnectionPort": 8913 -} -``` - -The following table descripts the parameters in the CARLA configuration file. - -| Parameters | **Type** | **Description** | **Required** | -| ------------------- | -------- | ------------------------------------------------------------ | ------------ | -| updateInterval | number | The Interval after which the CARLA is updated. The default unit is ms. Define the size of one simulation step in CARLA. The updateInterval of Carla and Sumo ambassador must be the same. **Note**: the minimal value of updateInterval is 100ms and the default setting of updateInterval being predefined in the java code is 1000ms for both carla and sumo configuration. | Yes | -| carlaUE4Path | string | Path to CarlaUE4 executable file (Windows systems: CarlaUE4.exe; Linux systems: CarlaUE4.sh). If the environment variable **`CARLA_HOME`** is configured to define the installation directory of CarlaUE4 executable file, this parameter can be removed from the configuration file. | No | -| bridgePath | string | This parameter includes two information separated by the semicolon. The first substring is the path of bridge .sh or .bat. The second substring is the file name of bridge .sh or .bat. The extension of the bridge file is needed. | Yes | -| carlaConnectionPort | number | The bridge server port . It must be the same as the bridge server port number in the bridge .sh or .bat file. If the entry is not used, the default port number is 8913. | No | - -### **3.** **Bridge file** - -The bridge file (bridge.sh or bridge.bat) is used to run the bridge to connect CARLA simulator and CARLA ambassador, load maps to CARLA simulator, pass messages between CARLA ambassador and CARLA simulator. The examples of bridge files on Linux systems and on Windows systems are shown in the following, respectively. - -**Linux system** - -```bash -#!/bin/bash - -cd ../../../bridge - -x-terminal-emulator python3.7 carla_mosaic_bridge.py --bridge-server-port 8913 --map Town04 ../scenarios/Town04/sumo/Town04.net.xml --step-length 0.1 -``` - - **Windows system** - -```powershell -@ECHO OFF -cd ../../../bridge -python carla_mosaic_bridge.py --bridge-server-port 8913 --map Town04 ../scenarios/Town04/sumo/Town04.net.xml --step-length 0.1 -``` - -The arguments in the above python commands are shown in the following. - -**`--bridge-server-port 8913`:** The port number that the bridge server is listening to. It must be the same as the carlaConnectionPort in the carla configuration file. If not specified, the default port number 8913 will be used for the bridge server. - -**`--map Tow04`**: the map loaded in the CARLA simulator. If not specified, the default map of CARLA simulator will be used. - -**`../scenarios/Town04/sumo/Town04.net.xml`**: the net file of the CARLA map or SUMO, the net file is located in the net folder under the bridge folder. Since SUMO and CARLA simulator use different reference systems, the SUMO net offset calculated from the net file is used to calculate the transform of SUMO actors in CARLA simulator and the transform of CARLA actors in SUMO. If not specified, the net file will be generated using the CARLA map. - -**--step-length**: the simulation step length, which should be the same as the updateInterval of CARLA. - -### 4. CARMA Configuration File - -The CARMA ambassador can be configured with the CARMA configuration file. The specific path is **/carma/carma_config.json**. An example configuration files of CARMA ambassador is shown in the following. - -``` -{ - "updateInterval": 100, - "carmaVehicles":[ -{ - "routeID": "0", - "lane": 1, - "position": 0, - "departSpeed": 0, - "vehicleType": "vehicle.chevrolet.impala", - "applications":["org.eclipse.mosaic.app.tutorial.VehicleCommunicationApp"], - "geoPosition": { - "latitude": 52.579272059028646, - "longitude": 13.467165499469328 - }, - "projectedPosition": - { - "x": 501.62, - "y": 116.95 - }, - - "heading": 24.204351784500364, - "slope": 0.0 -}], -"senderCarmaVehicleId":"carma_0" -} -``` - -The following table describes the parameters in the CARMA configuration file. - -| **Parameters** | **Type** | **Description** | -| -------------------- | ------------- | ------------------------------------------------------------ | -| updateInterval | number | The Interval after which the CARMA is updated. The default unit is ms. | -| carmaVehicles | list | A list of CARMA vehicles controlled by CARMA platforms. | -| senderCarmaVehicleID | string | The id of virtual CARMA vehicle which transmit the received messages from its corresponding real CARMA vehicle. | -| routeID | number | The route ID on which the vehicle will be spawned. | -| lane | number | The lane on which the vehicle will be spawned. | -| position | number | Position within the route where the vehicle should be spawned. | -| departSpeed | number | The speed at which the vehicle is supposed to depart. | -| vehicleType | string | The vehicle type | -| application | list | the applications to be used for this vehicle. | -| geoPosition | geopoint | The geo position at which the vehicle is currently located. | -| projectedPosition | CatesianPoint | The projected position at which currently the vehicle is located. | -| heading | number | Direction/Heading of the vehicle in degrees from north clockwise. | -| slope | number | The slope of vehicle in degrees | - -### 5. Infrastructure Configuration File - -The Infrastructure ambassador can be configured with the Infrastructure configuration file. The specific path is **/infrastructure/infrastructure_config.json**. An example configuration files of Infrastructure ambassador is shown in the following. - -``` -{ - "updateInterval": 1000, - "senderRSUId": "rsu_0" -} -``` - -The following table describes the parameters in the Infrastructure configuration file. - -| **Parameters** | **Type** | **Description** | -| -------------- | -------- | ------------------------------------------------------------ | -| updateInterval | number | The Interval after which the infrastructure is updated. The default unit is ms. | -| senderRSUId | string | The id of virtual RSU which transmits received messages from corresponding real RSU. | - -### 6. Mapping Configuration File - -The Mapping ambassador can be configured with the mapping configuration file. The specific path is **/mapping/mapping_config.json**. Please refer to this [link](https://www.eclipse.org/mosaic/docs/simulators/application_mapping/) for more information about the configuration file. - -### 7. NS-3 Configuration File - -The ns-3 ambassador and ns-3 federate can be configured with the configuration files. The specific path is **/ns3/**. Please refer to this [link](https://www.eclipse.org/mosaic/docs/simulators/network_simulator_ns3/#configuration) for more information about the configuration file. - -## **Run a Co-simulation Scenario** - -To run a co-simulation scenario via Command Line Interface, call the start script with the following command line arguments. For more CLI options, please refer to Eclipse MOSAIC documentation. After CARLA loads map and SUMO GUI pops out, click the play button in SUMO GUI to start running co-simulation. - -**GNU/Linux** - -``` -./mosaic.sh -s -./mosaic.sh -c ./scenarios//scenario_config.json -``` - -**Windows** - -``` -mosaic.bat -s -mosaic.bat -c .\scenarios\\scenario_config.json -``` - -**Example** - -The following call starts the co-simulation scenario “Co-simulation” on a Linux Machine. - -``` -./mosaic.sh -s Co-simulation -v -w 0 -``` - -The following call starts the co-simulation scenario “Tow04” on a Windows Machine. - -``` -mosaic.bat -s Co-simulation -v -w 0 -``` - - ![co-simulation demo](https://github.com/usdot-fhwa-stol/carma-simulation/blob/feature/mosaic-carla-sumo-ambassadors/co-simulation%20tool/co-simulation%20demo.gif) - -## **Check the Log Files** - -Log files are generated for the used ambassadors for each simulation run. They are stored in the folder `/logs/log--scenarioname`. Each simulation run has a new log file folder generated. The folder structure of log file folder looks like the following. The log file Carla.log is about CARLA ambassador. - -``` -└─ log--secarioname - Apps . . . . . . . . . . . . . . . . the folder for logs of applications - ├─ Application.log .......... Information about the application ambassador - ├─ Carla.log ...................... CARLA ambassador log - ├─ Carma.log ...................... CARMA ambassador log - ├─ Cell.log ....................... Cellular network log - ├─ Communication.log ......... (Ad hoc) network simulation ambassador log - ├─ CommunicationDetails.log ........ (Ad hoc) network simulation detail log - ├─ Environment.log ................ Logs of the environmental eventserver - ├─ Infrastructure.log ................ Infrastructure ambassador log - ├─ Mapping.log .................... Mapping configuration logs - ├─ MOSAIC.log ...... General information, e.g. startup sequence information - ├─ Navigation.log ......... Detailed logs about navigation component in the application ambassador - ├─ output.csv ....... Recorded data of the integrated File Output Generator - ├─ RunTimeEvents.csv .............. Logs of run time events - ├─ Traffic.log .................... Traffic simulation log (SUMO) - -``` - -## Troubleshooting - -If the maps of CARLA for the scenarios is the same as the default map of CARLA simulator, the argument about map in the bridge file is recommended to be removed. Loading a map in CARLA simulator takes time and sometimes may break the connection of CARLA client. The users need restart the co-simulation to solve the connection issue. - -Sometimes, the CARLA client may not be connected to CARLA simulator. Check whether there is a CARLA process running in the background or not. If so, terminate the CARLA process. - -During the simulation, change the view of spectator may cause the CARLA simulator freeze. Users should adjust the view of spectator before starting the co-simulation. diff --git a/Instruction/README.md b/Instruction/README.md new file mode 100644 index 00000000..ef15af0d --- /dev/null +++ b/Instruction/README.md @@ -0,0 +1,202 @@ +# Running CARMA-simulation version 1.0.1 + +## Prerequisites + +- NVIDIA GPU with at least 8 GB +- NVIDIA drivers > 361.93 +- Free Disk Space > 30 GB +- NVIDIA Container Toolkit +- Docker +- CARLA Simulator 0.9.10 + +If you do not have Docker installed, please refer to this [link](https://usdot-carma.atlassian.net/wiki/spaces/CRMPLT/pages/486178841/Setup+CARMA+Platform+Prerequisites#Install-docker-using-docker-install.sh-in-CARMA-Platform-repo) for installation. + +If you do not have NVIDIA Container Toolkit installed, please refer to this [link](https://usdot-carma.atlassian.net/wiki/spaces/CRMPLT/pages/486178841/Setup+CARMA+Platform+Prerequisites#CUDA-11.2-(Non-VM-installation)) for installation. + +## Build/Pull Docker Image of Co-Simulation Tool + +There are two ways to get co-simulation docker image. You can either choose to pull the co-simulation tool docker image from DockerHub or build the image by yourself. + +#### Option 1, Pull Docker Image +##### Prerequisites + +To pull the co-simulation tool from DockerHub, make sure that you have been installed the docker tool into your system and have been login your personal account. + +##### Simply type the command to pull the docker image: + +```sh +docker pull usdotfhwastol/carma-simulation:[docker-image-tag] +``` + +The docker tag information could be found from [usdotfhwastol Dockerhub](https://hub.docker.com/repository/docker/usdotfhwastol/carma-simulation/tags?page=1&ordering=last_updated). + + + +#### Option 2, Build Docker Image +##### Prerequisites + +Downalod [CARLA_0.9.10.tar.gz](https://carla-releases.s3.eu-west-3.amazonaws.com/Linux/CARLA_0.9.10.tar.gz) file then put the file under carma-simulation root folder + +##### Build image from Dockerfile by using following command: + +```sh +cd /docker && ./build-image.sh +``` + +## Run Docker Image + +Once the build image process has been done, the terminal will show the docker image tag as picture below. + +![tag_from_built](../co-simulation/doc/img/tag_from_build.png) + +You also can check the docker image tag by the command **`docker images`**. The information will show as the picture below. + +![tag_from_list](../co-simulation/doc/img/tag_from_list.png) + +If you pull the docker image directly from DockerHub, simply copy the tag from [Tag page](https://hub.docker.com/repository/docker/usdotfhwastol/carma-simulation/tags?page=1&ordering=last_updated) + +Copy tag string to do the following action for running Co-Simulation + +#### Hello World MOSAIC Scenario for Testing +```sh +cd /docker && ./run.sh -v [docker-image-tag] +``` + +#### Run Scenario Existed on Docker +```sh +cd /docker && ./run.sh -v [docker-image-tag] -s --from_docker Town04_20 +``` + +The sample Town04_20 scenario with CARLA and SUMO simulation will show up: +![carla_sumo_mosaic](../co-simulation/doc/gif/carla_sumo_mosaic_demo.gif) + +#### Run Sceanrio from Local +```sh +cd /docker && ./run.sh -v [docker-image-tag] -s --from_local [path-to-your-customize-sceanrio-folder] +``` + +## **Scenario Folder Content** + +``` +└─ + ├─ application + | └─ .db ................. Scenario database file + ├─ carla + | └─ carla_config.json ................. CARLA configuration file + | └─ bridge.sh ......................... Bridge file + ├─ mapping + | └─ mapping_config.json ............... Mapping configuration file + ├─ sumo + | └─ .net.xml ............ SUMO network file + | └─ .rou.xml ............ SUMO route file + | └─ .sumocfg ............ SUMO configuration file for SUMO + | └─ sumo_config.json .................. SUMO configuration file for MOSAIC + └─ scenario_config.json ................ Basic configuration of the simulation scenario + +``` + +Here the scenario configuration file, the CARLA configuration file, and bridge file are introduced in detail below and take the **`Town04_20`** from **`sample_sceario.zip`** as an example. For other configuration files and scenario creation, refer to the documentation of Eclipse MOSAIC [[link](https://www.eclipse.org/mosaic/docs/scenarios/)]. Moreover, the CARLA 3D maps corresponding to the scenarios must be generated for co-simulation scenarios. + +### **1.** **Scenario configuration file** + +The **scenario_config.json** is the main configuration file of a co-simulation scenario. A co-simulation scenario file looks like the following example. + + + +```json +{ + "simulation": { + "id": "Town04", + "duration": "600s", + "randomSeed": 212323853, + "projection": { + "centerCoordinates": { + "latitude": 52.63, + "longitude": 13.56 + }, + "cartesianOffset": { + "x": 503.02, + "y": 423.76 + } + }, + "network": { + "netMask": "255.255.0.0", + "vehicleNet": "10.1.0.0", + "rsuNet": "10.2.0.0", + "tlNet": "10.3.0.0", + "csNet": "10.4.0.0", + "serverNet": "10.5.0.0", + "tmcNet": "10.6.0.0" + } + }, + "federates": { + "application": true, + "cell": false, + "environment": false, + "sns": false, + "ns3": false, + "omnetpp": false, + "output": false, + "sumo": true, + "carla": true + } +} + +``` + +The federate tags show which simulators are used in the simulation. For the co-simulation scenarios, CARLA and SUMO federate must be enabled. If the CARLA federate is disabled, the simulation of SUMO and MOSAIC will be run. + +### **2.** **Carla configuration file** + +The CARLA ambassador can be configured with the carla configuration file. The specific path is **/carla/carla_config.json**. The example configuration files of CARLA ambassador on Linux systems and on Windows systems are shown in the following, respectively. + +```json +{ + "updateInterval": 100, + "carlaUE4Path": "/opt/carla/", + "bridgePath": "./scenarios/Town04_20/carla; bridge.sh", + "carlaConnectionPort": 8913 +} +``` + +The following table descripts the parameters in the CARLA configuration file. + +| Parameters | **Type** | **Description** | **Required** | +| ------------------- | -------- | ------------------------------------------------------------ | ------------ | +| updateInterval | int | The Interval after which the CARLA is updated. The default unit is ms. Define the size of one simulation step in CARLA. The updateInterval of Carla and Sumo ambassador must be the same. **Note**: the minimal value of updateInterval is 100ms and the default setting of updateInterval being predefined in the java code is 1000ms for both carla and sumo configuration. | Yes | +| carlaUE4Path | string | Path to CarlaUE4 executable file. | Yes | +| bridgePath | string | This parameter includes two information separated by the semicolon. The first substring is the path of bridge .sh or .bat. The second substring is the file name of bridge .sh. The extension of the bridge file is needed. | Yes | +| carlaConnectionPort | int | The bridge server port . It must be the same as the bridge server port number in the bridge .sh file. If the entry is not used, the default port number is 8913. | No | + +### **3.** **Bridge file** + +The bridge file bridge.sh is used to run the bridge to connect CARLA simulator and CARLA ambassador, load maps to CARLA simulator, pass messages between CARLA ambassador and CARLA simulator. The examples of bridge files on Linux systems is shown in the following, respectively. + +```.sh +#!/bin/bash + +#x-terminal-emulator +cd ../../../bridge + +x-terminal-emulator -e python3.7 carla_mosaic_bridge.py --bridge-server-port 8913 -m Town04 ../scenarios/Town04_20/sumo/Town04.net.xml --step-length 0.1 --tls-manager sumo +``` + +The arguments in the above python commands are shown in the following. + +**`--bridge-server-port 8913`:** The port number that the bridge server is listening to. It must be the same as the carlaConnectionPort in the carla configuration file. If not specified, the default port number 8913 will be used for the bridge server. + +**`--m Tow04`**: the map loaded in the CARLA simulator. If not specified, the default map of CARLA simulator will be used. + +**`../scenarios/Town04_20/sumo/Town04.net.xml`**: the net file of the CARLA map or SUMO, the net file is located in the. + +**`--step-length`**: the simulation step length, which should be the same as the updateInterval of CARLA. + +**`--tls-manager`**: the traffic light manager. Since co-simulation currently supports CARLA and SUMO simulation, parsing parameter to indicate which simulations to control traffic light to avoid the conflict + +### 4. Mapping Configuration File + +The Mapping ambassador can be configured with the mapping configuration file. The specific path is **/mapping/mapping_config.json**. Please refer to this [link](https://www.eclipse.org/mosaic/docs/simulators/application_mapping/) for more information about the configuration file. + +## **Check the Log Files** + +Log files are generated for the used ambassadors for each simulation run. They are stored in the folder `/logs/log--scenarioname`. Each simulation run has a new log file folder generated. The folder structure of log file folder looks like the following. The log file Carla.log is about CARLA ambassador. diff --git a/co-simulation/.gitignore b/co-simulation/.gitignore index dc36af0b..82cfe275 100644 --- a/co-simulation/.gitignore +++ b/co-simulation/.gitignore @@ -1,5 +1,4 @@ # Eclipse -bin/ .metadata .project .classpath @@ -65,4 +64,4 @@ logs/ tmp/ *.log credentials.cached -*.lcs \ No newline at end of file +*.lcs diff --git a/co-simulation/bundle/src/assembly/resources/bin/mosaic.sh b/co-simulation/bundle/src/assembly/resources/bin/mosaic.sh new file mode 100644 index 00000000..abeba484 --- /dev/null +++ b/co-simulation/bundle/src/assembly/resources/bin/mosaic.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# set maximum JVM memory +javaMemorySizeXmx="2g" + +# uncomment to activate remote debugging +# javaRemoteDebugging="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=10000" + +# mosaic +dir_mosaic=./lib/mosaic +tmp=`ls ${dir_mosaic} | grep jar` +mosaic=${dir_mosaic}/${tmp//[^A-Za-z0-9\-\.]/:${dir_mosaic}/} + +# third-party +dir_libs=./lib/third-party +tmp=`ls ${dir_libs} | grep jar` +libs=${dir_libs}/${tmp//[^A-Za-z0-9\-\.]/:${dir_libs}/} + +# create and run command +cmd="java -Xmx${javaMemorySizeXmx} ${javaRemoteDebugging} -cp .:${mosaic}:${libs} org.eclipse.mosaic.starter.MosaicStarter $*" +$cmd diff --git a/co-simulation/pom.xml b/co-simulation/pom.xml index 347ec4c3..9b682ad3 100644 --- a/co-simulation/pom.xml +++ b/co-simulation/pom.xml @@ -5,7 +5,7 @@ org.eclipse.mosaic mosaic-parent - 21.2 + 22.1-SNAPSHOT pom Eclipse MOSAIC Parent @@ -83,7 +83,7 @@ - 1.0 + 22.1-SNAPSHOT . UTF-8 1.8 diff --git a/co-simulation/sample_scenario.zip b/co-simulation/sample_scenario.zip index 2c5ad892..a40c9ccf 100644 Binary files a/co-simulation/sample_scenario.zip and b/co-simulation/sample_scenario.zip differ diff --git a/docker/build-image.sh b/docker/build-image.sh index 8df3486d..d81099c4 100755 --- a/docker/build-image.sh +++ b/docker/build-image.sh @@ -18,7 +18,7 @@ USERNAME=usdotfhwastol cd "$(dirname "$0")" # IMAGE=$(./get-image-name.sh | tr '[:upper:]' '[:lower:]') -IMAGE="carma-xil-cosimulation" +IMAGE=$(basename `git rev-parse --show-toplevel`) echo "" echo "##### $IMAGE Docker Image Build Script #####" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000..9485db1b --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ -z "$@" ]]; then + source ~/.base-image/env.sh; cd /opt/carma-simulation; exec "bash" +else + source ~/.base-image/env.sh; cd /opt/carma-simulation; exec "$@" +fi + diff --git a/docker/env.sh b/docker/env.sh new file mode 100755 index 00000000..c00c8b66 --- /dev/null +++ b/docker/env.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Set environment variables here. + +export NS3_HOME="/opt/ns-3/" +export JAVA_HOME="/usr/lib/jvm/java-11-jdk-amd64" +export SUMO_HOME="/opt/sumo/sumo-1_12_0" +export CARLA_HOME="/opt/carla" +export CARMA_SIMULATION_HOME="/opt/carma-simulation" +export PATH="/usr/local/share/sumo/bin:/usr/local/share/sumo/tools:$PATH" +export PATH="/opt/maven/bin:$PATH" +export PATH="/opt/carma-simulation:$PATH" diff --git a/docker/install.sh b/docker/install.sh index 3de4ae5e..d2be8e09 100755 --- a/docker/install.sh +++ b/docker/install.sh @@ -1,21 +1,122 @@ #!/bin/bash # Copyright (C) 2018-2020 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. -source /opt/ros/kinetic/setup.bash -cd ~/ -colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release +set -e -chmod -R ugo+x ~/install \ No newline at end of file +# Install software-proprties-common to be able to setup PPA repos +sudo apt-get update +sudo apt-get install -y software-properties-common + +sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test +sudo add-apt-repository -y ppa:deadsnakes/ppa +sudo apt-get update + +# Download apt dependencies +sudo apt-get install -y --allow-unauthenticated gcc-7 g++-7 python3.6 unzip tar python3.6-dev \ + pkg-config sqlite3 autoconf libtool curl make libxml2 libsqlite3-dev \ + libxml2-dev cmake libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev \ + libgl2ps-dev python3.7 python3-pip automake openjdk-8-jdk ant python3.7-dev \ + python3.7-distutils x11-xserver-utils dconf-editor dbus-x11 libglvnd0 libgl1 \ + libglx0 libegl1 libxext6 libx11-6 python3-dev \ + build-essential pkg-config lbzip2 libprotobuf-dev protobuf-compiler patch rsync \ + wget vim nano xterm default-jdk libprotobuf-dev +sudo rm -rf /var/lib/apt/lists/* +export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" + +#update-alternatives --set python /usr/bin/python3.7 +sudo apt-get clean +sudo rm -rf /var/cache/oracle-jdk8-installer +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20 --slave /usr/bin/g++ g++ /usr/bin/g++-7 +sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 +sudo update-alternatives --set python /usr/bin/python3.7 + +cd /home/carma/src + +# Install Protobuf - OPTIONAL +# +# Pulled in via apt-get instead of compiled +# +#wget "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.3.0.tar.gz" +#tar xvf v3.3.0.tar.gz +#cd protobuf-3.3.0 +#./autogen.sh +#./configure --prefix=/usr + +#make +#make check +#sudo make install + +# Install NS-3 +#cd "/home/carma/src/co-simulation tool/bundle/src/assembly/resources/fed/ns3/" +# Added sudo cp -ar ns-3.28/build/ns /usr/include before "Build ns3-federate" in ns3_installer.sh +#chmod +x ns3_installer.sh +#set -x +#./ns3_installer.sh -q +#TODO: Add expore NS3_HOME=path_to_run.sh to /bin/fed/ns3/run.sh + +# Install SUMO-1.12.0 +cd /home/carma/src/ +wget "https://github.com/eclipse/sumo/archive/refs/tags/v1_12_0.tar.gz" +sudo mkdir -p /opt/sumo +sudo chown -R carma:carma /opt/sumo +tar xvf v1_12_0.tar.gz -C /opt/sumo +sudo cp co-simulation/traci_update/constants.py /opt/sumo/sumo-1_12_0/tools/traci +sudo cp co-simulation/traci_update/connection.py /opt/sumo/sumo-1_12_0/tools/traci +sudo cp co-simulation/traci_update/main.py /opt/sumo/sumo-1_12_0/tools/traci +cd /opt/sumo/sumo-1_12_0 +mkdir -p build/cmake-build && cd build/cmake-build +cmake ../.. +make -j$(nproc) +sudo make install + +# Install python3.7 and lxml +python3.7 -m pip install pip +python3.7 -m pip install lxml==4.5.0 + +# Install CARLA +cd /home/carma/src/ +if [[ ! -f '/home/carma/src/CARLA_0.9.10.tar.gz' ]]; then + echo "!!! CARLA not present in the installation directy, please download CARLA_0.9.10.tar.gz into the work directory and rebuild. !!!" + exit -1 +fi + +sudo mkdir -p /opt/carla +sudo chown -R carma:carma /opt/carla +tar xzvf CARLA_0.9.10.tar.gz -C /opt/carla + +# Installation of Co-Simulation Tool +wget "https://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz" +sudo mkdir -p /opt/maven +sudo chown -R carma:carma /opt/maven +tar xzvf apache-maven-3.8.3-bin.tar.gz -C /opt/maven +export PATH=/opt/maven/apache-maven-3.8.3/bin/:$PATH + +# Build co-simulation tool +cd /home/carma/src/co-simulation +mvn clean install -DskipTests +cd bundle/target +sudo mkdir -p /opt/carma-simulation +sudo chown -R carma:carma /opt/carma-simulation +unzip carla-sumo-mosaic-22.1-SNAPSHOT.zip -d /opt/carma-simulation +sudo chmod +x /opt/carma-simulation/mosaic.sh +sudo mkdir /opt/carma-simulation/scenarios/tmp_scenario +cp bundle-22.1-SNAPSHOT.jar /opt/carma-simulation + +# Deploy scenario files +cd /home/carma/src/co-simulation +unzip sample_scenario.zip -d /opt/carma-simulation/scenarios + +echo "Build complete!!!" diff --git a/docker/run.sh b/docker/run.sh index 5aa8d232..cb0aaff8 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,8 +1,18 @@ #!/bin/bash +function parseCheck(){ + if [[ -z "$1" ]]; then + echo "Missing necessary parameter, please reference ./run.sh --help" + return 1 + fi + return 0 +} + RUNTIME="" -IMAGE="carma-xil-cosimulation" +IMAGE=$(basename `git rev-parse --show-toplevel`) DOCKER_VERSION=$(docker version --format '{{.Client.Version}}' | cut --delimiter=. --fields=1,2) + + if [[ $DOCKER_VERSION < "19.03" ]] && ! type nvidia-docker; then RUNTIME="--gpus all" else @@ -10,21 +20,81 @@ else fi while [[ $# -gt 0 ]]; do - arg="$1" - case $arg in + case "$1" in -v|--version) COMPONENT_VERSION_STRING="$2" shift shift - ;; + ;; + + -s|--scenario) + case "$2" in + --from_local) + if parseCheck "$3" ; then + SCENARIO_PATH="$3" + SCENARIO=$(printf %s "$SCENARIO_PATH" | awk -F"/" '{print $NF}') + shift + shift + shift + else + exit 1 + fi + ;; + --from_docker) + if parseCheck "$3" ; then + SCENARIO="$3" + shift + shift + shift + else + exit 1 + fi + ;; + esac + ;; + + -h|--help) + echo "-v| --version [docker image tag]" + echo "-s| --scenario --from_local [path to scenario]" + echo "-s| --scenario --from_docker [scenario name]" + + exit 0 esac done -echo "##### Running usdotfhwastol/carma-xil-cosimulation:$COMPONENT_VERSION_STRING docker container #####" -docker run \ - --rm -it\ - --gpus all\ - --net=host\ - -v /tmp/.X11-unix:/tmp/.X11-unix\ - -e DISPLAY=$DISPLAY\ - -e QT_X11_NO_MITSHM=1\ - --user=carla_sumo_mosaic usdotfhwastol/carma-xil-cosimulation:$COMPONENT_VERSION_STRING + +if [[ -z "$COMPONENT_VERSION_STRING" ]]; then + COMPONENT_VERSION_STRING=$("./get-component-version.sh") +fi + +if [[ -z "$SCENARIO" ]]; then + SCENARIO="HelloWorld" +fi + +parseCheck "$SCENARIO_PATH" + +echo "##### Running usdotfhwastol/$IMAGE:$COMPONENT_VERSION_STRING docker container with $SCENARIO scenario #####" + +if [[ -z $SCENARIO_PATH ]]; then + # run scenario which already exists in docker container + docker run \ + --rm -it\ + --gpus all\ + --net=host\ + -v /tmp/.X11-unix:/tmp/.X11-unix\ + -e DISPLAY=$DISPLAY\ + -e QT_X11_NO_MITSHM=1\ + --user=carma usdotfhwastol/$IMAGE:$COMPONENT_VERSION_STRING\ + ./mosaic.sh -s $SCENARIO +else + # mount and run scenario from local to docker container + docker run \ + --rm -it\ + --gpus all\ + --net=host\ + -v /tmp/.X11-unix:/tmp/.X11-unix\ + -v $SCENARIO_PATH:/opt/carma-simulation/scenarios/tmp_scenario \ + -e DISPLAY=$DISPLAY\ + -e QT_X11_NO_MITSHM=1\ + --user=carma usdotfhwastol/$IMAGE:$COMPONENT_VERSION_STRING\ + ./mosaic.sh -s tmp_scenario +fi diff --git a/docs/Release_notes.md b/docs/Release_notes.md new file mode 100644 index 00000000..b467a229 --- /dev/null +++ b/docs/Release_notes.md @@ -0,0 +1,115 @@ +# CARMA Simulation Release Notes + +## October 4th, 2022 - Version 1.0.1 + +### CARMA Simulation 1.0.1 +carma-simulation release version 1.0.1 is a hotfix to correct an artifacts problem in the build environment for 1.0.0. Also, added the dockerization feature for Docker image build process. + +#### Features: +- Added carma-simulation dockerization feature which updates Docker configuration to be similar to how the rest of the CARMA product ecosystem utilizes Docker for builds and configuration management. + +#### Fixes: +- Resolve error while processing the POMs during the mvn clean +- Resolve mosaic.sh file not show up in the zip file after mvn build complete + +# Full list of PRs included in this release: +* Feature/dockerization update by @kjrush in https://github.com/usdot-fhwa-stol/carma-simulation/pull/83 +* Fix/simulation_scenario by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/84 +* Fix/docker sumo version by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/85 +* Feature/dockerization upload scenario by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/86 +* hotfix/build_environment by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/87 + +## August 10th, 2022 - Version 1.0.0 +Release version 1.0.0 of CARMA Simulation products. Initital release intended +to deliver minimum-viable-proudct integration of several major simulation +components: CARMA Platform, MOSAIC, SUMO, CARLA. + +### CARMA Simulation 1.0.0 +Initial full release. Minimum viable product version of CARMA Simulation to act as a base for additional feature development and to allow prospective users to begin integration and early use of tool. + +#### Features: +- Incorporate Eclipse MOSAIC Co-simulation framework including MOSAIC Runtime + Infrastructure (RTI), SUMO, and NS-3. +- Integrate CARLA with MOSAIC RTI. + - Vehicle synchronization between CARLA and SUMO + - Traffic signal synchronization between CARLA and SUMO + - Simulation map synchronization between CARLA and SUMO +- Dockerized setup of MOSAIC and simulators including CARLA +- Configure data output and logging to record data for verifying synchronization +- Integrate new Turner-Fairbank Highway Research Center simulation map with SUMO + and CARLA +- Develop initial build and deployment documentation for CARMA Simulation 1.0.0 + +#### Fixes: +- Resolve MOSAIC RTI priority queue conflicts which caused simulation deadlock + +### CARMA-CARLA Integration 1.0.0 +Initial full release. Minimum viable product version of CARMA-CARLA Integration packages to act as a base for additional feature development and to allow prospective users to begin integration and early use of tool. + +#### Features: +- Support for registration of CARMA Platform vehicles with CARLA ego-vehicle + roles +- Integration of CARMA Platform controller plugins with CARLA control inputs + via Ackermann Control node +- Integration of CARMA Platform localization with "ground truth" position of + vehicle in CARLA +- Integration of CARMA Platform perception with "ground truth" object list of + neighboring vehicles and obstacles +- Dockerized setup of CARMA Platform integration nodes + +#### Fixes: +- Resolve data rate consistency issues with CARMA-CARLA bridge + + + +# Full list of PRs included in this release: +* Feature/ci by @jtbaird in https://github.com/usdot-fhwa-stol/carma-simulation/pull/2 +* Feature/carla ackermann control wrapper by @fangzhou1227 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/1 +* add launch files for carma-simulation by @fangzhou1227 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/3 +* Make CI use dev images by @msmcconnell in https://github.com/usdot-fhwa-stol/carma-simulation/pull/4 +* Fix file not found error during cmake_install by @fangzhou1227 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/5 +* Updated package.xml files by @jsun6065 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/6 +* added release flag by @jtbaird in https://github.com/usdot-fhwa-stol/carma-simulation/pull/7 +* Fix/camke install error by @fangzhou1227 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/9 +* remove java by @MishkaMN in https://github.com/usdot-fhwa-stol/carma-simulation/pull/10 +* Release/wanderer by @jtbaird in https://github.com/usdot-fhwa-stol/carma-simulation/pull/11 +* Feature/building with colcon by @jsun6065 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/8 +* Feature/sync 3.4.3 by @msmcconnell in https://github.com/usdot-fhwa-stol/carma-simulation/pull/12 +* Fix build image .sh for dev and candidate images by @msmcconnell in https://github.com/usdot-fhwa-stol/carma-simulation/pull/13 +* Feature/repo cleanup for xil by @kjrush in https://github.com/usdot-fhwa-stol/carma-simulation/pull/15 +* upload script of creating corresponding CARLA virtual vehicle by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/18 +* Create carma_to_carla_ackermann_cmd by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/20 +* Feature/mosaic carla sumo ambassadors by @kjrush in https://github.com/usdot-fhwa-stol/carma-simulation/pull/17 +* Feature/carla carma agent by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/22 +* Create carla_to_carma_localization by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/21 +* Fix the path errors in the run.sh. by @DFCui in https://github.com/usdot-fhwa-stol/carma-simulation/pull/36 +* Fix CARLA CARMA bridge scripts by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/33 +* Fix/carla carma agent remove autoware by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/38 +* carla carma integration docker by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/37 +* CARLA-CARMA integration tool user instruction README.md by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/34 +* Create carla_to_carma_external_objects by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/23 +* Create carla_to_carma_twist by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/19 +* Fix/carla carma integration build and launch issue by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/40 +* Update/co simulation tool docker README by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/41 +* Correct wrong image name by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/42 +* Adding method to calculate velocity twist for external object function. by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/48 +* Update/driver status and robot status by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/45 +* Fix/carla sumo traffic light sync by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/53 +* Added environment setting in carla-carma-integration README.md file by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/52 +* Fix/incontinuous data publishing by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/51 +* Fix/soruce name not matching by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/56 +* Fix/driver manager issue by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/58 +* carla_mosaic_update by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/70 +* Update/carla mosaic bridge by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/71 +* update co-simulation docker and instruction by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/72 +* Feature/merge 1.0 to master by @chengyuan0124 in https://github.com/usdot-fhwa-stol/carma-simulation/pull/74 + +## New Contributors +* @jtbaird made their first contribution in https://github.com/usdot-fhwa-stol/carma-simulation/pull/2 +* @fangzhou1227 made their first contribution in https://github.com/usdot-fhwa-stol/carma-simulation/pull/1 +* @msmcconnell made their first contribution in https://github.com/usdot-fhwa-stol/carma-simulation/pull/4 +* @jsun6065 made their first contribution in https://github.com/usdot-fhwa-stol/carma-simulation/pull/6 +* @MishkaMN made their first contribution in https://github.com/usdot-fhwa-stol/carma-simulation/pull/10 +* @DFCui made their first contribution in https://github.com/usdot-fhwa-stol/carma-simulation/pull/36 + +**Full Changelog**: https://github.com/usdot-fhwa-stol/carma-simulation/commits/carma-simulation-1.0.0