Skip to content

raisin::tcp_viewer ​

namespace

Classes ​

  • struct BodyFramePose — One body frame in world coordinates, independent of its visual geometry offsets.
  • struct BufferReader — Lightweight reader for binary message buffers.
  • struct BufferWriter — Lightweight writer for binary message buffers.
  • struct ClientRequest — A single pending client request to be flushed on the next update.
  • struct ContactSample — Contact sample for contact visualization.
  • struct DeformableMesh — Dynamic triangle mesh data for a deformable object.
  • struct HeightmapMeshData — CPU geometry produced for a heightmap received by the TCP viewer.
  • struct HeightmapPlane — Heightmap plane data for mesh updates.
  • struct InstancedEntry — State associated with a remote instanced visual set.
  • struct ObjectListItem — Entry for selectable object list UI.
  • struct PendingSensorUpdate — Pending sensor update to be applied on the viewer side.
  • struct RemotePointCloud — State associated with a remote point cloud.
  • class RemoteScene — Client-side representation of a remote raisim scene.
  • struct RemoteSceneState — Persistent client-side state mirrored from the remote server.
  • struct SceneFileBlock — The scene-file block of one server response.
  • struct SceneFileEntry — One file of the server's scene.
  • class SceneSync — Finds, downloads and loads the server's scene for one viewer connection.
  • struct SelectedActuatorInfo — An actuator (a motor with its gear) of a selected articulated system: what defines its motor's operating region (raisim::ActuatorDefinition) and its state over the last simulation step…
  • struct SelectedObjectInfo — Details about a selected object from the remote scene.
  • struct SensorInfo — Metadata for a remote sensor.
  • class TcpClient — Cross-platform TCP client for the Rayrai/RaisimServer protocol.
  • struct TcpMeshBatch — Instanced mesh batch synthesized from repeated TCP visual entries.
  • struct ViewerCommand — A server-originated command that must be completed by the viewer application.
  • struct VisualEntry — State associated with a remote visual object.
  • struct VisualEntrySnapshot — Copy of a VisualEntry together with its object tag and body index.

Enumerations ​

ClientMessageType ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
enum class ClientMessageType : int

Viewer-to-server message type; mirrors RaisimServer::ClientMessageType.

EnumeratorValue
REQUEST_UPDATE0
REQUEST_SENSOR_UPDATE

ServerSceneMessageType ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
enum class ServerSceneMessageType : int

Server-to-viewer scene message type; mirrors RaisimServer::ServerMessageType.

EnumeratorValue
UPDATE_ALL0
NO_MESSAGE1

ServerRequestType ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
enum class ServerRequestType : int

Command the server asks the viewer to perform (recording, camera, window size).

EnumeratorValue
NO_REQUEST0
START_RECORD_VIDEO1
STOP_RECORD_VIDEO2
FOCUS_ON_SPECIFIC_OBJECT3
SET_CAMERA_TO4
GET_SCREEN_SHOT5
SET_SCREEN_SIZE6

ServerStatus ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
enum class ServerStatus : int

Server state sent with every update; TERMINATING makes the viewer disconnect.

EnumeratorValue
STATUS_RENDERING0
STATUS_HIBERNATING1
STATUS_TERMINATING2

ClientRequestType ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
enum class ClientRequestType : int

Mirror of raisim::RaisimServer::ClientRequestType.

The values below 100 are the legacy scene-editing requests; 100 to 106 are gated behind PROTOCOL_FEATURE_SIM_CONTROL and 200 and 201 behind PROTOCOL_FEATURE_SCENE_FILES. rayrai_protocol_mirror_consistency_test static_asserts every value against the server header.

EnumeratorValue
CR_SPAWN_BOX0
CR_SPAWN_SPHERE1
CR_SPAWN_CYLINDER2
CR_SPAWN_CAPSULE3
CR_SPAWN_HEIGHT_MAP4
CR_SPAWN_MESH5
CR_SPAWN_PLANE6
CR_SPAWN_AS7
CR_ATTACH_WIRE8
CR_DRAG_OBJECT9
CR_REMOVE_OBJECT10
CR_SAVE_THE_WORLD11
CR_PAUSE100
CR_RESUME101
CR_STEP_N102
CR_APPLY_FORCE103
CR_APPLY_TORQUE104
CR_SET_POSE105
CR_SET_GC106
CR_SCENE_MANIFEST200
CR_SCENE_FILE_CHUNK201

