Ask Your Question

connecting matlab and ros in same computer

asked 2020-03-01 01:52:54 -0600

m.kowsar gravatar image

hi every one.I'm so begginer with ros and I want to run talker.m in matlab and visulize it's results in ros (in linux terminal).but I can't connect matlab to ros.I use ubuntu 16.04 and ros kinetic version.I set ros_ip=my_pc_name:11311 and my matlab ip as my pc ip using 'ifconfig'.In this code matlab gets this error: Error using talker (line 12) Cannot determine the message type of the /talker topic. Either the topic is not registered with the ROS master, or the ROS master is not reachable.

////////////////////////////////////matlab code


ros_master_ip = 'http://localhost:11311';

matlab_ip = '';


talker_sub = rossubscriber( '/talker' );

[chatter_pub, chatter_msg] = rospublisher('/chatter','std_msgs/String');

r = rosrate(2); % 2 Hz loop rate

pause(2) % wait a bit the roscore initialization

edit retag flag offensive close merge delete


Hi @m.kowsar,

I think the problem is you are subscribing to an nonexistent topic. The standard information flow will be:

pub = rospublisher('/chatter','std_msgs/String');
sub = rossubscriber('/chatter');

To communicate both ends.

Weasfas gravatar image Weasfas  ( 2020-03-02 02:16:22 -0600 )edit

thanks a lot @Weasfas for your seems to be right.

m.kowsar gravatar image m.kowsar  ( 2020-03-02 02:32:13 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2020-03-02 03:41:07 -0600

Weasfas gravatar image

As stated by @m.kowsar,

The problem came from the logic implemented in the matlab script. Providing this lines to subscribe and publish in he proper topic solved the issue.

pub = rospublisher('/chatter','std_msgs/String');
sub = rossubscriber('/chatter');

Note: @m.kowsar, if you consider this answer to be correct add the check mark at the right.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-03-01 01:52:54 -0600

Seen: 208 times

Last updated: Mar 02 '20