-
Notifications
You must be signed in to change notification settings - Fork 58
Simulation using UWSim
#Overview on using the Simulator
The simulator is used to emulate the conditions of the actual pool and is implemented using the UWSim package. The UWSim package helps to create the pool environment containing necessary objects from an xml file. Read more on simulations [here] ('http://www.societyofrobots.com/programming_robot_simulation.shtml')
#UWSim ##Package-based installation
There are deb packages pre-compiled for Ubuntu and ROS Groovy / Hydro. Assuming you have the ROS repositories already added to your sources.list, the following command will install UWSim and all its dependencies:
sudo apt-get install ros-hydro-uwsim
Read more here
##Running
First be sure that a roscore is already running. If not, start it:
roscore
After that, the following command should start UWSim:
rosrun uwsim uwsim
The first time you run UWSim, it will ask for downloading a data package that will be installed under ~/.uwsim. After that, a window should appear showing a default scenario and robot. Inside the simulator, you can freely move the camera with the mouse.
With the simulator running, you can check the list of ROS topics involved:
rostopic list
The urdf file is the robot description file that is used to simulate the scene. To read on how to build and parse a urdf file read this tutorial.
For kraken 3.0, the UWSim will generate a scene using the data fed into the xml file scenes.urdf found at kraken_3.0/simulator_stack/kraken_visualization/kraken/scenes. Open this file on Github
The objects used in the pool like gate marker, other markers, and buoys are exported into the xml file using its path and the data is changed to place it at appropriate position by joining it to the pool object and appropriate orientation.
This snippet of code from the file shows how its done.
<link name="gate_buoy_red">
<visual>
<geometry>
<mesh filename="package://kraken_visualization/kraken/objects/buoy_red.osg"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.75"/>
</visual>
<collision>
<geometry>
<mesh filename="package://kraken_visualization/kraken/objects/buoy_red.osg"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
</collision>
</link>
<joint name="gate_buoy_red_to_pool" type="fixed">
<parent link="pool"/>
<child link="gate_buoy_red"/>
<origin rpy="0 0 0.0" xyz="5 6.84 0"/>
</joint>
There are esssentially two tags linked with placing an object
<link>
is used to link to the object and to specify position.
<joint>
is used to join the object appropriately to the pool.
The file is used to position the various objects in the pool for simulating the environment in the arena. The file allows to place the object at desired position in terms of x, y, and z coordinates.
To choose the object you want to place at any position, link it using <mesh filename="path/filename" scale="1.0000 1.0000 1.0000" />
To insert the object at point x, y, z, use the tag <origin>
inside <link>
and replace xyz="x1 y1 z1"
with your new respective values.
Similarly, to rotate the object around any axis, use angle values in radians and change the values inside rpy="x1 y1 z1"
to new respective values.
All objects can be linked and oriented in similar manner.
#Generating Custom Scenes using UWSim
The edited xml file can be used to generate the custom pool by running an executable file kraken_visualization_launcher found at kraken_3.0/simulator_stack/kraken_visualization.
This launcher file uses the command rosrun uwsim uwsim --configfile kraken/scenes/UWSim_scene.xml
to launch the simulator.
In case of poor graphic capabilities of machine, use the command rosrun uwsim uwsim --configfile --disableShaders kraken/scenes/UWSim_scene.xml