ROS subscriber callback is not triggered when the master is run from ros hydro

I have the following setup in Linux: 1- ros core (hydro) running on a separate terminal. 2- stage publish LIDAR message and others... 3- Matlab subscribing to Lidar messages and displaying a message every time a message is received.
Verified: 1- rostopic list shows the Lidar data is publish at an average 10 Hz rate 2- Matlab node is recognized by ros as a subscriber to the Lidar topic (/base_scan)
Problem: The call back function never gets triggered.
Note: I tried a similar setup with roscore running on Matlab with publisher & subscriber to Lidar data, and that worked...
code:
node = rosmatlab.node('LidarPlotter', 'http://localhost:11311');
subscriber = rosmatlab.subscriber('/base_scan', 'sensor_msgs/LaserScan', 10, node);
subscriber.setOnNewMessageListeners({@LidarPlot});
pause(10);
node.removeSubscriber(subscriber);
% Delete the master.
clear('roscore');
%%Clean up workspace.
clear;
Function code:
function LidarPlot(x)
disp('a lidar message has been received');

3 件のコメント

Felix Burget
Felix Burget 2014 年 2 月 10 日
Hi Utayba,
i am having the same problem. Just trying so use Matlab to plot some data in real time while running a ROS application. I already tried to receive messages in matlab using
rostopic pub /TOPIC std_msgs/String 'Hello'
without success. The communication between ROS & Matlab does not seem to be bidirectional. There's also no example or tutorial explaining how messages published from ROS are received by a Matlab subscriber. Hope to get some info soon.
Best, Felix
Hi,
Were you able to run any of the examples? When I try rosmatlab_basic I receive the following error:
>> rosmatlab_basic
Undefined variable "org" or class "org.ros.RosCore.newPublic".
Error in rosmatlab.roscore (line 62)
rosMaster = org.ros.RosCore.newPublic(port);
Error in rosmatlab_basic (line 4)
roscore = rosmatlab.roscore(11311);
Do i need to install any other packages for Hydro? I just download and installed the source from matlab. There is no tutorial or proper instructions for this package, so any help is apriciated.
Bests,
Soner
Daniel
Daniel 2014 年 2 月 21 日
I have the same problem in hydro. I have try with many official and unofficial messages, but communication is only works from Matlab to ROS. However when nodes are create with Matlab communication is bidirectional.
Soner Ulun: Are you in the correct path?

サインインしてコメントする。

 採用された回答

Jaime
Jaime 2014 年 2 月 24 日

0 投票

Hi, i found a solution and post it in http://answers.ros.org/questions/
I hope it will work for you as well.
Greets, Jaime

1 件のコメント

Utayba Mohammad
Utayba Mohammad 2014 年 2 月 24 日
Thanks Jaime,
That worked for me. Following up on your solution I notice that when you don't specify ROS_MASTER_URI, roscore uses a default value of "http://ubuntu:11311" so Matlab was communicating with ROS properly using localhost or explicit IP but not the other way around.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Services and Actions についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by