turtlebot3 can't receive message from matlab, but matlab can get data from turtlebot
Show older comments
I use matlab to control my turtlebot, there is something wrong with communication.
Rossubscriber can work sucessfully, matlab can get data from bot correctly, from topics like /scan , /cmd_vel
But rospublisher cannot work.
I tried rospublisher() and send() to send msg to /cmd_vel,
and /cmd_vel is always linear: x: 0.0 y: 0.0 z: 0.0
However, I can make the bot move by terminal via ssh into the board on the turtlebot
both
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0}}'
and
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
can work,
so the hardware does not have problems.
Here are my Settings.
In ubuntu of turtlebot, .bashrc
export ROS_IP=192.168.1.101
export ROS_MASTER_URI=http://192.168.1.101:11311
export ROS_HOSTNAME=192.168.1.101
In matlab
rosshutdown;
setenv('ROS_IP','192.168.1.108')
setenv('ROS_MASTER_URI','http://192.168.1.101:11311')
ipaddress = "http://192.168.1.101:11311" ;
rosinit(ipaddress)
code to move the bot
cmd_publish = rospublisher("/cmd_vel","DataFormat","struct") ;
velMsg = rosmessage(cmd_publish);
velMsg.Linear.X = 0.1;
send(cmd_publish,velMsg)
another attempt
velocity=0.1;
robot = rospublisher("/cmd_vel",'geometry_msgs/Twist')
velmsg = rosmessage(robot)
velmsg.Linear.X = velocity;
send(robot,velmsg)
Neither echo nor rospublisher can find any change in /cmd_vel
I don't understand why rospublisher can't work but rossubscriber can.
All help is appreciated.
Thank you in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Network Connection and Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!