turtlebot3 can't receive message from matlab, but matlab can get data from turtlebot
古いコメントを表示
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Network Connection and Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!