raisin::tcp_viewer
namespace
Classes
structBodyFramePose — One body frame in world coordinates, independent of its visual geometry offsets.structBufferReader — Lightweight reader for binary message buffers.structBufferWriter — Lightweight writer for binary message buffers.structClientRequest — A single pending client request to be flushed on the next update.structContactSample — Contact sample for contact visualization.structDeformableMesh — Dynamic triangle mesh data for a deformable object.structHeightmapMeshData — CPU geometry produced for a heightmap received by the TCP viewer.structHeightmapPlane — Heightmap plane data for mesh updates.structInstancedEntry — State associated with a remote instanced visual set.structObjectListItem — Entry for selectable object list UI.structPendingSensorUpdate — Pending sensor update to be applied on the viewer side.structRemotePointCloud — State associated with a remote point cloud.classRemoteScene — Client-side representation of a remote raisim scene.structRemoteSceneState — Persistent client-side state mirrored from the remote server.structSceneFileBlock — The scene-file block of one server response.structSceneFileEntry — One file of the server's scene.classSceneSync — Finds, downloads and loads the server's scene for one viewer connection.structSelectedActuatorInfo — 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…structSelectedObjectInfo — Details about a selected object from the remote scene.structSensorInfo — Metadata for a remote sensor.classTcpClient — Cross-platform TCP client for the Rayrai/RaisimServer protocol.structTcpMeshBatch — Instanced mesh batch synthesized from repeated TCP visual entries.structViewerCommand — A server-originated command that must be completed by the viewer application.structVisualEntry — State associated with a remote visual object.structVisualEntrySnapshot — Copy of a VisualEntry together with its object tag and body index.
Enumerations
ClientMessageType
#include <rayrai/TcpProtocolMessages.hpp>
enum class ClientMessageType : intViewer-to-server message type; mirrors RaisimServer::ClientMessageType.
| Enumerator | Value |
|---|---|
REQUEST_UPDATE | 0 |
REQUEST_SENSOR_UPDATE |
ServerSceneMessageType
#include <rayrai/TcpProtocolMessages.hpp>
enum class ServerSceneMessageType : intServer-to-viewer scene message type; mirrors RaisimServer::ServerMessageType.
| Enumerator | Value |
|---|---|
UPDATE_ALL | 0 |
NO_MESSAGE | 1 |
ServerRequestType
#include <rayrai/TcpProtocolMessages.hpp>
enum class ServerRequestType : intCommand the server asks the viewer to perform (recording, camera, window size).
| Enumerator | Value |
|---|---|
NO_REQUEST | 0 |
START_RECORD_VIDEO | 1 |
STOP_RECORD_VIDEO | 2 |
FOCUS_ON_SPECIFIC_OBJECT | 3 |
SET_CAMERA_TO | 4 |
GET_SCREEN_SHOT | 5 |
SET_SCREEN_SIZE | 6 |
ServerStatus
#include <rayrai/TcpProtocolMessages.hpp>
enum class ServerStatus : intServer state sent with every update; TERMINATING makes the viewer disconnect.
| Enumerator | Value |
|---|---|
STATUS_RENDERING | 0 |
STATUS_HIBERNATING | 1 |
STATUS_TERMINATING | 2 |
ClientRequestType
#include <rayrai/TcpProtocolMessages.hpp>
enum class ClientRequestType : intMirror 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.
| Enumerator | Value |
|---|---|
CR_SPAWN_BOX | 0 |
CR_SPAWN_SPHERE | 1 |
CR_SPAWN_CYLINDER | 2 |
CR_SPAWN_CAPSULE | 3 |
CR_SPAWN_HEIGHT_MAP | 4 |
CR_SPAWN_MESH | 5 |
CR_SPAWN_PLANE | 6 |
CR_SPAWN_AS | 7 |
CR_ATTACH_WIRE | 8 |
CR_DRAG_OBJECT | 9 |
CR_REMOVE_OBJECT | 10 |
CR_SAVE_THE_WORLD | 11 |
CR_PAUSE | 100 |
CR_RESUME | 101 |
CR_STEP_N | 102 |
CR_APPLY_FORCE | 103 |
CR_APPLY_TORQUE | 104 |
CR_SET_POSE | 105 |
CR_SET_GC | 106 |
CR_SCENE_MANIFEST | 200 |
CR_SCENE_FILE_CHUNK | 201 |
SpawnBodyType
#include <rayrai/TcpProtocolMessages.hpp>
enum class SpawnBodyType : int32_tBody type encoding shared with RaisimServer::commitSpawnRequest().
| Enumerator | Value |
|---|---|
Dynamic | 0 |
Kinematic | 1 |
Static | 2 |
ViewerCommandType
#include <rayrai/TcpRemoteSceneState.hpp>
enum class ViewerCommandTypeKind of server-originated ViewerCommand.
| Enumerator |
|---|
StartRecording |
StopRecording |
Screenshot |
SetWindowSize |
Functions
isLoopbackAddress
#include <rayrai/RaisimTcpCommon.hpp>
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
| Parameter | Description |
|---|---|
address | Address bytes in network order. |
size | 4 for IPv4, 16 for IPv6; any other size is not a loopback address. |
Returns False for a null address.
sendUpdateRequest
#include <rayrai/RaisimTcpCommon.hpp>
bool sendUpdateRequest(
TcpClient &client,
uint32_t objectId,
const std::vector<ClientRequest> &controlRequests={})Send a single update request for an object.
Parameters
| Parameter | Description |
|---|---|
client | TCP client instance. |
objectId | Object tag to request. |
controlRequests | Optional 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>
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
| Parameter | Description |
|---|---|
client | TCP client instance. |
pending | Pending sensor updates to send. |
nextSensorIndex | Rotation 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>
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
| Parameter | Description |
|---|---|
pending | Updates to encode (all of them). |
payload | Output 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>
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
| Parameter | Description |
|---|---|
heightmap | Received heightmap. |
meshData | Output; reset on entry. |
worldTiledUv | Tile 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>
bool isKnownServerSceneMessageType(int rawType)True if rawType is a ServerSceneMessageType value.
isSpawnClientRequest
#include <rayrai/TcpProtocolMessages.hpp>
bool isSpawnClientRequest(ClientRequestType type)True for the eight CR_SPAWN_* requests.
isFileSpawnClientRequest
#include <rayrai/TcpProtocolMessages.hpp>
bool isFileSpawnClientRequest(ClientRequestType type)True for the spawn requests whose geometry is loaded from a server-side file.
isSimControlClientRequest
#include <rayrai/TcpProtocolMessages.hpp>
bool isSimControlClientRequest(ClientRequestType type)True for requests the server only honours with PROTOCOL_FEATURE_SIM_CONTROL.
isSceneFileClientRequest
#include <rayrai/TcpProtocolMessages.hpp>
bool isSceneFileClientRequest(ClientRequestType type)True for the requests of a scene download (PROTOCOL_FEATURE_SCENE_FILES).
writeClientRequest
#include <rayrai/TcpProtocolMessages.hpp>
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>
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>
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>
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>
constexpr size_t kClientRequestSizeSlotsNumber of size slots the height-map spawn payload uses; the widest request.
kDefaultPort
#include <rayrai/TcpProtocolReader.hpp>
constexpr int kDefaultPortDefault 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>
constexpr int kProtocolVersionProtocol version for compatibility checks.
kProtocolFeatureExplicitHeader
#include <rayrai/TcpProtocolReader.hpp>
constexpr uint64_t kProtocolFeatureExplicitHeaderFeature 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>
constexpr uint64_t kProtocolFeatureDeformableDeltaFeature bit for deformable-object delta updates (wire format).
kProtocolFeatureSimControl
#include <rayrai/TcpProtocolReader.hpp>
constexpr uint64_t kProtocolFeatureSimControlNegotiates 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>
constexpr uint64_t kProtocolFeatureContactObjectTagsAdds both participating object tags to every streamed contact sample.
kProtocolFeatureActuatorState
#include <rayrai/TcpProtocolReader.hpp>
constexpr uint64_t kProtocolFeatureActuatorStateAppends the actuators (motor operating region and state) of a selected articulated system.
kProtocolFeatureSceneFiles
#include <rayrai/TcpProtocolReader.hpp>
constexpr uint64_t kProtocolFeatureSceneFilesAdds 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>
constexpr uint64_t kProtocolFeatureBodyFrameOffsetsBody-relative visual position/wxyz rotation in articulated/compound initialization records.
kProtocolSupportedFeatures
#include <rayrai/TcpProtocolReader.hpp>
constexpr uint64_t kProtocolSupportedFeaturesEvery feature bit this viewer understands; sent in its requests.
kMaxMessageBytes
#include <rayrai/TcpProtocolReader.hpp>
constexpr int kMaxMessageBytes