Skip to content

Commit

Permalink
Feature/time source (#57)
Browse files Browse the repository at this point in the history
* Created CARMA Cloud time source and simulation federate

* Added SimFederal servlet configuration

* Updated SimFederate to test ambassador address.

* Update SimFederate import InetAdress.

* Fixed SimFederate registration JSON message.

* Update Dockerfile with simulation configuration.

* Update rsu.js

* Update map.js

* Update Dockerfile

* Update ihp.js

* SimFederate separated registration retry from socket close

* Update web.xml

* Update Dockerfile

* Update Dockerfile

* Update SimFederate.java

* Update RoadMark.java

* Update satellite-streets-v11.json

* Update sourcelayers.json

* Update validatexodr_sourcelayers.json

* Removed commented-out RSM Servlet.

* Default traffic control update and start time to 0L.

* Added port and list attribute parsing to old TCR format.

* Updated TcmReqServlet to preserve request host address.

* Added error log to TCM response connection.

* Add docker and dockerhub workflows

* Build and push image for testing

* Update web.xml init TimeSource singleton first and added CARMA Cloud simulation id

* Delete lib/libcs2cswrapper.so

This library is downloaded in install dependencies script, and compiled from source in the build script.

* Added CARMA Cloud simulation id configuration item and handle exceptions better

* Use TimeSource to handle simulation and real world time, remove extraneous commented code

* Update TcmReqServlet to use TimeSource

* Update web.xml to add explicit simulation mode logical flag

* Update SimFederate to check for explicit simulation mode configuration

* Update SimFederate to use JSON libary for building ambassador registration message

* Update SimFederate fixed sid typo

* Update dockerfile and move instructions to scripts
Added deployment_test workflow to replace circleci integration test workflow

* Install GIT for checkout

* Fix build/install scripts issues

* Figure out CI VM path

* Fix path error

* Remove rm calls in build script

* Update to build scripts

* Print commands in scripts and their arguments as exexuted

* Update

* Updates to fix carma-cloud path to absolute /home/carma-cloud inside build.sh

* Update path for workflow

* Fix issues

* Updates

* Updates

* Updates

* Update

* Updates

* Removing circle ci workflow that was replaced with github action

* Update with docker-compose file, testing script and volume directory

* add carma-cloud-config work folder

* Update install_dependencies.sh

* Update build.sh

* Update deployment_test.yml

* Update map.js

* Update ihp.js

* Update rsu.js

* Revert "add carma-cloud-config work folder"

This reverts commit 311cf83.

* Update build.sh to modify default host path

* Delete carma-cloud-config/server.xml

* Create web.xml for simulation

* Update web.xml to adjust SimFederate load on startup order

* Remove trigger for building feature/time-source docker image

---------

Co-authored-by: kruegersp <kruegersp@users.noreply.github.com>
Co-authored-by: Eric Chen <122404059+EricChen-Lei@users.noreply.github.com>
  • Loading branch information
3 people authored May 29, 2024
1 parent 4c64ffc commit b1e6053
Show file tree
Hide file tree
Showing 23 changed files with 802 additions and 191 deletions.
70 changes: 0 additions & 70 deletions .circleci/config.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/deployment_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on:
push:
branches:
- develop
- master
- "release/*"
pull_request:
types: [opened, synchronize, reopened]
name: Deployment Test
jobs:
deployment_test:
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
defaults:
run:
shell: bash
steps:
- name: Install git
# Installing git for checkout action
run: |
apt update
export DEBIAN_FRONTEND=noninteractive
apt-get install -y git
- name: Checkout
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
path: ${{ github.event.repository.name }}
submodules: recursive
- name: Move source code
run: mv $GITHUB_WORKSPACE/${{ github.event.repository.name }} /home/carma-cloud
- name: Install dependencies
run: |
cd /home/carma-cloud/scripts
./install_dependencies.sh
- name: Build
run: |
cd /home/carma-cloud/scripts
./build.sh
- name: Configure network and set privileges
run: |
echo -e '127.0.0.1\tcarmacloud' | tee -a /etc/hosts
groupadd tomcat
useradd -g tomcat -m tomcat
chmod g+r /opt/tomcat/conf/*
chmod -R o-rwx /opt/tomcat/webapps/*
chown -R root:tomcat /opt/tomcat
chown -R tomcat:tomcat /opt/tomcat/logs
chown -R tomcat:tomcat /opt/tomcat/temp
chown -R tomcat:tomcat /opt/tomcat/work
- name: Start Tomcat and verify deployment
run: |
/opt/tomcat/bin/catalina.sh start
sleep 10
if [[ `grep "startup in" /opt/tomcat/logs/catalina.out | wc -l` -ne "1" ]]; then exit 1; fi
if [[ `wget -O - http://carmacloud:8080 | grep "CARMAcloud Login" | wc -l` -ne "1" ]]; then exit 2; fi
if [[ `wget -O - --post-data="uname=ccadmin&pword=admin_testpw" http://carmacloud:8080/api/auth/login | grep "token" | wc -l` -ne "1" ]]; then exit 3; fi
9 changes: 9 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Docker build
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
docker:
uses: usdot-fhwa-stol/actions/.github/workflows/docker.yml@main
with:
runner: ubuntu-latest
17 changes: 17 additions & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Docker Hub build
on:
push:
branches:
- develop
- master
- "release/*"
tags:
- "carma-system-*"
jobs:
dockerhub:
uses: usdot-fhwa-stol/actions/.github/workflows/dockerhub.yml@main
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
runner: ubuntu-latest
60 changes: 12 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,15 @@
FROM ubuntu:22.04
# update package manager and install prerequisites
RUN apt-get update -y && \
apt-get install -y build-essential cmake git wget pkg-config sqlite3 libcurl4-openssl-dev libsqlite3-dev libtiff5-dev
# download geodesy projection library source
WORKDIR /tmp
RUN wget -q https://download.osgeo.org/proj/proj-9.3.0.tar.gz && \
tar -xzf proj-9.3.0.tar.gz && \
rm proj-9.3.0.tar.gz && \
mv proj-9.3.0 proj && \
mkdir -p proj/build
# download openjdk
RUN wget -q https://download.java.net/java/GA/jdk21.0.1/415e3f918a1f4062a0074a2794853d0d/12/GPL/openjdk-21.0.1_linux-x64_bin.tar.gz && \
tar -xzf openjdk-21.0.1_linux-x64_bin.tar.gz && \
rm openjdk-21.0.1_linux-x64_bin.tar.gz && \
mv jdk-21.0.1 /opt/jdk
# download apache tomcat
RUN wget -q https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.83/bin/apache-tomcat-9.0.83.tar.gz && \
tar -xzf apache-tomcat-9.0.83.tar.gz && \
rm apache-tomcat-9.0.83.tar.gz && \
mv apache-tomcat-9.0.83 tomcat && \
sed -i 's/appBase="webapps"/appBase="webapps\/carmacloud"/g' tomcat/conf/server.xml && \
rm -r tomcat/webapps/*
COPY scripts/install_dependencies.sh /home/carma-cloud/scripts/install_dependencies.sh
RUN /home/carma-cloud/scripts/install_dependencies.sh
COPY src /home/carma-cloud/src
COPY lib /home/carma-cloud/lib
COPY web /home/carma-cloud/web
COPY osmbin /home/carma-cloud/osmbin
COPY *.sh /home/carma-cloud/
COPY scripts/build.sh /home/carma-cloud/scripts/build.sh

# download carma-cloud source
RUN git clone https://github.com/usdot-fhwa-stol/carma-cloud.git cc && \
rm cc/lib/libcs2cswrapper.so && \
mkdir -p tomcat/webapps/carmacloud/ROOT && \
mv cc/web/* tomcat/webapps/carmacloud/ROOT
# compile geodesy projection library
WORKDIR /tmp/proj/build
RUN cmake .. && \
cmake --build . && \
cmake --build . --target install
# compile jni projection library
WORKDIR /tmp/cc/src/cc/geosrv
RUN gcc -c -std=c11 -fPIC -Wall -I /opt/jdk/include/ -I /opt/jdk/include/linux/ -I /tmp/proj/src/ cs2cswrapper.c && \
gcc -shared -lproj cs2cswrapper.o -o libcs2cswrapper.so && \
mv *.so /usr/lib
# compile carma-cloud java source and cleanup
WORKDIR /tmp
RUN find ./cc/src -name "*.java" > sources.txt && \
mkdir -p tomcat/webapps/carmacloud/ROOT/WEB-INF/classes && \
/opt/jdk/bin/javac -cp tomcat/lib/servlet-api.jar:cc/lib/commons-compress-1.18.jar:cc/lib/javax.json.jar:cc/lib/json-20210307.jar:cc/lib/keccakj.jar:cc/lib/log4j-api-2.16.0.jar:cc/lib/vector_tile.jar -d tomcat/webapps/carmacloud$
rm sources.txt && \
/opt/jdk/bin/java -cp tomcat/webapps/carmacloud/ROOT/WEB-INF/classes/:tomcat/lib/servlet-api.jar cc.ws.UserMgr ccadmin admin_testpw > tomcat/webapps/carmacloud/user.csv && \
echo "JAVA_HOME=/opt/jdk" > tomcat/bin/setenv.sh && \
mv tomcat /opt && \
rm -r proj && \
rm -r cc
# start carma-cloud
CMD /opt/tomcat/bin/catalina.sh start
RUN /home/carma-cloud/scripts/build.sh
ENTRYPOINT [ "/opt/tomcat/bin/catalina.sh", "run" ]

18 changes: 18 additions & 0 deletions SendTimeSyncMessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import http.client
import json
import requests

connection = http.client.HTTPConnection("localhost:8080")
# headers = {'Content-type': 'application/json'}
foo = {'timestep': 100, 'seq': 1}

connection.request("POST", "/carmacloud/simulation/dumb", json.dumps(foo))
x = requests.post("http://127.0.0.1:8080/carmacloud/simulation/dumb", json.dumps(foo))
print(x)

response = connection.getresponse()
print(response.read().decode())

connection.request("GET", '/api/rop/details')
response = connection.getresponse()
print(response.read().decode())
18 changes: 18 additions & 0 deletions carma-cloud-config/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
status = warn
monitorInterval = 300

appender.rolling.type = RollingFile
appender.rolling.name = LogToRollingFile
appender.rolling.fileName = /opt/tomcat/logs/carmacloud.log
appender.rolling.filePattern = /opt/tomcat/logs/carmacloud-%d{yyyyMMdd}.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%-5level %d{HH:mm:ss.SSS} [%c{1}] - %msg%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 366

rootLogger.level = debug
rootLogger.appenderRef.stdout.ref = LogToRollingFile
Loading

0 comments on commit b1e6053

Please sign in to comment.