Examples

Overview

The raisim2Lib distribution ships C++ example sources and prebuilt RaiSim and rayrai libraries. Build the examples with CMake; the install target does not copy those source-built executables or provide a prebuilt TCP viewer. The rayrai_tcp_viewer target builds the viewer from this repository’s sources. Use server examples such as primitive_grid, rayrai examples such as rayrai_pbr_material_grid, and non-visual tools such as model_asset_pipeline to exercise RaiSim physics APIs, mesh import/export, OpenUSD mesh loading, and rayrai asset inspection. Use rayrai_tcp_viewer to inspect applications that publish a raisim::World through raisim::RaisimServer. RaisimUnity and RaisimUnreal are no longer supported.

Overview of RaiSim and rayrai examples

Run

After the top-level build from Build, Test, and Benchmark, run examples from the build tree:

./build-examples/examples/primitive_grid
./build-examples/examples/rayrai_pbr_material_grid

On Windows, use the .exe executable from build-examples\\bin:

.\build-examples\bin\primitive_grid.exe

If the runtime loader cannot find shared libraries, use the platform-specific environment setup before running examples:

source /path/to/raisim2Lib/raisim_env.sh

This script sets LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH on macOS.

.\raisim_env.ps1
raisim_env.bat

Visualization modes

There are two visualization paths. See Visualization for the full workflow comparison.

RaisimServer examples

Server examples such as primitive_grid create a RaiSim world and publish it through raisim::RaisimServer. They do not open a renderer window themselves. Start the source-built viewer, then run the server example:

# Terminal 1
./build-examples/examples/rayrai_tcp_viewer

# Terminal 2
./build-examples/examples/primitive_grid

The default server port is 8080 unless the example changes it. Use this path when you want to inspect the same simulation data that a normal RaisimServer application publishes.

Rayrai examples

Examples such as rayrai_pbr_material_grid, rayrai_pbr_texture_maps, and rayrai_visual_asset_support create or use a raisin::RayraiWindow directly and render in process. They do not need the TCP viewer:

./build-examples/examples/rayrai_pbr_material_grid

Prefer these examples when you need camera images, GPU/offscreen rendering, PBR materials, glTF visual import, or standalone rayrai feature inspection. USD visual meshes can also be loaded through RayraiWindow::addVisualMesh; see OpenUSD Loading for the importer scope.

Non-visual examples

Some examples are intended to print output or create files rather than show a window. model_asset_pipeline writes preprocessed and exported OBJ files to /tmp/raisim_model_asset_pipeline_example.

Example layout

The examples project groups targets by executable behavior:

Group

Purpose

Server examples

Build targets for RaiSim physics, contact, terrain, sensor, robot, XML/MJCF, and OpenUSD scene workflows.

rayrai_*

rayrai tools and standalone renderer examples.

Choosing an example

Start with these targets when learning a specific feature:

Target

Demonstrates

primitive_grid

Basic rigid primitive creation and RaisimServer publishing.

model_asset_pipeline

Mesh preprocessing, content-hash cache reuse, addMesh with processed assets, and OBJ export from a world.

shadow_hand_usd_cube

Loading an OpenUSD ShadowHand scene through World(shadow_hand.usd) with a textured cube visual and publishing it through RaisimServer.

nvidia_usd_robots

Loading vetted NVIDIA Isaac Sim robot USD scenes through the World constructor and publishing them through RaisimServer.

rayrai_pbr_material_grid

Inspecting metallic-roughness PBR material behavior under rayrai.

rayrai_visual_asset_support

Rendering textured URDF visual meshes (OBJ/DAE with image textures) separately from their collision geometry.

rayrai_coacd_mesh_approximation

Visually comparing original meshes and CoACD convex approximation parts generated through World::addMesh. The first run can take a few minutes while CoACD generates and caches the parts.

rayrai_tcp_viewer

The TCP visualizer used by RaisimServer examples.

tendon_elastic, tendon_pulleys, tendon_coupling

Elastic suspensions, routed guides/pulley branches, and joint transmissions. See Tendon examples and Rayrai.

rayrai_tendons

Automatic tendon rendering with scene selection, pause/step/reset, and live transmission values. See Tendons.

rayrai_forest

Dense instanced vegetation on a heightmap with automatic mesh LOD, foliage wind and shadows, and asynchronous loading. Requires the upcoming rayrai release; see Rayrai Example: Forest.

Runtime assets

Some targets depend on bundled assets or platform runtime packages:

  • OpenUSD loading uses the package’s bundled OpenUSD runtime and USD files; keep the openusd runtime directory and rsc assets with the installed package.

  • Rayrai examples require SDL2/OpenGL and rayrai runtime libraries. See Platform support for the OpenGL requirements and the reduced macOS feature set.

  • Poly Haven and PBR asset examples require the corresponding assets under rsc. CMake copies rsc next to the executables (build-examples/examples/rsc, or build-examples/bin/rsc on Windows).

  • rayrai_forest reads its assets from rsc/forest in the configured checkout and writes regenerable rayrai_cache_*.lods files beside them.

  • rayrai_coacd_mesh_approximation writes raisim_coacd_* cache files beside the YCB meshes in the build tree’s rsc copy.

After building, list the example executables from the platform-specific output directory. Linux and macOS builds place them under examples:

ls build-examples/examples/

Windows builds place them under bin:

Get-ChildItem .\build-examples\bin\*.exe

Current Package Examples

Benchmark Examples

Rayrai Tools And Examples

Server Examples

XML Examples