I am planning to use MATLAB and Gazebo for one of my course projects.

However all the tutorials I have seen till now use Gazebo by using a virtual machine which has ROS and Gazebo installed. I have already installed ROS and Gazebo on this machine (OS Ubuntu). I also have MATLAB installed on it.

Is it possible to use the Gazebo on this machine itself with the MATLAB toolbox?

  • 1
    $\begingroup$ I haven't done it before, but it does look like there are ways to connect Gazebo and MATLAB -- check out the Mathworks resources here. $\endgroup$ Commented Oct 20, 2015 at 19:27
  • $\begingroup$ This method involve using a virtual machine. I was wondering if it could be done in such a way that same machine has Matlab and gazebo running. $\endgroup$
    – Anupu
    Commented Oct 21, 2015 at 0:07

2 Answers 2


The MATLAB tutorial doesnt cover this aspect well about when you have matlab and gazebo running on the same linux machine with no virtual box.

Change your linux ethernet interface ip address statically using:

sudo ifconfig eth0 netmask

assign to ros master the same ip address using:

export ROS_MASTER_URI= >> ~/.bashrc
export ROS_HOSTNAME= >> ~/.bashrc
export ROS_IP= >> ~/.bashrc

assign to matlab ros, an ip address in same subnet as the master above using :


start rosmaster in terminal using : roscore

start gazebo model in terminal

connect to rosmaster ip adress in MATLAB using: rosinit('')

Now you should see gazebo and ros topics in matlab command window

You can also follow the matlab tutorial to see how much more you can do

  • $\begingroup$ This is a stellar answer! For readability (and to prevent parsing of URLs) I'll comment that you can place code between grave accent marks (`) or put the code on a new line and preface it with four spaces. Also, you can highlight the code and use the code command button { } and it will automatically insert the 4 preceding spaces. $\endgroup$
    – Chuck
    Commented Jun 28, 2016 at 12:38

As I understand, you installed ROS and Gazebo in your virtual machines, but MATLAB is not. Your MATLAB is installed in the real machine(~.~). If your case is like this, you can get a linux-MATLAB version and install it in the virtual computer. All things get done! You can follow the instruction mentioned in Brian's comment above to connect Gazebo and MATLAB in your virtual machine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.