SpawnBodyType ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
enum class SpawnBodyType : int32_t

Body type encoding shared with RaisimServer::commitSpawnRequest().

EnumeratorValue
Dynamic0
Kinematic1
Static2

ViewerCommandType ​

#include <rayrai/TcpRemoteSceneState.hpp>

cpp
enum class ViewerCommandType

Kind of server-originated ViewerCommand.

Enumerator
StartRecording
StopRecording
Screenshot
SetWindowSize

Functions ​

isLoopbackAddress ​

#include <rayrai/RaisimTcpCommon.hpp>

cpp
bool isLoopbackAddress(const unsigned char *address, size_t size)

Whether an IP address is this computer's loopback address: 127.0.0.0/8, ::1 or an IPv4-mapped 127.x.y.z (TcpClient::peerIsLoopback()).

Parameters

ParameterDescription
addressAddress bytes in network order.
size4 for IPv4, 16 for IPv6; any other size is not a loopback address.

Returns False for a null address.

sendUpdateRequest ​

#include <rayrai/RaisimTcpCommon.hpp>

cpp
bool sendUpdateRequest(
    TcpClient &client,
    uint32_t objectId,
    const std::vector<ClientRequest> &controlRequests={})

Send a single update request for an object.

Parameters

ParameterDescription
clientTCP client instance.
objectIdObject tag to request.
controlRequestsOptional client requests to piggyback on this update. RaisimServer only honours CR_SAVE_THE_WORLD when it is the sole request in the frame, so callers must flush a world export on its own.

Returns True on successful send.

sendSensorUpdate ​

#include <rayrai/RaisimTcpCommon.hpp>

cpp
bool sendSensorUpdate(
    TcpClient &client,
    const std::vector<PendingSensorUpdate> &pending,
    size_t &nextSensorIndex)

Send a batch of pending sensor updates.

Sends as many entries as fit in RaisimServer's 32 MiB receive buffer. When not all fit, successive calls rotate the starting entry so every sensor is eventually sent.

Parameters

ParameterDescription
clientTCP client instance.
pendingPending sensor updates to send.
nextSensorIndexRotation state of this sender: the entry the batch starts from (modulo pending.size()). Advanced past the last entry sent. Keep one per connection, starting at 0.

Returns True on successful send.

buildSensorUpdatePayload ​

#include <rayrai/RaisimTcpCommon.hpp>

cpp
bool buildSensorUpdatePayload(
    const std::vector<PendingSensorUpdate> &pending,
    std::vector<char> &payload)

Build the client sensor-update payload; exposed for protocol tests and offline diagnostics.

Parameters

ParameterDescription
pendingUpdates to encode (all of them).
payloadOutput payload, without the frame-size header.

Returns False if an entry is invalid or the payload would exceed the server's buffer.

buildHeightmapMeshData ​

#include <rayrai/TcpHeightmapMesh.hpp>

cpp
bool buildHeightmapMeshData(
    const HeightmapPlane &heightmap,
    HeightmapMeshData &meshData,
    bool worldTiledUv=false)

Build the CPU-side render mesh for a remote heightmap.

Triangles containing NaN or infinite heights are omitted. Such heightmaps retain their source grid so every remaining source triangle is drawn. Resamples the heights onto the visual grid with the physics triangulation and computes normals and tangents. Texture coordinates span the heightmap once, for its streamed color map, or with worldTiledUv tile every 4 m of world XY like world heightmaps, for the renderer's heightmap terrain textures (RayraiWindow::applyHeightmapTerrainTextures()).

Parameters

ParameterDescription
heightmapReceived heightmap.
meshDataOutput; reset on entry.
worldTiledUvTile the texture coordinates in world space.

Returns False if the heightmap has fewer than 2 samples per axis or a height-count mismatch.

isKnownServerSceneMessageType ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
bool isKnownServerSceneMessageType(int rawType)

True if rawType is a ServerSceneMessageType value.

