# Brizo: URDF fish to controlled simulation

> Documentation version: 3.0
> HTML: https://docs.flarelive.manifolddynamics.com/manual/tutorials/brizo/
> [Complete contents](https://docs.flarelive.manifolddynamics.com/contents.md) · [Agent index](https://docs.flarelive.manifolddynamics.com/llms.txt)

This tutorial builds a scene from URDF, drives three joints with phase-shifted sine commands and records motion. You need Flare Live, Python 3.10+ and the supplied [Python client](https://docs.flarelive.manifolddynamics.com/manual/operation/rpc.md).

The Brizo model has not been publicly released, so a model download is not currently available.

If you already have the model, download [brizo_servo_rpc.py](https://docs.flarelive.manifolddynamics.com/examples/brizo/brizo_servo_rpc.py) and place the `brizo_urdf` package beside it. The package contains `package.xml`, a four-link URDF and its STL meshes; ROS is optional.

![Brizo's articulated body and visible wake in the tracked top camera after a short servo trial.](https://docs.flarelive.manifolddynamics.com/examples/brizo/preview.png)

## 1. Start a simulator

Use a separate headless instance for this tutorial. The script replaces that instance's current scene.

In **terminal A**, open the tutorial folder. On Windows PowerShell, use the CLI path from your installation:

```powershell
& 'C:\Tools\FlareLive\bin\flare-live-cli.exe' serve
```

On Linux:

```sh
/path/to/FlareLive.AppImage --cli serve
```

Replace the AppImage path with your downloaded file. Keep terminal A open.

You can instead use an open GUI after saving your work, stopping Simulation and ending any Experiment.

## 2. Run the script

Open **terminal B** in the same tutorial folder. Complete [client installation](https://docs.flarelive.manifolddynamics.com/manual/operation/rpc.md#install-the-client) there and activate its environment. The script connects to the running instance automatically:

```sh
python brizo_servo_rpc.py
```

The settings at the top of the script specify the URDF directory, output folder, duration and sine-wave parameters. The script imports and places the robot, creates its drives/sensors/Cameras, configures the fluid and initializes. The short run should finish near **2.000 simulated seconds** and print the results folder.

## 3. Inspect the results

```text
brizo-output/
├── trajectory.csv
└── export/
    └── <run-series>/
        └── camera_views/
            ├── Brizo side/
            └── Brizo top/
```

The CSV contains:

- `time_s`: actual simulated time.
- `target_link1_deg`, `target_link2_deg`, `target_lin3_deg`: commanded angles in degrees.
- Corresponding `actual_..._deg` columns: measured joint angles.
- Body position in meters (`x_m, y_m, z_m`).

The source calls its third joint **lin3**. Open the CSV in a spreadsheet or plotting tool and compare target/measured angles. The first half-second smoothly ramps up the sine motion; the three joints should oscillate with successive phase delays.

Each Camera directory receives an initial and final PNG. Compare them for articulation and inspect the wake. This short trial checks scene construction, actuation, feedback and rendering. Assess propulsion using longer runs and an otherwise identical neutral-command trial.

## 4. Adjust or save the experiment

The script leaves Simulation paused for inspection. To run a longer trial, Stop Simulation, change `DURATION` to `60.0` at the top of the script, then run it again. It creates a fresh scene each time. Set `AMPLITUDES = [0, 0, 0]` for a neutral-command comparison. Rerunning overwrites `trajectory.csv` and creates a new image-export series.

To save the configured preparation in a GUI, choose **Simulation > Stop**, then **File > Save as...**. Stop discards the simulated pose and keeps the imported/configured Document. In a headless client use `clear_simulation()`, then `save_world(absolute_fll_path)`. Finish an owned headless session with Ctrl+C in terminal A.

The tutorial rebuilds the scene to show the import and configuration steps. For repeated experiments on a larger scene, save that configured Document once, then use `open_world` in later RPC scripts and configure only the trial parameters.

## What the script configures

| Setting | Value and purpose |
| --- | --- |
| Fluid | Gen 2, density 1000 kg/m³, kinematic viscosity 1e−6 m²/s, still water. |
| Grid and velocity scale | 0.01 m cells and 2 m/s maximum velocity; step size 0.005 s in this setup. |
| Wall model | Capped Navier slip, 2 cells, maximum slip ratio 0.8, NormalSide. |
| Drives | One Simple Servo per revolute joint; shared model with 30° maximum angle, 1 N·m torque and 360°/s speed. |
| Controller | Kp 30, Ki 0, Kd 0.05. These demonstration gains can be tuned using the angle feedback. |
| Motion | X/Y translation and yaw allowed; Z/roll/pitch constrained; gravity zero. |
| Command | 1 Hz; 8°, 12°, 18° amplitudes; successive 60° phase lags. Servo inputs divide each requested angle by its model's maximum angle. |
| Observation | Position-mode Joint Sensors, Body Info, tracked side/top Cameras. |

This setup isolates planar swimming motion. For a freely moving 3D experiment, configure gravity/buoyancy, mass/inertia and constraints for that experiment.

## Rebuild the scene manually

1. Choose **File > Import > URDF robot or ROS package** and select `brizo_urdf` or its URDF.
2. Select the resulting Robot preset in Presets, turn **Fixed base** off and click **Add to scene**.
3. Inspect the four physical links and three revolute joints. The visual meshes carry FluidBoundary; collision-only copies serve rigid contact.
4. Add a Simple Servo and a Position-mode Joint Sensor under each driven joint, using the model values above.
5. Add Body Info under the root, then configure fluid and root constraints.

Follow [URDF import](https://docs.flarelive.manifolddynamics.com/manual/assets/urdf.md), [drives](https://docs.flarelive.manifolddynamics.com/manual/rigid-bodies/drives.md) and [fluid setup](https://docs.flarelive.manifolddynamics.com/manual/fluids/setup.md) for each step's properties. Imported geometry and materials are embedded when you save the project.
