ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

connecting matlab and ros in same computer

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

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

rosshutdown

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

matlab_ip = '192.168.42.10';

rosinit(ros_master_ip,'NodeHost',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

Comments

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 -0500 )edit

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

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

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Question Tools

1 follower

Stats

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

Seen: 493 times

Last updated: Mar 02 '20