Examples
Overview
The RaiSim source package builds runnable C++ examples and rayrai tools. Use
server examples such as primitive_grid to exercise RaiSim physics APIs and
rayrai_* examples for in-process rendering, sensors, PBR assets, and rayrai
tools. Use rayrai_tcp_viewer to inspect applications that publish a
raisim::World through raisim::RaisimServer. RaisimUnity and
RaisimUnreal are no longer supported.
Build
Build examples from the raisim2Lib root. Source the environment first so
both RaiSim and rayrai shared libraries are visible:
source ./raisim_env.sh
cmake -S . -B build \
-DRAISIM_EXAMPLE=ON \
-DRAISIM_PY=ON
cmake --build build -j
RAISIM_EXAMPLE is enabled by default. RAISIM_PY is disabled by default,
so enable it when you want raisimPy.
Run
Run examples from the build tree:
source ./raisim_env.sh
./build/examples/primitive_grid
./build/examples/rayrai_basic_scene
On Windows, use the .exe executable from the build tree:
.\build\examples\Release\primitive_grid.exe
If the runtime loader cannot find shared libraries, use the platform-specific environment setup before running examples:
cd $HOME/raisim2Lib
source ./raisim_env.sh
This script sets LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH on macOS.
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 and atlas create a RaiSim world
and publish it through raisim::RaisimServer. They do not open a renderer
window themselves. Start the rayrai TCP viewer in one sourced terminal, then run
the example in another sourced terminal:
# Terminal 1
source ./raisim_env.sh
./build/examples/rayrai_tcp_viewer
# Terminal 2
source ./raisim_env.sh
./build/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_basic_scene, rayrai_complete_showcase,
rayrai_pbr_material_grid, and rayrai_pbr_texture_maps create or use a
raisin::RayraiWindow directly and render in process. They do not need the
TCP viewer:
source ./raisim_env.sh
./build/examples/rayrai_basic_scene
Prefer these examples when you need camera images, GPU/offscreen rendering, PBR materials, glTF visual import, or standalone rayrai feature inspection.
Non-visual examples
Some examples are intended to print output or create files rather than show a
window. object_lifecycle_stress runs headless, and
model_asset_pipeline writes preprocessed and exported mesh assets when the
installed RaiSim package exposes the asset-pipeline APIs.
Example layout
The build groups examples by executable behavior:
Group |
Purpose |
|---|---|
Server examples |
Examples that publish a world through |
|
rayrai tools and standalone renderer examples. |
Benchmarks |
Timing-oriented examples such as |
Choosing an example
Start with these targets when learning a specific feature:
Target |
Demonstrates |
|---|---|
|
Basic server-side simulation and visualization. |
|
Atlas contact simulation with RaisimServer publishing. |
|
Mesh preprocessing, content-hash cache reuse, |
|
Minimal in-process rayrai rendering. |
|
Broad rayrai feature overview with sensors and visuals. |
|
Inspecting bundled glTF PBR sample assets under rayrai lighting. |
|
PBR texture-map import and material inspection. |
|
Visually comparing original meshes and convexified collision modes
generated through |
|
The TCP visualizer used by RaisimServer examples. |
Optional targets
Some targets depend on optional assets or platform packages:
Rayrai examples require SDL2/OpenGL and rayrai runtime libraries.
PBR asset examples require the corresponding assets under
rsc.
List available examples by inspecting the build tree:
ls build/examples
Rayrai Tools
Server Examples
- Server Example: Compound Object
- Server Example: Deformable Objects
- Server Example: Dynamic Heightmap
- Server Example: Dynamic Object Addition
- Server Example: Dzhanibekov Effect
- granular_media
- Server Example: Heightmap From Png
- Server Example: Inverse Dynamics
- Server Example: Kinematic Platform
- Server Example: Length Constraints Newtons Cradle
- Server Example: Material Restitution
- Server Example: Material Static Friction
- Server Example: Mesh Stack
- Server Example: Minitaur PD
- mjcf_gymnasium_hopper
- mjcf_gymnasium_humanoid
- mjcf_gymnasium_walker2d
- Server Example: Model Asset Pipeline
- Server Example: Object Lifecycle Stress
- Server Example: Primitive Grid
- Server Example: Procedural Heightmap
- Server Example: Ray Casting
- Server Example: Ray Scan LiDAR
- Server Example: Spring Damper Joints
- Server Example: Templated Tracked Robot
- Server Example: Visual Objects Showcase
- Server Example: Wheeled Robot Force Control
- ycb_objects
- ANYmal Pair
- Atlas
- Hill1 Heightmap
- Kinova Arm
- Lake1 Heightmap
- Mountain1 Heightmap
- Office1 Scene
XML Examples
Rayrai Example Gallery
- Rayrai Example: Aruco Marker
- Rayrai Example: Basic Scene
- rayrai_blender_scene_import
- Rayrai Example: COACD Mesh Approximation
- Rayrai Example: Complete Showcase
- Rayrai Example: Custom Visuals
- Rayrai Example: Depth Camera
- rayrai_feature_showcase
- Rayrai Example: Instancing Grid
- Rayrai Example: LiDAR Pointcloud
- Rayrai Example: PBR Material Grid
- Rayrai Example: PBR Texture Maps
- Rayrai Example: Pointcloud Animation
- Rayrai Example: Quality Lighting and FXAA
- Rayrai Example: RGB Camera
- Rayrai Example: Runtime Scene Editing
- Rayrai Example: Swept CCD
- Rayrai Example: TCP Viewer
- rayrai_visual_asset_support