Start the ROS stage simulation with a MATLAB/Simulink project

This guide is about how to get the ROS stage simulation going combined with our current MATLAB/Simulink project. As usual terminal commands are printed blue.

Note: This guide is not about how MATLAB and ROS stage do communicate with each other. It’s a manual for team member.

Step 1:

Source the “setup.bash” in the “floribot_ws/devel/” directory and execute the launch script “launch_stage1.sh” in the “floribot_ws/src/” directory. The roscore and the stage simulation should be started automatically.

source floribot_ws/devel/setup.bash

./floribot_ws/src/launch_stage1.sh

Step 2:

Open MATLAB and add all folder and subfolder of the directory “floribot_ws” to the MATLAB path (Add to Path -> Selected Folders and Subfolders). After that open with MATLAB the project “floribot_simulink.prj” that is inside of the “floribot_ws/src/” directory.

Step 3

Now open “simulink/robot1_MIL.slx” and start the rosnode connection with the function “start_rosnode” that is accessible at the “project shortcuts” tab. Otherwise execute “start_rosnode” inside the MATLAB command window.

Step 4

If no error occures, open the subsystem “wiimote” inside the Simulink model “robot1_MIL” and start the simulation with the “Run” button. The robot inside the ROS stage window still does not move. First it has to be set to automatic mode with the switch “button_2″ inside the “wiimote” subsystem. After a simple flip of the switch the only thing the robot still needs is the information where it should turn after the end of the first lane. In order to provide this information simply flip the switch “button_left” for a turn to the left or “button_right” for a turn to the right, after the first lane. With this final flip the robot should start moving inside the ROS stage simulation. If you like to cancel the movement of the robot, just stop the Simulink simulation with the “Stop” button.