File tree:
.
├── compile_proto.sh # script for compiling proto files
├── cyber # proto files from Apollo Autopilot
├── cyber_bridge # codes for communicating with Apollo cyber_bridge
├── Dockerfile # Dockerfile
├── dreamview_api.py # Apollo Dreamview websocket api
├── main.py # main script
├── modules # proto files from Apollo Autopilot
├── opendrive # opendrive maps
├── pygame_viewer.py # pygame viewer sub-process
├── README.md # this README.md
├── requirements.txt # required python packages
├── scenario_configs # scenario configurations, unused for now
├── scenario_runner # scenario_runner submodule
├── sensor_configs # sensors configurations
├── sensors # codes for sensors
├── setup.bash # setup environment variables
└── utils.py # common utilities codes
# 0. good programmers start counting at zero
git clone --recurse-submodules git@gitlab.quyan.info:the-flying-hoyshanist/simulator.git
# 1. cd to project root
cd simulator/
# 2. generate protobuf files
bash compile_proto.sh
# 3. source setup script
source setup.bash
# 4. show usage
python main.py -h
# 5. run main.py script
python main.py --carla-host <carla.server.ip.addr> --apollo-host <apollo.ip.addr> --configFile scenario_configs/781_stop_at_fix_location_cfg.json
- include scenario_runner as a git submodule, and start scenerio_manager as a child process
- turn all
print
s intolog
s project docker image (Dockerfile)- apollo opendrive map converter (*.xodr -> apollo_map)
- communication between scenario_runner and main process
different frequency for different sensorssensor configuration files
A functioning simulator node should contains the following components:
- Carla Sensors Module
- Control Sensor Module
- Pygame Viewer
- Scenario Runner
- Apollo Bootstrap
Algorithm:
- Wait for ego vehicle to be created
- Setup sensors on ego
- For every server tick, update sensors and send msg to Apollo
- When done, destroy all created sensors (Carla actors)
Exit condition: Process exits when ego no longer exists
Algorithm:
- Wait for ego vehicle to be created
- For every server tick, receive apollo control commands and apply to ego
Exit condition: Process exits when ego no longer exists
Algorithm:
- Wait for ego vehicle to be created
- Create an rgb camera sensor attached to ego, and pipe output dataframe to pygame
- For every server tick, update ego status and pygame windows
- When done, destroy all created sensors (Carla actors)
Exit condition: Process exits when one of the following happens:
- Ego vehicle no longer exists
- User prompted exit (via pygame interface)
Algorithm:
- Setup Carla world (map, weather, etc)
- Create ego vehicle and other actors (vehicles and walkers)
- For every server tick, monitor ego vehicle metrics and manipulate other actors' behavour accordingly
- Output scenario report
- Destroy all carla actors created in step 2
Exit condition: Process exits when one of the following happens:
- Timeout
- Ego vehicle violate one of the criteria
Algorithm:
- Setup Apollo map
- Setup Apollo vehicle
- Load all required Apollo modules
- Send Apollo routing request
- Monitor Apollo moduels status
- Output abnormalies if any
Exit condition:
Process exits when indicated (probably a multiprocessing.Event
?)
ChassisAlter
BestPose
Odometry
InsStatus
CorrectedImu
Obstacles
TrafficLightAlter
ClockSensor
Common attributes for all sensors:
- "name": string, id of the sensor, used for identification, should be different for different sensor instances
- "type": string, type of the sensor class
- "frequency": number, set it to -1.0 if the sensor should be run as fast as it can
This sensor sends data about the vehicle chassis.
This sensor outputs the GPS location of the vehicle in Longitude/Latitude and Northing/Easting coordintates.
This sensor outputs the GPS location of the vehicle in Longitude/Latitude and Northing/Easting coordintates and the vehicle velocity.
Since some maps do not centred at (0,0), there are two additional attributes for this sensor:
- "x_offset": number, offset along the x axis
- "y_offset": number, offset along the y axis
This sensor outputs the status of the GPS correction due to INS. The simulator is an ideal environment in which GPS is always corrected.
This sensor output the data about the vehicle imu status.
This sensor returns 3D ground truth data for training and creates bounding boxes around the detected objects.
Additional attributes:
- "x_offset": number, offset along the x axis
- "y_offset": number, offset along the y axis
- "vehicle_distance": number, vehicles outside of this radius will not be detected
- "walker_distance": number, pedestrians outside of this radius will not be detected
This sensor returns ground truth data for traffic light signals connected to the current lane of ego vehicle.
This sensor outputs simulated time to CyberRT as clock messages.
Build docker image
git clone --recurse-submodules git@gitlab.quyan.info:the-flying-hoyshanist/simulator.git
cd ./simulator
docker build -t simulator-0.9.11:v0.1 .
Start docker container
docker run -it -d \
-v /tmp/.X11-unix/:/tmp/.X11-unix \
simulator-0.9.11:v0.1 \
bash
bash compile_proto.sh
- Apollo Autopilot maps use a modified version of opendrive, so directly export carla maps to opendrive format won't be compatible with Apollo.
- AuroAI has converted all carla maps to Apollo maps format, see here
# in carla/PythonAPI/util
python3 config.py --no-rendering
See https://carla.readthedocs.io/en/0.9.11/adv_rendering_options/ for details.