isSpawnClientRequest ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
bool isSpawnClientRequest(ClientRequestType type)

True for the eight CR_SPAWN_* requests.

isFileSpawnClientRequest ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
bool isFileSpawnClientRequest(ClientRequestType type)

True for the spawn requests whose geometry is loaded from a server-side file.

isSimControlClientRequest ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
bool isSimControlClientRequest(ClientRequestType type)

True for requests the server only honours with PROTOCOL_FEATURE_SIM_CONTROL.

isSceneFileClientRequest ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
bool isSceneFileClientRequest(ClientRequestType type)

True for the requests of a scene download (PROTOCOL_FEATURE_SCENE_FILES).

writeClientRequest ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
void writeClientRequest(BufferWriter &writer, const ClientRequest &request)

Append request in the wire format RaisimServer decodes.

Writes the int32 request type followed by the fields that type uses.

parseSceneFileBlock ​

#include <rayrai/TcpSceneSync.hpp>

cpp
bool parseSceneFileBlock(BufferReader &reader, SceneFileBlock &block)

Parse the scene-file block at the reader.

Messages tagged with another manifest id than the block's are dropped.

Returns false, with reader.ok cleared, for a malformed block.

normalizeServerPath ​

#include <rayrai/TcpSceneSync.hpp>

cpp
std::string normalizeServerPath(const std::string &path)

A server path in a comparable form: '/' separators, no "." or empty components and ".." folded, whatever the server's platform.

defaultSceneDirectory ​

#include <rayrai/TcpSceneSync.hpp>

cpp
std::filesystem::path defaultSceneDirectory()

Where viewers keep the scenes they download: ~/.raisim/scenes, with HOME or, on Windows, USERPROFILE as the home directory, else raisim/scenes in the temporary directory.

Variables ​

kClientRequestSizeSlots ​

#include <rayrai/TcpProtocolMessages.hpp>

cpp
constexpr size_t kClientRequestSizeSlots

Number of size slots the height-map spawn payload uses; the widest request.

kDefaultPort ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr int kDefaultPort

Default TCP port for the viewer protocol.

The current wire format is a native-endian binary protocol shared by RaisimServer and this viewer. Each TCP frame starts with an int32_t total frame size, including the 4-byte header. Strings in both directions (including sensor names in REQUEST_SENSOR_UPDATE) use int32_t byte-length prefixes.

kProtocolVersion ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr int kProtocolVersion

Protocol version for compatibility checks.

kProtocolFeatureExplicitHeader ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureExplicitHeader

Feature bits advertised by protocol 10021 and newer.

Mirrors RaisimServer::PROTOCOL_FEATURE_*. The viewer rejects a server update whose feature word carries any bit outside kProtocolSupportedFeatures.

kProtocolFeatureDeformableDelta ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureDeformableDelta

Feature bit for deformable-object delta updates (wire format).

kProtocolFeatureSimControl ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureSimControl

Negotiates interactive sim control. When both sides advertise this bit, the client may send CR_PAUSE / CR_RESUME / CR_STEP_N / CR_APPLY_FORCE / CR_APPLY_TORQUE / CR_SET_POSE / CR_SET_GC. There is no authentication – the bind address is the only access control (bind to loopback unless you trust the network).

kProtocolFeatureContactObjectTags ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureContactObjectTags

Adds both participating object tags to every streamed contact sample.

kProtocolFeatureActuatorState ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureActuatorState

Appends the actuators (motor operating region and state) of a selected articulated system.

kProtocolFeatureSceneFiles ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureSceneFiles

Adds a scene-file block after the server requests of every response and enables CR_SCENE_MANIFEST / CR_SCENE_FILE_CHUNK (see rayrai/TcpSceneSync.hpp).

kProtocolFeatureBodyFrameOffsets ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolFeatureBodyFrameOffsets

Body-relative visual position/wxyz rotation in articulated/compound initialization records.

kProtocolSupportedFeatures ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr uint64_t kProtocolSupportedFeatures

Every feature bit this viewer understands; sent in its requests.

kMaxMessageBytes ​

#include <rayrai/TcpProtocolReader.hpp>

cpp
constexpr int kMaxMessageBytes

RaiSim — physics for robotics and AI.