Azzera filtri
Azzera filtri

Matlab ROS subscriber basic example

5 visualizzazioni (ultimi 30 giorni)
Vincent Talon
Vincent Talon il 7 Lug 2017
Commentato: xupeng il 19 Nov 2019
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

Risposta accettata

Vincent Talon
Vincent Talon il 11 Lug 2017
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 Commento
xupeng
xupeng il 19 Nov 2019
thanks for your answer, it soluts my problem whice disturbe me for a long time .

Accedi per commentare.

Più risposte (1)

Sebastian Castro
Sebastian Castro il 10 Lug 2017
Modificato: Sebastian Castro il 10 Lug 2017
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

Categorie

Scopri di più su Publishers and Subscribers in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by