You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Gazebo Fluid Simulation Plugin using the Fluidix library #
1
+
# Introduction
2
2
3
3
The package allows the simulation of fluids in Gazebo. The fluid particle interactions are computed on the GPU
4
4
using the [Fluidix](http://onezero.ca/documentation/) library (if a nvidia GPU is not available the simulation will run in CPU mode).
5
5
6
-
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`). The interaction includes collision detection and the application of forces and torques from the fluid on the rigid objects.
6
+
**Prerequisites:**
7
+
* Get the package from [bitbucket](https://bitbucket.org/ahaidu/gz_fluid).
* 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.
11
+
* For deeper understanding of the particle simulation look through some [Fluidix examples](http://onezero.ca/sample/?id=general_basic).
7
12
8
-
The core of the fluid simulation is written in the `src/FluidEngine.cu` cuda file, it is built upon the [basic SPH example](http://onezero.ca/sample/?id=general_sph).
13
+
# How the package works
9
14
10
-
The package contains two plugins, one world plugin for updating the fluid and its interactions (`FluidWorldPlugin.cc`). And one client based system plugin for visualizing the fluid particles(`FluidVisPlugin.cc`).
15
+
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`).
16
+
The interaction includes:
17
+
* collision detection
18
+
* forces / torques application on the rigid objects
19
+
* visualization of the particles
11
20
12
-
### Installation requirements:
21
+
The core of the fluid simulation is written in the `src/FluidEngine.cu` cuda file and it is built upon the [basic SPH example](http://onezero.ca/sample/?id=general_sph).
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`).
17
24
18
-
### Buid instructions:
25
+
##Build instructions
19
26
27
+
* in a terminal go to the downloaded `gz_fluid` folder and run the following commands
20
28
* $ mkdir build
21
29
* $ cd build
22
30
* $ cmake ..
23
31
* $ make
24
32
25
-
26
-
### Running the plugin:
33
+
## Running the plugin:
27
34
28
35
* set the gazebo plugin paths
29
36
* add the plugin to your world file (e.g worlds/fluid.world), or use one of the world examples from the package
30
-
* run gazebo server with the world plugin $ gzserver worlds/fluid.world
31
-
* run gazebo client with the system plugin $ gzclient -g build/libFluidVisPlugin.so
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
32
41
33
42
34
-
### Changing simulation:
43
+
##How to specify fluid parameters
35
44
36
45
* change fluid plugin parameters from the sdf tags:
37
46
*`<world_position>` and `<world_size>` set the fluid worlds center position and its size
38
47
*`<fluid_position>` and `<fluid_volume>` set the center position of the fluid and its volume to be filled with particles
39
48
*`<particle_nr>` if set to `0`, the given volume will be filled with fluid particles, otherwise the given particle number will be spawned.
* by changing the source code from FluidWorldPlugin.cc
42
61
43
62
44
63
64
+
# To know:
45
65
46
-
### TODOs:
47
-
48
-
* 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.
49
-
50
-
* 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.
51
-
52
-
* the force and torque interaction is done via the particle collisions, pressure force from the liquid is not taken into account.
53
-
54
-
### To know:
66
+
### Collisions meshes
55
67
56
68
* in order for the fluid simulation to detect collisions gazebo needs to use `.stl` files for collision.
57
69
@@ -61,96 +73,31 @@ The package contains two plugins, one world plugin for updating the fluid and it
61
73
* in CMakeLists.txt, the cuda compiler might need graphics card specific flags:
* in the constructor the fluid engine is initialized
69
82
* 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)
70
83
* in `FluidWorldPlugin::Init` the publishers of the objects and fluids particles positions are initialized
71
84
*`FluidWorldPlugin::OnUpdate` is called every world update event, there the fluid engine is updated one timestamp, a msg is sent for the rendering plugin with all the new particles position, and computed forces and torques are applied on the rigid objects.
72
85
73
86
* The system plugin `FluidVisPlugin.cc`, used for rendering the fluid:
87
+
74
88
* in `FluidVisPlugin::Load` the arguments (if given) are loaded for the type of rendering, `sphere` or default `point`. When sphere is selected the rendering gets slower if many particles are loaded.
75
89
* in `FluidVisPlugin::Init` the subscribes for the fluid particle positions are loaded.
76
90
* in `FluidVisPlugin::RenderAsPointsUpdate` or `FluidVisPlugin::RenderAsSpheresUpdate`, (depending on the rendering type) if a new message with the particle positions is available, these will be rendered.
77
91
78
-
* The fluid simulation engine `FluidEngine.cc`:
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
92
+
* The fluid simulation engine `FluidEngine.cu` is similar to the SPH example from Fluidix.
91
93
92
-
# Overview
93
94
94
-
**Prerequisites:**[Attach a Mesh as Visual](http://gazebosim.org/tutorials/?tut=attach_meshes)
95
95
96
-
This tutorials demonstrates how the user can create composite models directly from other models in the [Gazebo Model Database](http://gazebosim.org/user_guide/started__models__database.html) by using the `<include>` tags and [`<joint>`](http://gazebosim.org/sdf/1.4.html#joint309) to connect different components of a composite model.
96
+
# Unfinished parts, TODOs:
97
+
If somebody is interested in further contributing to the package, many features still need work:
97
98
98
-
## Adding a Laser
99
-
100
-
Adding a laser to a robot, or any model, is simply a matter of including the sensor in the model.
101
-
102
-
1. Go into your model directory from the previous tutorial:
103
-
104
-
cd ~/.gazebo/models/my_robot
105
-
106
-
1. Open `model.sdf` in your favorite editor.
107
-
108
-
1. Add the following lines directly before the `</model>` tag near the end of the file.
109
-
110
-
~~~
111
-
<include>
112
-
<uri>model://hokuyo</uri>
113
-
<pose>0.2 0 0.2 0 0 0</pose>
114
-
</include>
115
-
<joint name="hokuyo_joint" type="revolute">
116
-
<child>hokuyo::link</child>
117
-
<parent>chassis</parent>
118
-
<axis>
119
-
<xyz>0 0 1</xyz>
120
-
<limit>
121
-
<upper>0</upper>
122
-
<lower>0</lower>
123
-
</limit>
124
-
</axis>
125
-
</joint>
126
-
~~~
127
-
128
-
The `<include>` block tells Gazebo to find a model, and insert it at a given `<pose>` relative to the parent model. In this case we place the hokuyo laser forward and above the robot. The `<uri>` block tells gazebo where to find the model inside its model database (note, you can see a listing of the model database uri used by these tutorials at [here](http://gazebosim.org/models/), and the corresponding [mercurial repository](https://bitbucket.org/osrf/gazebo_models).
129
-
130
-
The new `<joint>` connects the inserted hokuyo laser onto the chassis of the robot. The joint has and `<upper>` and `<lower>` limit of zero to prevent it from moving.
131
-
132
-
The `<child>` name in the joint is derived from the [hokuyo model's SDF](https://bitbucket.org/osrf/gazebo_models/src/6cd587c0a30e/hokuyo/model.sdf?at=default), which begins with:
133
-
134
-
~~~
135
-
<?xml version="1.0" ?>
136
-
<sdf version="1.4">
137
-
<model name="hokuyo">
138
-
<link name="link">
139
-
~~~
140
-
141
-
When the hokuyo model is inserted, the hokuyo's links are namespaced with their model name. In this case the model name is `hokuyo`, so each link in the hokuyo model is prefaced with `hokuyo::`.
142
-
143
-
1. Now start gazebo, and add the robot to the simulation using the Insert tab on the GUI. You should see the robot with a laser attached.
144
-
145
-
[[file:files/Add_laser_pioneer.png|640px]]
146
-
147
-
1. (Optional) Try adding a camera to the robot. The camera's model URI is `model://camera`, it should have been locally caches for you in:
148
-
149
-
ls ~/.gazebo/models/camera/
150
-
151
-
152
-
For reference, the SDF documentation can be found [here](http://gazebosim.org/sdf/).
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.
153
100
154
-
## Next
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.
155
102
156
-
[Next: Make a Simple Gripper](http://gazebosim.org/tutorials/?tut=simple_gripper)
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.
0 commit comments