Guided
Introduction
Welcome to step by step tutorials for the users with little or no experience using URSim. The steps will guide you through the most basic usage of URSim. We will run a simple prebuilt scene in Unity and connect it to ROS.
You will find the guidelines to so the following tasks ahead:
- Downloading and installing ROS, Unity and other required packages.
- Setting up URSim on windows and connecting it to ROS running on Ubuntu.
- Running your first simulation on URSim.
Downloading and installing ROS, Unity
-
Ubuntu 16.04LTS
Instructions for installing Ubuntu 16.04LTS can be found here. Please stick to Ubuntu 16.Xs only. -
ROS
Instructions for installing ROS Kinetic Kame can be found here. Please stick to ROS Kinetic Kame only. -
Unity
You can download Unity3D from here and install it by running the executable file downloaded.
Setting up the repository and URSim
Setting up repository
- In your Ubuntu terminal enter the following command to git clone the URSim repository:
git clone https://github.com/srmauvsoftware/URSim.git
- Source your environnment:
source /opt/ros/kinetic/setup.bash
Create a new catkin workspace:mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
- Copy the contents of ros directory to the new workspace:
cd /path/to/repo/ros ~/catkin_ws/src
- Install rosbridge:
sudo apt-get install ros-kinetic-rosbridge-suite
- Port forwarding:
Open your web browser and enter the url for opening the configuration page of your router somewhat similar to the examples below:TP Link Routers: http://192.168.0.1
Asus Routers: http://192.168.1.1
Find the option for port forwarding. It could be in security settings or advanced setting. Add a new port and ip address to forward and save the settings then restart the router.
Setting up URSim
- On your Windows machine, download the repository from here. Extract the downloaded zip file.
- Navigate to /path/to/repo/URSim-master/unity/Assets/Scripts and open the file
AUV.cs
. - Edit the ip address and the forwarded port of your ubuntu machine in the following line in the file:
ros = new ROSBridgeWebSocketConnection ("<ip address>", <port>);
for example:
ros = new ROSBridgeWebSocketConnection ("ws://192.168.0.100", 9090);
Runnning simulations and using ROS launch files
- Running the simulation
- Launch Unity3D and after signing in/skipping, click on ‘open’ icon at the top right of the window.
- Navigate to
/path/to/repo/URSim-master/unity/
to select the project. - When the project opens, click on
file->open scene
and navigate to\pathtorepo\URSim-master\unity\Assets\Scenes
and select the scene to run.
-
Using ROS launch files Launch files in ROS are very common to both users and developers. They provide a convenient way to start up multiple nodes and a master, as well as other initialization requirements such as setting up parameters. The launch files are written in
xml
roslaunch is used to open launch files. This is done by specifying the package the launch files are contained in followed by the name of the launch file. We have placed all the launch files inURSim/ros/src/mission_planner/launch/
. You can run these launch files as follows:roslaunch launch <launch_file_name>
. Eg.roslaunch launch depth_controller.launch
. Make sure you have sourced the repository before running any commands.We provide you with the following launch files:
Launch files for controllers
heave_controller.launch
launches the ‘controller’ node from package ‘pid’ under the namespace ‘heave_controller’.
Sets values to the following parameters - kp, ki, kd
upper_limit, lower_limit, windup_limit
max_loop_frequency, min_loop_frequency
Remaps
‘setpoint’ to ‘/depth_setpoint’
‘state’ to ‘/depth’
‘control_effort’ to ‘/heave_controller/control_effort’yaw_controller.launch
launches the ‘controller’ node from package ‘pid’ under the namespace ‘yaw_controller’.
Sets values to the following parameters - kp, ki, kd
upper_limit, lower_limit, windup_limit
max_loop_frequency, min_loop_frequency
Remaps
‘setpoint’ to ‘/heading_setpoint’
‘state’ to ‘/imu/HeadingTrue_degree/theta’
‘control_effort’ to ‘/yaw_controller/control_effort’sway_controller.launch
launches the ‘controller’ node from package ‘pid’ under the namespace ‘sway_controller’.
Sets values to the following parameters - kp, ki, kd
upper_limit, lower_limit, windup_limit
max_loop_frequency, min_loop_frequency
Remaps
‘setpoint’ to ‘/sway_scale_setpoint’
‘state’ to ‘/sway_scale/’
‘control_effort’ to ‘/sway_controller/control_effort’surge_controller.launch
launches the ‘controller’ node from package ‘pid’ under the namespace ‘surge_controller’.
Sets values to the following parameters - kp, ki, kd
upper_limit, lower_limit, windup_limit
max_loop_frequency, min_loop_frequency
Remaps
‘setpoint’ to ‘/surge_scale_setpoint’
‘state’ to ‘/surge_scale/’
‘control_effort’ to ‘/surge_controller/control_effort’controllers.launch
launches all four controllers - heave, sway, yaw, surge.
Launch files for thrusters
depth_thruster.launch
Launches the node ‘depthThrusters’ in package ‘thrusters’vector_thruster.launch
Launches the node ‘vectorThrusters’ in package ‘thrusters’thrusters.launch
Launches both the nodes - ‘depth_thrusters’ and ‘vectorThrusters’