3
$\begingroup$

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?

$\endgroup$
2
  • 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$ 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
    Oct 21, 2015 at 0:07

2 Answers 2

4
$\begingroup$

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   192.168.1.1 netmask 255.255.255.0

assign to ros master the same ip address using:

export ROS_MASTER_URI=http://192.168.1.1:11311 >> ~/.bashrc
export ROS_HOSTNAME=192.168.1.1 >> ~/.bashrc
export ROS_IP=192.168.1.1 >> ~/.bashrc

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

setenv('ROS_IP','192.168.1.100:11311')
setenv('ROS_IP','192.168.1.100')

start rosmaster in terminal using : roscore

start gazebo model in terminal

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

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

$\endgroup$
1
  • $\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
    Jun 28, 2016 at 12:38
1
$\begingroup$

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.

$\endgroup$

Your Answer

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

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