# Get Started

> Documentation version: 2.x (old)
> HTML: https://docs.flarelive.manifolddynamics.com/2.x/quickstart.html
> [Complete contents](https://docs.flarelive.manifolddynamics.com/2.x/contents.md) · [Agent index](https://docs.flarelive.manifolddynamics.com/2.x/llms.txt)

Welcome to use Flare Live, the real-time fluid simulation system for robotics.
The software is also a continuation to the prior work, [FishGym](https://github.com/fish-gym/gym-fish).

**If you have not installed Flare Live and have it run, please follow the instructions in [Installation & Activation](https://docs.flarelive.manifolddynamics.com/2.x/install.md) first.**

## Part I. Simulator

- The simulator uses **.fll files** to save the whole simulation scene.
- You can navigate over the world in a first-person view. **Holding right mouse button** anywhere in the scene view, use WASDQE to move, and slide your mouse to look around.
- You need to select the `Mode` on top of the window to `MessageControlled` in order to control the simulation from *Python* (see part III).
- Press `Run` to start the simulation.


## Part II. FLL File
See [sample scenes and controller examples](https://docs.flarelive.manifolddynamics.com/2.x/resources/samples.md#uav-scene-amovlab-p600) for the 2.x workflows. Downloadable current-version scenes are available in the [3.0 tutorials](https://docs.flarelive.manifolddynamics.com/manual/tutorials/index.md).

#### Editing scene
Edit simulator settings, scene objects and export settings in the GUI.

#### Run simulation
Select the `Mode` on top of the window to `FixedSpeed`, and click `Run` to run the simulation at a fixed speed, which is useful for debugging or testing.

For the UAV scene (P600), the UAV will takeoff and hover. However, you will find nothing moving on some other scenes, since there is no working actuator in the scene.

## Part III. Python Control Script
Python scripts can start, stop and reset simulation, edit scene parameters, apply inputs and read results.

For this archived 2.x workflow, install the 0.2.x series of flcpy. To run an older controller with Flare Live 3.0, follow the [migration guide](https://docs.flarelive.manifolddynamics.com/manual/migration/from-2x.md).

```shell
pip install "flcpy>=0.2,<0.3"
```

For the UAV example, a minimum Python control script looks like:

```python
import flcpy
import numpy as np

# Make sure the `Mode` is set to `MessageControlled` in the GUI
# And click `Run` to start listening for connections from Python.

# Connect to the simulation and retrieve object references
sim = flcpy.connect()
px4 = sim.get_object('p600/core/px4')
sensor = sim.get_object('p600/core/info')

# Define control frequency and duration
control_frequency = 30.0
duration = 20.0

# Start the simulation
sim.start()
t = 0.0

while (t < duration):
    # Set control input (e.g. run a controller)
    px4_input = (0.0, 0.0, 0.0, 1.0, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.sin(t), np.nan) # This is the input vector for build-in px4 controller

    # Execute simulation
    t += 1.0 / control_frequency
    reply = sim.simulate_until(t,  {px4: px4_input}, [sensor])

    if reply.is_failed():
        print('Simulation failed!')
        break
    else:
        body_state = reply.get_output_of(sensor)

        # Update flight controller, log or record...
        p_x = body_state[0]
        p_y = body_state[1]
        p_z = body_state[2]
        print(f'x: {p_x:.2f}, y: {p_y:.2f}, z: {p_z:.2f}')

# Clear the simulation and close the controller
sim.stop()
sim.close()
print("Done.")
```

After you start running the script, you should be able to view the simulation process with fluid visualizations in Flare Live GUI window.
