Issues connecting MATLAB to Turtlebot4

5 visualizzazioni (ultimi 30 giorni)
Kai
Kai il 5 Dic 2023
Commentato: Kai il 22 Dic 2023
I am trying to connect MATLAB R2023b on Ubuntu 22.04 to my Turtlebot4 using:
rosinit("http://192.168.1.3:11311");
I have checked my ROS_MASTER_URI on both my PC and the RPi.
On my PC:
$ echo $ROS_MASTER_URI
http://localhost:11311
On my RPi:
$ echo $ROS_MASTER_URI
http://192.168.1.3:11311
When I tried to do rosinit, MATLAB outputs the error:
Cannot connect to ROS master at http://192.168.1.3:11311. Check the specified address or hostname.
Am I missing something here? Any help would be greatly appreciated!

Risposte (2)

Ashutosh Thakur
Ashutosh Thakur il 19 Dic 2023
Hi Kai,
I understand that you are facing issue with connecting MATLAB with TurtleBot4.
Following are the suggestion which may help you in troubleshooting the issue:
  • Check the firewall and network settings and also check if all required ports are open for ROS communication.
  • Verify the ROS_HOSTNAME environment variable on both your PC and the RPi. It should be set to the IP address of the respective machine to ensure that ROS communication occurs over the correct network interface.
  • Also ensure that MATLAB has necessary permissions to access the network.
Kindly follow these documentation links which would help in understanding the ROS connectivity in MATLAB:
I hope this helps you in troibleshooting the issue.
  1 Commento
Kai
Kai il 22 Dic 2023
Hi, thanks for your reply.
First, to check for any firewall:
$ sudo ufw status
Status: inactive
Which means there are no firewalls active. I also checked the ports using
$ netstat -a
and all of them are CONNECTED or LISTENING.
Next, I verified that the ROS_IP on my host computer is 192.168.1.4 and the ROS_IP on my Turtlebot4 Rpi is 192.168.1.3. My ROS_MASTER_URI for both are the same, http://192.168.1.3://11311
Not sure how to check MATLAB permissions though, but it is a fresh install.
It still does not work.

Accedi per commentare.


Raj
Raj il 20 Dic 2023
Adding on to the answer mentioned above, you can also check the following points to troubleshoot your issue
  • Verify both the host machine and Turtlebot4 are connected to the same network
  • Set ROS_MASTER_URI on both the host machine and the Rpi
  • On Turtlebot, set ROS_IP to match the Turtlebot IP address
If the problem persists, try initializing ROS on your Rpi as well. You can later use the following command to check if ROS master is up and running
bool ros ::master::check()
If the master is available it will return true, else it will return false.
I hope you are able to proceed further
  1 Commento
Kai
Kai il 22 Dic 2023
Hi, thanks for your reply.
I have verified that they are connected to the same network. I can ping the turtlebot from the host computer's terminal and also the host computer from the turtlebot's terminal.
Yes, my ROS_MASTER_URI is the same http://192.168.1.3://11311.
Yes, my ROS_IP in the turtlebot's terminal is 192.168.1.3.
The command
bool ros ::master::check()
does not work when I entered it into the MATLAB command window.
It outputs: Unrecognized function or variable 'bool'.
Any further help would be greatly appreciated.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by