フィルターのクリア

Matlab ROS subscriber basic example

5 ビュー (過去 30 日間)
Vincent Talon
Vincent Talon 2017 年 7 月 7 日
コメント済み: xupeng 2019 年 11 月 19 日
Have you a step by step example to create a subscriber I do this
setenv('ROS_IP','192.168.1.41') % adress PC with Matlab setenv('ROS_HOSTNAME','192.168.1.41') setenv('ROS_MASTER_URI','http://192.168.1.28:11311/') % adress turtlebot rosinit rostopic list
Here I am able to see all the topics that are on the turtlebot And I am able to command to move my turtlebot with
velocity = -0.1; % meters per second robot = rospublisher('/mobile_base/commands/velocity') velmsg = rosmessage(robot) velmsg.Linear.X = velocity; for i=1:50000 i send(robot,velmsg); end
I can also ask to my Turtle to emitting a noise
soundpub = rospublisher('/mobile_base/commands/sound', 'kobuki_msgs/Sound') soundmsg = rosmessage('kobuki_msgs/Sound'); soundmsg.Value = 6; % Any number 0-6 send(soundpub,soundmsg);
But when I want to subscribe to a topic…
odom = rossubscriber('/odom')
odomdata = receive(odom,3);
I have this error message
Error using robotics.ros.Subscriber/receive (line 325)
The function did not receive any data and timed out.
When I apply : rostopic info /odom I obtain :
Type: nav_msgs/Odometry Publishers: * /mobile_base_nodelet_manager (<http://turtlebot.local:58513/>) Subscribers: * /matlab_global_node_86572 (<http://192.168.1.65:49791/>) * /matlab_turtlebot_69671 (<http://192.168.1.65:49752/>)
What I should do to be able to subscribe and read a topic of my Turtlebot with Matlab My configuration is Turtlebot : Ubuntu 14.4 + Indigo PC : Windows10 + Matlab 2017a (I stop all firewall)
Thank you in advance for your help

採用された回答

Vincent Talon
Vincent Talon 2017 年 7 月 11 日
My problem come to multipl IP adress for my Matlab computer...
.
To help other persone, the configuration that work well with my Turtlebot
In my case, the IP adress are
PC with Matlab : 192.168.1.41
Turtlebot computer : 192.168.1.28
.
In the .bashrc, I have
source /opt/ros/indigo/setup.bash
export ROS_MASTER_URI=http//192.168.1.28:11311
export ROS_HOSTNAME=192.168.1.28
export ROS_IP=192.168.1.28
.
In Matlab 2 solutions are possible:
solution 1:
setenv('ROS_IP','192.168.1.41') % adress PC with Matlab
setenv('ROS_HOSTNAME','192.168.1.41')
setenv('ROS_MASTER_URI','http://192.168.1.28:11311/') % adress turtlebot
rosinit
.
solution 2 :
rosinit('http://192.168.1.28:11311', 'NodeHost', '192.168.1.41')
  1 件のコメント
xupeng
xupeng 2019 年 11 月 19 日
thanks for your answer, it soluts my problem whice disturbe me for a long time .

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

その他の回答 (1 件)

Sebastian Castro
Sebastian Castro 2017 年 7 月 10 日
編集済み: Sebastian Castro 2017 年 7 月 10 日
If you try to echo the /odom topic on the Turtlebot and in MATLAB (same syntax), do you see any messages?
rostopic echo /odom
If you don't see anything on the robot, then it's not sending anything and it's not a MATLAB issue. If you see something on the robot but not in MATLAB, then it could be a connectivity issue and maybe changing the port on the URI could help?
- Sebastian

カテゴリ

Help Center および File ExchangePublishers and Subscribers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by