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