Skip to content

Commit 76f0351

Browse files
committed
Updated fluid tutorial
1 parent 779e9c9 commit 76f0351

File tree

1 file changed

+114
-56
lines changed

1 file changed

+114
-56
lines changed

fluids/tutorial.md

+114-56
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,54 @@
11
# Introduction
22

3-
The package allows the simulation of fluids in Gazebo. The fluid particle interactions are computed on the GPU
4-
using the [Fluidix](http://onezero.ca/documentation/) library (if a nvidia GPU is not available the simulation will run in CPU mode).
3+
**IMPORTANT: This is experimental.**
4+
5+
The package allows the simulation of fluids in Gazebo. The fluid particle
6+
interactions are computed on the GPU using the
7+
[Fluidix](http://onezero.ca/documentation/) library (if a nvidia GPU is not
8+
available the simulation will run in CPU mode).
59

610
**Prerequisites:**
711

8-
* Get the package from [bitbucket](https://bitbucket.org/ahaidu/gz_fluid).
9-
* Install [CUDA](https://developer.nvidia.com/cuda-downloads) (recommended 6.0).
10-
* Install [Fluidix](http://onezero.ca/documentation/).
11-
* Go through the basic Gazebo tutorials, especially through [world plugins](http://gazebosim.org/tutorials?tut=plugins_world), [system plugins](http://gazebosim.org/tutorials?tut=system_plugin), [transport library](http://gazebosim.org/tutorials?cat=transport) examples.
12+
* Nvidia graphics card
13+
* Go through the basic Gazebo tutorials, especially through [world plugins](http://gazebosim.org/tutorials?tut=plugins_world), [system plugins](http://gazebosim.org/tutorials?tut=system_plugin), [transport library](http://gazebosim.org/tutorials?cat=transport) examples.
1214
* For deeper understanding of the particle simulation look through some [Fluidix examples](http://onezero.ca/sample/?id=general_basic).
1315

16+
# Install
17+
18+
1. Install [CUDA](https://developer.nvidia.com/cuda-downloads) (recommended 6.0)
19+
20+
~~~
21+
sudo apt-get install nvidia-cuda-dev nvidia-cuda-toolkit
22+
~~~
23+
24+
1. Install [Fluidix](http://onezero.ca/downloads/)
25+
26+
Use the online form to get links to Fluidix
27+
28+
~~~
29+
mkdir /tmp/fluidix
30+
unzip ~/Downloads/Fluidix*.zip -d /tmp/fluidix
31+
cd /tmp/fluidix
32+
sudo ./install.sh
33+
~~~
34+
35+
1. Install [gz_fluid]( https://bitbucket.org/ahaidu/gz_fluid)
36+
37+
~~~
38+
cd /tmp
39+
git clone https://bitbucket.org/ahaidu/gz_fluid
40+
cd gz_fluid
41+
mkdir build
42+
cd build
43+
cmake ../
44+
make
45+
~~~
46+
1447
# How the package works
1548
16-
The fluid simulation runs as a separate physics engine which interacts with the rigid body physics engine of Gazebo through an interface (`include/FluidEngine.hh`).
49+
The fluid simulation runs as a separate physics engine which interacts with
50+
the rigid body physics engine of Gazebo through an interface
51+
(`include/FluidEngine.hh`).
1752
1853
The interaction includes:
1954
* collision detection
@@ -24,57 +59,80 @@ The core of the fluid simulation is written in the `src/FluidEngine.cu` cuda fil
2459
2560
The package contains two plugins, one world plugin for updating the fluid and its interactions (`FluidWorldPlugin.cc`). And one GUI system plugin for visualizing the fluid particles(`FluidVisPlugin.cc`).
2661
27-
## Build instructions
28-
29-
In a terminal go to the downloaded `gz_fluid` folder and run the following commands:
30-
31-
~~~
32-
mkdir build
33-
cd build
34-
cmake ..
35-
make
36-
~~~
37-
3862
## Running the plugin:
3963
40-
* Set the gazebo plugin and model paths
41-
~~~
42-
echo "export GAZEBO_PLUGIN_PATH=<install_path>/gz_fluid/build:${GAZEBO_PLUGIN_PATH}" >> ~/.bashrc
43-
echo "export GAZEBO_MODEL_PATH=<path>/gz_fluid/models:${GAZEBO_MODEL_PATH}" >> ~/.bashrc
44-
source ~/.bashrc
45-
~~~
46-
* Add the plugin to your custom world file, or use one of the examples from the package
47-
~~~
48-
<?xml version="1.0"?>
49-
<sdf version="1.5">
50-
<world name="fluid_world">
51-
...
52-
<plugin name="FluidWorldPlugin" filename="libFluidWorldPlugin.so">
53-
<world_position>0 0 5.01</world_position>
54-
<world_size>1.5 1 10</world_size>
55-
<fluid_position>-0.5 0.0 0.8</fluid_position>
56-
<fluid_volume>0.4 0.95 0.5</fluid_volume>
57-
<particle_nr>0</particle_nr>
58-
</plugin>
59-
60-
</world>
61-
</sdf>
62-
~~~
63-
Where:
64-
* `<world_position>` and `<world_size>` set the fluid world center position and its size
65-
* `<fluid_position>` and `<fluid_volume>` set the center position of the fluid and its volume to be filled with particles
66-
* `<particle_nr>` if set to `0`, the given volume will be filled with fluid particles, otherwise the given particle number will be spawned.
67-
68-
69-
* Run gazebo server with the world plugin:
70-
~~~
71-
gzserver worlds/fluid.world
72-
~~~
73-
* Run gazebo client with the system plugin:
74-
~~~
75-
gzclient -g build/libFluidVisPlugin.so
76-
~~~
77-
64+
1. Set the gazebo plugin and model paths
65+
66+
~~~
67+
echo "export GAZEBO_PLUGIN_PATH=/tmp/gz_fluid/build:${GAZEBO_PLUGIN_PATH}" >> ~/.bashrc
68+
echo "export GAZEBO_MODEL_PATH=/tmp/gz_fluid/models:${GAZEBO_MODEL_PATH}" >> ~/.bashrc
69+
source ~/.bashrc
70+
~~~
71+
72+
1. Add the plugin to your world file, or use one of the examples from the package.
73+
74+
~~~
75+
gedit ~/fluid.world
76+
~~~
77+
78+
Copy the following into the open editor, save, and quit.
79+
80+
~~~
81+
<?xml version="1.0"?>
82+
<sdf version="1.5">
83+
<world name="fluid_world">
84+
85+
<!-- A global light source -->
86+
<include>
87+
<uri>model://sun</uri>
88+
</include>
89+
90+
<!-- A box (plane + fluid is not supported) -->
91+
<model name="box">
92+
<static>true</static>
93+
<pose>0 0 0 0 0 0</pose>
94+
<link name="link">
95+
<collision name="collision">
96+
<geometry>
97+
<box>
98+
<size>20 20 0.1</size>
99+
</box>
100+
</geometry>
101+
</collision>
102+
<visual name="visual">
103+
<geometry>
104+
<box>
105+
<size>20 20 0.1</size>
106+
</box>
107+
</geometry>
108+
</visual>
109+
</link>
110+
</model>
111+
112+
113+
<plugin name="FluidWorldPlugin" filename="libFluidWorldPlugin.so">
114+
<world_position>0 0 1.01</world_position>
115+
<world_size>1.5 1 10</world_size>
116+
<fluid_position>-0.5 0.0 0.8</fluid_position>
117+
<fluid_volume>0.4 0.95 0.5</fluid_volume>
118+
<particle_nr>0</particle_nr>
119+
</plugin>
120+
121+
</world>
122+
</sdf>
123+
~~~
124+
125+
Where:
126+
* `<world_position>` and `<world_size>` set the fluid world center position and its size
127+
* `<fluid_position>` and `<fluid_volume>` set the center position of the fluid and its volume to be filled with particles
128+
* `<particle_nr>` if set to `0`, the given volume will be filled with fluid particles, otherwise the given particle number will be spawned.
129+
130+
131+
1. Run gazebo client with the system plugin:
132+
133+
~~~
134+
gazebo ~/fluid.world -g /tmp/gz_fluid/build/libFluidVisPlugin.so
135+
~~~
78136
79137
# To know:
80138

0 commit comments

Comments
 (0)