- If you're using a VM or another machine, try to see if the message is getting through. Open a new terminal, set up the same Master target, run "rostopic echo /cmd_vel", and see if the MATLAB messages are received.
- Check if you are receiving sensor messages from the robot in MATLAB. Sometimes if communications are only going one-way, it can indicate improper address or network settings.
- After the turtlebot is started, can you see /cmd_vel advertised as an existing topic in MATLAB ("rostopic list").
- Try roswtf from a Linux machine.
I can't move the turtlebot3 with matlab and ros
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
i have some weird trouble here with the turtlebot and hope somebody can help me find where i did wrong. Up until now I can't make the turtlebot move when I publish on /cmd_vel
PC with matlab : 192.168.43.76
Rpi : 192.168.43.215
On the Rpi of the turtlebot:
I did modify the ~/.bashrc :
export ROS_MASTER_URI=http//192.168.43.215:11311
export ROS_HOSTNAME=192.168.43.215
export ROS_IP=192.168.43.215
export TURTLEBOT3_MODEL=waffle_pi
then I did: source ~/.bashrc
Next on matlab I wrote:
rosshutdown
setenv('ROS_IP','192.168.43.76')
setenv('ROS_HOSTNAME','192.168.43.76')
setenv('ROS_MASTER_URI','http://192.168.43.215:11311/')
rosinit
So the weird thing are that when i write :
velocity = 1.0;
robot = rospublisher('/cmd_vel','geometry_msgs/Twist');
msg = rosmessage(robot);
msg.Linear.X= velocity;
send(robot,msg);
the robot doesn't move, although I have verified that the matlab is a publisher on /cmd_vel node on the RPi ( with the command rostopic info /cmd_vel), but i doesn't receive anything from the matlab ( I have also check with rostopic echo /cmd_vel)
I have already verify if the trouble was on the turtlebot but I can make the turtlebot move by using the command:
rostopic pub -1 /cmd_vel geometry_msgs/Twist --'[1.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
but this time I try to check if I was seeing anything on the matlab by using rostopic('echo','/cmd_vel') but it doesn't show any modification of the topic on this either.
So I guess I have communication trouble between matlab and Rpi but I can't find where.
If anybody has an hint, you're more than welcome.
Thank you in advance community.
0 Kommentare
Antworten (1)
Cam Salzberger
am 29 Mai 2020
Bearbeitet: Cam Salzberger
am 29 Mai 2020
Hello Ambroise,
There are a couple of things I noticed right off the bat that could be causing things to be weird:
export ROS_MASTER_URI=http//192.168.43.215:11311
I believe you have forgotten the colon between "http" and "//".
export ROS_HOSTNAME=192.168.43.215
export ROS_IP=192.168.43.215
Generally you should only set either the hostname or the IP address. The hostname will override the IP address if both are set. However, since you are trying to specify an IP address, then "ROS_IP" would be the more appropriate variable to set.
Also, I generally have not seen the ROS_MASTER_URI set before starting a roscore. ROS_IP is fine, I think, but the master generally selects its own IP and port number. Try removing the setting of ROS_MASTER_URI, and see if it automatically sets itself to the same address anyway. If it doesn't try updating the MATLAB code to target the correct address and test that.
setenv('ROS_IP','192.168.43.76')
setenv('ROS_HOSTNAME','192.168.43.76')
You should not need to set either ROS_HOSTNAME or ROS_IP in MATLAB. When you do "rosinit" or "ros.Node", these variables are set for you before spinning off the node. It shouldn't hurt, but it probably isn't necessary. If you do want to set something, just set the one variable.
setenv('ROS_MASTER_URI','http://192.168.43.215:11311/')
You've got an extra slash on the end of the address. Not sure it matters, but I've never seen it done that way before.
Other tips for diagnostics:
-Cam
4 Kommentare
Cam Salzberger
am 8 Jun. 2020
To make sure I'm understanding you correctly, you've tried:
- Publishing /cmd_vel from TurtleBot and subscribing in MATLAB -> No communication
- Publishing /cmd_vel from MATLAB and subscribing in TurtleBot -> No communication
- Publishing /scan from TurtleBot and subscribing in MATLAB -> Communication works
That is odd. I'd normally expect to see any and all communication from one source to the other fail, not particular topics. There are two more things to explore that I can suggest:
- I have seen firewalls be an issue in ROS networks before, blocking communication in either one or both directions. The ROS documentation has some tips for configuring your firewall, but use your best judgement and follow your organization's security guidelines (if applicable).
- If the message definitions are different between two machines, the messages will be dropped when their MD5 checksum does not match. This shouldn't be the issue, as I don't believe geometry_msgs/Twist (I assume that's the message type for /cmd_vel) or its nested messages (geometry_msgs/Vector3) have changed since creation, but it's worth checking. Run this command on both MATLAB and TurtleBot, and make sure the value is the same:
rosmsg md5 geometry_msgs/Twist
Siehe auch
Kategorien
Mehr zu Network Connection and Exploration finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!