Skip to content

Commit 2f8539d

Browse files
committed
changes to tutorial
1 parent 07fdc7a commit 2f8539d

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

fluids/tutorial.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The package allows the simulation of fluids in Gazebo. The fluid particle intera
44
using the [Fluidix](http://onezero.ca/documentation/) library (if a nvidia GPU is not available the simulation will run in CPU mode).
55

66
**Prerequisites:**
7+
78
* Get the package from [bitbucket](https://bitbucket.org/ahaidu/gz_fluid).
89
* Install [CUDA](https://developer.nvidia.com/cuda-downloads) (recommended 6.0).
910
* Install [Fluidix](http://onezero.ca/documentation/).
@@ -13,6 +14,7 @@ using the [Fluidix](http://onezero.ca/documentation/) library (if a nvidia GPU i
1314
# How the package works
1415

1516
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`).
17+
1618
The interaction includes:
1719
* collision detection
1820
* forces / torques application on the rigid objects
@@ -24,60 +26,72 @@ The package contains two plugins, one world plugin for updating the fluid and it
2426

2527
## Build instructions
2628

27-
* in a terminal go to the downloaded `gz_fluid` folder and run the following commands
28-
* $ mkdir build
29-
* $ cd build
30-
* $ cmake ..
31-
* $ make
32-
33-
## Running the plugin:
34-
35-
* set the gazebo plugin paths
36-
* add the plugin to your world file (e.g worlds/fluid.world), or use one of the world examples from the package
37-
* run gazebo server with the world plugin:
38-
* $ gzserver worlds/fluid.world
39-
* run gazebo client with the system plugin:
40-
* $ gzclient -g build/libFluidVisPlugin.so
29+
In a terminal go to the downloaded `gz_fluid` folder and run the following commands:
4130

31+
~~~
32+
mkdir build
33+
cd build
34+
cmake ..
35+
make
36+
~~~
4237

43-
## How to specify fluid parameters
38+
## Running the plugin:
4439

45-
* change fluid plugin parameters from the sdf tags:
46-
* `<world_position>` and `<world_size>` set the fluid worlds center position and its size
47-
* `<fluid_position>` and `<fluid_volume>` set the center position of the fluid and its volume to be filled with particles
48-
* `<particle_nr>` if set to `0`, the given volume will be filled with fluid particles, otherwise the given particle number will be spawned.
49-
40+
* Set the gazebo plugin and model paths
5041
~~~
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+
...
5152
<plugin name="FluidWorldPlugin" filename="libFluidWorldPlugin.so">
5253
<world_position>0 0 5.01</world_position>
5354
<world_size>1.5 1 10</world_size>
5455
<fluid_position>-0.5 0.0 0.8</fluid_position>
5556
<fluid_volume>0.4 0.95 0.5</fluid_volume>
5657
<particle_nr>0</particle_nr>
5758
</plugin>
59+
60+
</world>
61+
</sdf>
5862
~~~
63+
* `<world_position>` and `<world_size>` set the fluid world center position and its size
64+
* `<fluid_position>` and `<fluid_volume>` set the center position of the fluid and its volume to be filled with particles
65+
* `<particle_nr>` if set to `0`, the given volume will be filled with fluid particles, otherwise the given particle number will be spawned.
5966

60-
* by changing the source code from FluidWorldPlugin.cc
6167

68+
* Run gazebo server with the world plugin:
69+
~~~
70+
gzserver worlds/fluid.world
71+
~~~
72+
* Run gazebo client with the system plugin:
73+
~~~
74+
gzclient -g build/libFluidVisPlugin.so
75+
~~~
6276

6377

6478
# To know:
6579

6680
### Collisions meshes
6781

68-
* in order for the fluid simulation to detect collisions gazebo needs to use `.stl` files for collision.
82+
In order for the fluid simulation to detect collisions gazebo needs to use `.stl` files for collision meshes.
6983

7084

7185
### Possible issues:
7286

73-
* in CMakeLists.txt, the cuda compiler might need graphics card specific flags:
87+
In CMakeLists.txt, the cuda compiler might need graphics card specific flags:
7488

7589
`SET(CUDA_NVCC_FLAGS "-arch;sm_30 -use_fast_math -lm -ldl -lrt -Xcompiler \"-fPIC\"")`
7690

7791
### Some code explanation:
7892

7993
* The world plugin `FluidWorldPlugin.cc`:
80-
94+
8195
* in the constructor the fluid engine is initialized
8296
* in `FluidWorldPlugin::Load` the sdf parameters are loaded, the fluid world is created, fluid is added, the objects from the environment are recreated in the fluid environment (when possible)
8397
* in `FluidWorldPlugin::Init` the publishers of the objects and fluids particles positions are initialized
@@ -96,8 +110,8 @@ The package contains two plugins, one world plugin for updating the fluid and it
96110
# Unfinished parts, TODOs:
97111
If somebody is interested in further contributing to the package, many features still need work:
98112

99-
* implementing a newer SPH: [PCISPH](https://sph-sjtu-f06.googlecode.com/files/a40-solenthaler.pdf) or [IISPH](http://cg.informatik.uni-freiburg.de/publications/2013_TVCG_IISPH.pdf) for faster simulation and no compression of the fluid. This can be done in the `src/FluidEngine.cu` file by changing the algorithm.
113+
* Implementing a newer SPH: [PCISPH](https://sph-sjtu-f06.googlecode.com/files/a40-solenthaler.pdf) or [IISPH](http://cg.informatik.uni-freiburg.de/publications/2013_TVCG_IISPH.pdf) for faster simulation and no compression of the fluid. This can be done in the `src/FluidEngine.cu` file by changing the algorithm.
100114

101-
* currently the simulation only has the box implemented as a standard shape, see `FluidEngine::AddMovableBox` from `src/FluidEngine.cu`, it is implemented similarly to this [example](http://onezero.ca/sample/?id=init_manual). Using the same idea the rest of the collision types can be implemented as well: cylinder, sphere, plane. After implementation these need to be added in the `FluidWorldPlugin::CreateFluidCollision` method, similarly to the `box` type.
115+
* Currently the simulation only has the box implemented as a standard shape, see `FluidEngine::AddMovableBox` from `src/FluidEngine.cu`, it is implemented similarly to this [example](http://onezero.ca/sample/?id=init_manual). Using the same idea the rest of the collision types can be implemented as well: cylinder, sphere, plane. After implementation these need to be added in the `FluidWorldPlugin::CreateFluidCollision` method, similarly to the `box` type.
102116

103-
* the force and torque interaction is done via the particles surface collisions, pressure force from the liquid is not taken into account. A fancier algorithm would greatly increase realism.
117+
* The force and torque interaction is done via the particles surface collisions, pressure force from the liquid is not taken into account. A fancier algorithm would greatly increase realism.

0 commit comments

Comments
 (0)