Table of Contents
CoSim Documentation
A screenshot from Carla running as part of the CoSIM framework
Introduction
CoSim stands for CETRAN open-source Simulation framework. The framework is modular with different tools performing distinct tasks and the framework is able to achieve full system-level software-in-the-loop simulation testing of an autonomous vehicle (AV).
The co-simulation architecture incorporates the following elements:
- A highly customizable and modular simulation framework built on top of the open-source Carla simulator.
- A reference ADS bridge to Baidu Apollo from the Carla simulation framework. The bridge is highly parallelized with multiprocessing-based Carla clients and communicates over a custom low overhead TCP messaging protocol developed by CETRAN.
- Various custom-developed tools and scripts used to facilitate interconnection between disparate aspects of the simulation framework.
This simulation framework and its reference implementation, as described here, consists of open-source tools and components. However, the same general architecture can be used and supplanted with any commercial or custom/proprietary tools as needed.
The framework is able to output sensor data and incorporate realistic and randomized road traffic and pedestrian interactions along with the capability to script complex scenarios which can be used to challenge the various subsystems of an AV.
Project layout
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
src/
ads/
apolloBridgeServer.py # The main server-side script for the Apollo bridge. Run inside Apollo Docker.
cyberReader.py # Module to read control commands from Apollo CyberRT.
cyberWriter.py # Module to write simulation messages into Apollo CyberRT.
sim/
modules/ # Directory containing protobuf modules for Apollo messages
agents/ # Directory containing some Carla Python API modules for scenario generation and execution
cosimManager.py # The main script for the CoSim framework.
bridgeClient.py # The main client-side classes for the Apollo bridge.
apolloEncode.py # Methods to encode and decode ProtoBuf messages as required by Apollo.
sensorManager.py # Module to define ego vehicle sensors and placement
scenarioManager.py # Module to spawn actors and make them execute scenarios using the Carla Python API
config.py # File containing general configuration parameters.
sensorConfig.py # File containing configuration parameters pertaining to the sensor setup of the ego vehicle.
To get started, take a look at the general architecture of the CoSim framework in the next section.
Getting started ↵
CoSIM Architecture
A high level architecture of the CoSIM framework is illustrated below.
This simulation framework and its reference implementation have mostly been built with open-source tools. However, the same general architecture can be used and supplanted with any commercial or custom/proprietary tools, as needed. The current version of the simulation framework consists of a reference bridge to the Baidu Apollo ADS. This reference bridge can serve as a good baseline to create an interface between the framework and any ADS.
Map creation workflow
This section describes the workflow for creating maps compliant with the CoSIM framework and its reference bridge to the Baidu Apollo ADS.
MathWorks RoadRunner can be used for modelling and exporting the map in various formats for the CoSIM framework. RoadRunner is a versatile and easy-to-use 3D road and environment modelling tool with powerful functionalities to import and export multiple different file formats focused on vehicle and autonomous driving testing.
RoadRunner is widely used by both industry and academia. Roads and associated infrastructure can be placed in a 3D space with relative ease using a straightforward GUI. Various aspects of the road network such as textures, lane markings, lane widths and so on can be customized as per requirements.
Formats required
Once the base map is generated on RoadRunner, it is exported to different formats as per the requirements of the individual tools in the simulation toolchain. These are as follows:
- Carla - As per the latest verion of Carla, RoadRunner exports have to be fulfilled in the Unreal Editor Datasmith format along with an OpenDRIVE file. Datasmith serves as a robust file format and workflow toolkit designed to streamline the integration of 3D data from various design and modeling applications into Unreal Engine. It intelligently converts lights and materials, preserving metadata, hierarchy, and enabling automatic updates for iterative design processes. The format facilitates photorealistic visualization within Unreal Engine, making it easy to quickly generate and update road models from RoadRunner.
- Apollo - Apollo requires the map in a specific ProtoBuf HD map format with semantic information about road features such as individual lanes. RoadRunner supports Apollo export in both plaintext and binary formats.
- SUMO - SUMO, if used for traffic simulation, requires the OpenDRIVE file to generate its own map network. Once the file is imported into SUMO, it must be post-processed to enable left-hand driving, as SUMO in its default configuration only supports right-hand driving. For more details, refer here.
Base map
For generating a map based on real-world locations, the first step of the workflow is to import ground-truth geospatial data. This could be in the form of GIS vector data, pointclouds or even accurately scaled drawings or map images.
For example, we can use the Singapore Land Traffic Authority's (LTA) publicly available kerbline dataset as the ground-truth data. The kerbline data is available freely as a ShapeFile (SHP) for the entire island of Singapore on the Land Transport DataMall. Using a free GIS software such as QGIS, we can isolate the area required for the simulation map before exporting the SHP file to GPS Exchange (GPX) format or GeoJSON format which can be imported into the RoadRunner workspace.
Export
The RoadRunner map, once modelled, can be exported to various formats as is required for the simulation test framework. The maps used for the ADS and the simulator have to match.
For the reference implentation, the map is recommended to be exported to the Unreal Datasmith format for Carla and the Baidu Apollo .bin format for the ADS. Carla coordinate system is the same as the exported map coordinates except with an inverted y-axis (as -y).
Apollo map
The Apollo map has an arbitrary offset which is specified in the config.py
file and is applied to the localization messages.
-
To find this offset, create a 5m long road from (0,0) to (0,5) in RoadRunner. Export the OpenDrive (.xodr) and Apollo map (.txt, .bin) formats.
-
From the .xodr, find the ID of the road. Find the same road ID in the Apollo .txt file and note the x and y values. These values are the offset. This offset value must be updated in the
config.py
file. -
After this, copy the map files into a new directory (named after your map) on the ADS machine at
/apollo/modules/maps/data/
. The file should be namedbase_map.bin
. -
bazel-bin/modules/map/tools/proto_map_generator --map_dir=INPUT_DIR --output_dir=OUTPUT_DIR
-
bazel-bin/modules/map/tools/sim_map_generator --map_dir=INPUT_DIR --output_dir=OUTPUT_DIR
-
scripts/generate_routing_topo_graph.sh --map_dir=INPUT_DIR
Refer here for more details on Apollo's map requirements.
Carla map
To import maps into Carla, users may follow the official guide here. This includes detailed instructions on how to use RoadRunner to create maps for Carla.
Ended: Getting started
CoSim framework ↵
Prerequisites
Software requirements
Before trying out the CoSim framework yourself, ensure that the following software packages are installed.
Simulation machine
- Operating system: Windows 10/11 or Ubuntu 20.04
- Python 3.8.10
- NumPy
- opencv-python
- pandas
- transforms3d
- Netstruct
- protobuf 3.14
ADS machine
- Operating system: Ubuntu 20.04
- Apollo 8.0
- Python 3.8.10
- netstruct
Apollo flag configuration to enable planning module with Carla bridge
On the Apollo machine, set the enable_map_reference_unify
flag as 'false' in apollo/modules/common/configs/config_gflags.cc
Once set as 'false', it should look like this:
DEFINE_bool(enable_map_reference_unify, false,
"enable IMU data convert to map reference");
Now, rebuild Apollo using ./apollo.sh build_opt_gpu
.
Hardware recommendations
Simulation machine
- CPU - A modern AMD or Intel CPU with good single and multithreaded performance
- GPU - A modern AMD or Nvidia GPU supporting Vulkan and DX12
- Memory - At least 16GB
- Storage - At least 500GB
- Network - At least 1GbE
ADS machine
- CPU - At least an 8-core AMD or Intel CPU with good single and multithreaded performance
- GPU - NVIDIA Turing GPU or AMD GFX9/RDNA/CDNA GPU
- Memory - At least 16GB
- Storage - At least 500GB
- Network - At least 1GbE
CoSIM Manager
The CoSim Manager is responsible for managing the simulation, calling the various client scripts, passing them data and starting and stopping scenarios.
A high-level architecture is shown here.
Here we list the identifier of the functions/class we commented
cosimManager.py
src.sim.cosimManager.ActorSnapshots()
src.sim.cosimManager.ActorSnapshots.parseActorSnapshot(snap, obsIDList, actorList, carlamap)
Parse the Carla snapshot to extract actor data. This is subsequently used to generate the actor ground truth message for the ADS.
Parameters:
-
snap
(Snapshot
) –Carla snapshot to be parsed
-
obsIDList
–List of actor IDs to be included in the output
-
actorList
–List of carla.actors used to retrieve static information
-
carlamap
–Carla world.map object used to get properties such as those for geolocation transformation
Returns: A tuple including all actor properties for each actor
src.sim.cosimManager.actorReader(CARLA_HOST, CARLA_PORT)
Manager function to send actor data using the bridge
Parameters:
-
CARLA_HOST
(string
) –Host IP of Carla server
-
CARLA_PORT
(int
) –Port of Carla server
src.sim.cosimManager.camReader(CARLA_HOST, CARLA_PORT)
Manager function to send camera on the bridge
Parameters:
-
CARLA_HOST
(string
) –Host IP of Carla server
-
CARLA_PORT
(int
) –Port of Carla server
src.sim.cosimManager.egoReader(CARLA_HOST, CARLA_PORT)
Manager function to send ego data on the bridge + more things TODO
Parameters:
-
CARLA_HOST
(string
) –Host IP of Carla server
-
CARLA_PORT
(int
) –Port of Carla server
src.sim.cosimManager.egoWriter(CARLA_HOST, CARLA_PORT)
Manager function to receive data from the ADS and control the ego vehicle in Carla accordingly
Parameters:
-
CARLA_HOST
(string
) –Host IP of Carla server
-
CARLA_PORT
(int
) –Port of Carla server
src.sim.cosimManager.lidarReader(CARLA_HOST, CARLA_PORT)
Manager function to send Lidar data on the bridge
Parameters:
-
CARLA_HOST
(string
) –Host IP of Carla server
-
CARLA_PORT
(int
) –Port of Carla server
src.sim.cosimManager.parseEgoSnapshot(snap, egoID, carlamap, throttle, brake, steering)
Parse the Carla snapshot to extract ego vehicle data
Parameters:
-
snap
(Snapshot
) –Carla snapshot to be parsed
-
egoID
–ID of the ego vehicle which is a carla.actor
-
carlamap
–Carla world.map object used to get properties such as those for geolocation transformation
-
throttle
–Throttle value taken from the ADS to be fed back in the ego state message
-
brake
–Brake value taken from the ADS to be fed back in the ego state message
-
steering
–Steering value taken from the ADS to be fed back in the ego state message
Returns: A tuple including all properties pertaining to the ego vehicle state
src.sim.cosimManager.scenarioPlayer(CARLA_HOST, CARLA_PORT)
Manager function to control carla actors
Parameters:
-
CARLA_HOST
(string
) –Host IP of Carla server
-
CARLA_PORT
(int
) –Port of Carla server
Bridge Client
The bridge client gets information about the simulation world, actors and the ego vehicle from the Carla simulation server. It also receives the control commands as supplied by the ADS (Automated Driving System) and applies it to the simulated ego vehicle.
The bridge client consists of two files, bridgeClient.py and apolloEncode.py. The former handles communication with the bridge server and the latter handles encoding of messages into formats compatible with the Baidu Apollo ADS.
bridgeClient.py
src.sim.bridgeClient.ApolloBridgeClient_ActorGTPublisher(hostIP, hostPort)
Bases: BridgeClient
Generic Bridge Client
Parameters:
-
hostIP
(string
) –The IP of the ADS host (server)
-
hostPort
(int
) –The port of the ADS host (server)
src.sim.bridgeClient.ApolloBridgeClient_ActorGTPublisher.sendActorGroundTruth(dataList)
Function to send actor ground truth data from the simulator
Parameters:
-
dataList
(tuple
) –Contains all parameters regarding actors in the simulation frame
src.sim.bridgeClient.ApolloBridgeClient_ActorGTPublisher.sendSensorData(data, type)
Wrapper function to send sensor data using the netstruct protocol
Parameters:
-
data
(bytestring
) –Sensor data as a bytestring
-
type
(string
) –String specifying type of sensor data
src.sim.bridgeClient.ApolloBridgeClient_EgoPublisher(hostIP, hostPort)
Bases: BridgeClient
Generic Bridge Client
Parameters:
-
hostIP
(string
) –The IP of the ADS host (server)
-
hostPort
(int
) –The port of the ADS host (server)
src.sim.bridgeClient.ApolloBridgeClient_EgoPublisher.sendEgoData(dataList)
Function to send ego vehicle localization and other data to the ADS. Some of the localization messages are not sent, as specified by the 'enableLocMsgs' flag. This is because Apollo does not need all the localization messages to drive.
Parameters:
-
dataList
(tuple
) –Contains all parameters regarding the ego in the simulation frame
src.sim.bridgeClient.ApolloBridgeClient_ImgPublisher(hostIP, hostPort)
Bases: BridgeClient
Generic Bridge Client
Parameters:
-
hostIP
(string
) –The IP of the ads host (server)
-
hostPort
(int
) –The port of the ads host (server)
src.sim.bridgeClient.ApolloBridgeClient_ImgPublisher.sendImgData(imgData)
Function to send image data from simulator to ADS
Parameters:
-
imgData
–Image data from the simulator
src.sim.bridgeClient.ApolloBridgeClient_ImgPublisher.sendcImgData(cimgData)
Function to send compressed image data from simulator to ADS
Parameters:
-
cimgData
–Compressed image data from the simulator
src.sim.bridgeClient.ApolloBridgeClient_PCPublisher(hostIP, hostPort)
Bases: BridgeClient
Generic Bridge Client
Parameters:
-
hostIP
(string
) –The IP of the ads host (server)
-
hostPort
(int
) –The port of the ads host (server)
src.sim.bridgeClient.ApolloBridgeClient_PCPublisher.sendPCData(PCData)
Function to send pointcloud data from simulator to ADS
Parameters:
-
cimgData
–Compressed image data from the simulator
src.sim.bridgeClient.ApolloBridgeClient_Subscriber(hostIP, hostPort)
Bases: BridgeClient
Generic Bridge Client
Parameters:
-
hostIP
(string
) –The IP of the ads host (server)
-
hostPort
(int
) –The port of the ads host (server)
src.sim.bridgeClient.ApolloBridgeClient_Subscriber.decodeSimData(binMsg)
Function to decode the control command data received from the ADS
Parameters:
-
binMsg
(bytestring
) –Binary message from the ADS to be decoded
src.sim.bridgeClient.BridgeClient(hostIP, hostPort, msgString, delay=None, nextMsgTime=None)
Generic Bridge Client
Parameters:
-
hostIP
(string
) –The IP of the ads host (server)
-
hostPort
(int
) –The port of the ads host (server)
-
msgString
(bstring
) –string ID of the client
-
delay
(float
, default:None
) –time delay between each message
-
nextMsgTime
(float
, default:None
) –store the expected timestamp of the next message
src.sim.bridgeClient.BridgeClient.closeConnection()
Close the connection to the server
src.sim.bridgeClient.BridgeClient.computeNextMsgTime(now, prevMsg, delay)
When a message is sent, determines the timestamp of the next message and wheter to skip frames in case of excessive accumulation
Parameters:
-
now
(float
) –Current timestamp
-
prevMsg
(float
) –Expected time of the previous message
-
delay
(float
) –Expected delay of this message stream
Returns:
src.sim.bridgeClient.BridgeClient.connectToServer()
Initiate connection
src.sim.bridgeClient.BridgeClient.decodeSimData(binMsg)
Decodes and return the message received from the server, to be customized based on the client role.
src.sim.bridgeClient.BridgeClient.recvMsg()
Netstruct function to receive message from apolloBridgeServer
src.sim.bridgeClient.BridgeClient.recvSimData()
Function to receive messages from the server
Returns:
-
–
The message from the server, decoded with self.decodeSimData
src.sim.bridgeClient.BridgeClient.register()
Register a client object to the server
src.sim.bridgeClient.BridgeClient.sendBinMsg(data, msgType)
Netstruct protocol function to package and send binary data
Parameters:
-
data
(bytestring
) –The data to send
-
msgType
(string
) –Message type
apolloEncode.py
src.sim.apolloEncode.ConvertPoints(carlaPoint, t)
Convert Carla points from the pointcloud to the Protobuf PointXYZIT format
Parameters:
-
carlaPoint
–Point from each Carla pointcloud frame
-
t
(float
) –Timestamp
Returns:
-
–
Point in the PointXYZIT format
src.sim.apolloEncode.encode_BPmsgs(lat, lon, utmx, utmy, t, seq)
Package and serialize ego vehicle Best Pose data from the simulator to Apollo's format
Parameters:
-
lat
(float
) –Latitude
-
lon
(float
) –Longitude
-
utmx
(float
) –UTM X-coordinate
-
utmy
(float
) –UTM Y-coordinate
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns:
-
–
Best Pose message as a bytestring
src.sim.apolloEncode.encode_Chamsgs(t, lat, lon, utmx, utmy, odo, heading, vel, throttle, brake, steering)
Package and serialize ego vehicle chassis data from the simulator to Apollo's format
Parameters:
-
t
(float
) –Timestamp
-
lat
(float
) –Latitude
-
lon
(float
) –Longitude
-
utmx
(float
) –UTM X-coordinate
-
utmy
(float
) –UTM Y-coordinate
-
odo
(float
) –Odometer reading
-
heading
(float
) –Heading
-
vel
(float
) –Absolute velocity
-
throttle
(float
) –Throttle percentage
-
brake
(float
) –Brake percentage
-
steering
(float
) –Steering angle
Returns:
-
–
Chassis message as a bytestring
src.sim.apolloEncode.encode_CompressedIMG(imgData, seq)
Package and serialize compressed camera images from the simulator to Apollo's format
Parameters:
-
imgData
–Image data from the simulator
-
seq
(int
) –Sequence number
Returns:
-
–
Compressed image data as a bytestring
src.sim.apolloEncode.encode_GPSmsg(lat, lon, utmx, utmy, qw, qx, qy, qz, velx, vely, heading, t, seq)
Package and serialize ego vehicle GPS data from the simulator to Apollo's format
Parameters:
-
lat
(float
) –Latitude
-
lon
(float
) –Longitude
-
utmx
(float
) –UTM X-coordinate
-
utmy
(float
) –UTM Y-coordinate
-
qw
(float
) –Quaternion W
-
qx
(float
) –Quaternion X
-
qy
(float
) –Quaternion Y
-
qz
(float
) –Quaternion Z
-
velx
(float
) –Velocity in X-axis
-
vely
(float
) –Velocity in Y-axis
-
heading
(float
) –Heading
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns:
-
–
GPS message as a bytestring
src.sim.apolloEncode.encode_Heamsgs(t, seq, heading)
Package and serialize ego vehicle heading from the simulator to Apollo's format
Parameters:
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
-
heading
(float
) –Heading
Returns:
-
–
Heading message as a bytestring
src.sim.apolloEncode.encode_IMG(imgData, seq)
Package and serialize camera images from the simulator to Apollo's format
Parameters:
-
imgData
–Image data from the simulator
-
seq
(int
) –Sequence number
Returns:
-
–
Image data as a bytestring
src.sim.apolloEncode.encode_IMUmsgs(avelX, avelY, avelZ, accX, accY, accZ, t, seq)
Package and serialize ego vehicle IMU data from the simulator to Apollo's format
Parameters:
-
avelX
(float
) –Angular velocity in the X-axis
-
avelY
(float
) –Angular velocity in the Y-axis
-
avelZ
(float
) –Angular velocity in the Z-axis
-
accX
(float
) –Acceleration in the X-axis
-
accY
(float
) –Acceleration in the Y-axis
-
accZ
(float
) –Acceleration in the Z-axis
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns:
-
–
IMU message as a bytestring
src.sim.apolloEncode.encode_INSmsgs(t, seq)
Package and serialize ego vehicle INS data from the simulator to Apollo's format
Parameters:
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns:
-
–
INS message as a bytestring
src.sim.apolloEncode.encode_PC(pcData, seq)
Package and serialize LiDAR pointcloud from the simulator to Apollo's format
Parameters:
-
pcData
–Pointcloud data from the simulator
-
seq
(int
) –Sequence number
Returns:
-
–
Pointcloud message as a bytestring
src.sim.apolloEncode.encode_POmsgs(objCount, objIDs, objType, objHeadings, objLats, objLons, objutmx, objutmy, objVelXs, objVelYs, objBBxs, objBBys, objBBzs, t, seq)
Package and serialize actor snapshot data from the simulator into Apollo's Perception Obstacle message
Parameters:
-
objCount
(int
) –Number of objects/obstacles in current simulation snapshot
-
objIDs
(list
) –Unique identifier assigned to each object/obstacle
-
objType
(string
) –Type of object (vehicle, pedestrian, cones etc.)
-
objHeadings
(float
) –Heading of each object
-
objLats
(float
) –Latitude of each object
-
objLons
(float
) –Longitude of each object
-
objutmx
(float
) –UTM X-coordinate of each object
-
objutmy
(float
) –UTM Y-coordinate of each object
-
objVelXs
(float
) –Velocity of each object in the X-axis
-
objVelYs
(float
) –Velocity of each object in the Y-axis
-
objBBxs
(float
) –Bounding box dimension of each object in the X-axis
-
objBBys
(float
) –Bounding box dimension of each object in the Y-axis
-
objBBzs
(float
) –Bounding box dimension of each object in the Z-axis
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns: Perception Obstacles message as a bytestring
src.sim.apolloEncode.encode_Posemsgs(lat, lon, utmx, utmy, qw, qx, qy, qz, velx, vely, heading, avelX, avelY, avelZ, accX, accY, accZ, t, seq)
Package and serialize ego vehicle pose from the simulator to Apollo's format
Parameters:
-
lat
(float
) –Latitude
-
lon
(float
) –Longitude
-
utmx
(float
) –UTM X-coordinate
-
utmy
(float
) –UTM Y-coordinate
-
qw
(float
) –Quaternion W
-
qx
(float
) –Quaternion X
-
qy
(float
) –Quaternion Y
-
qz
(float
) –Quaternion Z
-
velx
(float
) –Velocity in X-axis
-
vely
(float
) –Velocity in Y-axis
-
heading
(float
) –Heading
-
avelX
(float
) –Angular velocity in X-axis
-
avelY
(float
) –Angular velocity in Y-axis
-
avelZ
(float
) –Angular velocity in Z-axis
-
accX
(float
) –Acceleration in X-axis
-
accY
(float
) –Acceleration in Y-axis
-
accZ
(float
) –Acceleration in Z-axis
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns:
-
–
Pose message as a bytestring
src.sim.apolloEncode.encode_Tfmsgs(utmx, utmy, eulx, euly, eulz, t, seq)
Package and serialize ego vehicle transform from the simulator to Apollo's format
Parameters:
-
utmx
(float
) –UTM X-coordinate
-
utmy
(float
) –UTM Y-coordinate
-
eulx
(float
) –Euler angle in the X-axis
-
euly
(float
) –Euler angle in the Y-axis
-
eulz
(float
) –Euler angle in the Z-axis
-
t
(float
) –Timestamp
-
seq
(int
) –Sequence number
Returns:
-
–
Transform message as a bytestring
src.sim.apolloEncode.encode_corrIMUmsgs(avelX, avelY, avelZ, eulX, eulY, eulZ, accX, accY, accZ, heading, t)
Package and serialize ego vehicle Corrected IMU data from the simulator to Apollo's format
Parameters:
-
avelX
(float
) –Angular velocity in the X-axis
-
avelY
(float
) –Angular velocity in the Y-axis
-
avelZ
(float
) –Angular velocity in the Z-axis
-
eulX
(float
) –Euler angle in the X-axis
-
eulY
(float
) –Euler angle in the Y-axis
-
eulZ
(float
) –Euler angle in the Z-axis
-
accX
(float
) –Acceleration in the X-axis
-
accY
(float
) –Acceleration in the Y-axis
-
accZ
(float
) –Acceleration in the Z-axis
-
heading
(float
) –Heading (yaw)
-
t
(float
) –Timestamp
Returns:
-
–
Corrected IMU message as a bytestring
Bridge Server
The bridge server for the reference Carla-Apollo bridge runs inside the Baidu Apollo Docker environment.
apolloBridgeServer.py
src.ads.apolloBridgeServer.Server(host, port)
Main bridge server class file with host and port definitions
Parameters:
-
host
(string
) –IP of the bridge server, typically '127.0.0.1' (but if Carla is running on another machine, give an IP on the same subnet)
-
port
(int
) –Port of the bridge server, typically 9999
src.ads.apolloBridgeServer.Server.start()
Start the server, accept connections from clients and assign them to handlers (each on a different process)
src.ads.apolloBridgeServer.ccHandler(server, conn, addr, prID)
Handler for control command messages to be published to the simulator
src.ads.apolloBridgeServer.connHandler(server, conn, addr, prID, initmsgType)
Connection handler for subscribed messages from the simulator
cyberWriter.py
src.ads.cyberWriter.CyberWriter(nodeName, msgDict)
Initialize CyberWriter object
Parameters:
-
nodeName
(string
) –Name of the CyberRT node to write the message into
-
msgDict
(dict
) –Dictionary containing the message channel and type of message
src.ads.cyberWriter.CyberWriter.makeWriter()
Create a CyberRT node and create a writer to it
src.ads.cyberWriter.CyberWriter.writeMessage(binMsg, msgType, msgLen)
Write the binary message into the CyberRT node using the previously created writer
Parameters:
-
binMsg
(bytestring
) –Bytestring message received from the simulator
-
msgType
–Message type from the dictionary which stores all message channels and types
-
msgLen
(int
) –Length of the message
cyberReader.py
src.ads.cyberReader.cReader()
Initialize CyberReader object
src.ads.cyberReader.cReader.callback(data)
Callback function to get control command messages from CyberRT
src.ads.cyberReader.cReader.encodeBinMsg(msg)
Function to encode the control commands to binary for sending to the simulator
Parameters:
-
msg
–Control command message
src.ads.cyberReader.cReader.makeReader()
Function to create a CyberRT reader and assign the previously defined callback function to it
src.ads.cyberReader.cReader.readMsgList(clearFlag=True)
Thread locked function to read the control commands and control command list before sending to the simulator
Parameters:
-
clearFlag
(bool
, default:True
) –Flag to indicate if the backlog of contol commands have been cleared or not