CoreSimNet.h#
ROS/acres_core_sim/include/acres_core_sim/CoreSimNet.h Generated
The game's local transports, served: a TCP port on 127.0.0.1 with one client at a time (a second client waits in the listen backlog until the first disconnects), as the game's sensor stream (AcresSensorStream.h), RL / DBW bridge (AcresRlBridge.h) and simulator-control channel (AcresSimControl.h) are. acres_sim's clients (stream.hpp) connect to it unchanged.
Each port has an I/O thread (accept, then read until the client closes) and a sender thread, so a slow client never blocks the simulation: output is queued, and above MaxQueuedBytes droppable frames (LiDAR clouds) are dropped and counted, as the game's stream drops them. Input lines are stamped with CLOCK_MONOTONIC at arrival (the command timing of AcresCommandTiming.h needs it); Drain() reads what the socket holds right now on the caller's thread, so a line a client wrote before a request on another port is handled before that request (loopback delivers into the receive buffer before send() returns).
Also the stream's frame encoder (32-byte header "TSS1": type, flags, sequence, payload bytes, stamp, publish time).
MonotonicS#
CLOCK_MONOTONIC in seconds (the clock of the stream's publish stamps and of the arrival stamps).
EncodeFrame#
Encodes one stream frame: header ("TSS1", type, flags 0, sequence, payload bytes, stamp, CLOCK_MONOTONIC now) and payload.
| Argument | Description |
|---|---|
Type |
Frame type. |
Sequence |
Per-stream sequence number (all types). |
StampS |
Simulation time of the data, s. Head, HeadBytes: Leading payload bytes (the LiDAR sub-header), may be null. Body, BodyBytes: Payload body. |
Returns: The frame's bytes.
FLine#
A received line and its arrival time.
FServedPort#
One served port. See the file comment.
FServedPort::size_t#
Queued output above which droppable frames are dropped, bytes (the game's FAcresSensorStream::MaxQueuedBytes).
FServedPort::Open#
Binds 127.0.0.1:Port and listens.
| Argument | Description |
|---|---|
Port |
TCP port (1-65535). |
Name |
For the log ("control", "stream polaris", ...). |
Error |
Why it failed. |
Returns: False when the port cannot be bound (in use).
FServedPort::Start#
Starts the threads.
| Argument | Description |
|---|---|
bReadLines |
Collect newline-delimited input lines (JSON ports); else input is read and discarded. |
OnConnect |
Called on the I/O thread when a client connects; what it returns is queued first (the stream's hello frame, the control channel's episode event), before anything the simulation queues later. |
Wake |
Notified whenever a line arrives (the simulation loop waits on it). |
FServedPort::Stop#
Stops the threads and closes the sockets.
FServedPort::Send#
Queues bytes for the connected client (dropped when none is connected).
| Argument | Description |
|---|---|
Bytes |
The data (moved). |
bDroppable |
May be dropped when the client lags (above MaxQueuedBytes). |
Returns: False when nothing is connected or the frame was dropped.
FServedPort::Drain#
Reads whatever the socket holds now (non-blocking) into the line queue.
FServedPort::TakeLines#
Takes the lines received so far.
FServedPort::Connected#
A client is connected; connections so far; the port.
FServedPort::Flush#
Waits until everything queued before the call has been written to the socket (or the client is gone).
FServedPort::Dropped#
Frames dropped so far.
FServedPort::QueuedBytes#
Output bytes queued and not yet written.
EStreamFrame#
Stream frame types (AcresSensorStream.h EFrame).
| Value | Description |
|---|---|
FrameHello |
|
FrameClock |
|
FrameIns |
|
FrameLidar |
|
FrameCamera |
|
FrameBarrier |