Error using urROS2Node

Hi,
I am using MATLAB 2024a in linux, where I have installed ROS 2 and Dependencies as proposed in here by using the automated method.
As can be seen in the picture, evrething seems to work fine.
However, I am trying to connect to the UR simulator, as explained in this example using this script:
clear, clc;
ur5e = loadrobot('universalUR5e');
username = 'xxxxxx';
password = 'xxxxxxx';
ROS2Folder = '/opt/ros/humble';
ROS2Workspace = '/opt/ros/humble'; % In case of binary installation, ROS 2 Work-space is same as ROS 2 Folder
ROS2DeviceAddress = '192.168.56.1';
robotAddress = '192.168.56.101';
device = ros2device(ROS2DeviceAddress,username,password);
device.ROS2Folder = ROS2Folder;
device.ROS2Workspace = ROS2Workspace;
generateAndTransferLaunchScriptROS2GettingStarted(device,ROS2Workspace,robotAddress);
pause(10)
ur = urROS2Node('RigidBodyTree',ur5e);
and modifying the associated function so it works on simulation:
function generateAndTransferLaunchScriptROS2GettingStarted(device,WorkSpaceFolder,RobotAddress)
% Open a file to write set of commands to launch simulated UR5e
% in URSim
fid=fopen(fullfile(tempdir,"launchUR5eROS2.sh"),"w+");
% launch depending on the installation of ros2 ur driver
if strcmp(WorkSpaceFolder, device.ROS2Folder)
% Launch command for binary installation
fprintf(fid,"gnome-terminal --title=\42Simulated UR5e Robot\42 -- /bin/bash -c 'source %s/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s'",device.ROS2Folder,RobotAddress);
else
% Launch command for source installation
fprintf(fid,"gnome-terminal --title=\42Simulated UR5e Robot\42 -- /bin/bash -c 'source %s/setup.bash; source %s/install/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s'",device.ROS2Folder,WorkSpaceFolder,RobotAddress);
end
fclose(fid);
% Copy file into ROS2 device
putFile(device,fullfile(tempdir,'launchUR5eROS2.sh'),'~/')
% Make the shell script executable
system(device,'chmod a+x ~/launchUR5eROS2.sh');
% Launch the script
% system(device,'./launchUR5eROS2HWSetup.sh &');
system(device,'./launchUR5eROS2.sh &'); % JL: I use this instead
end
The UR sim loger viewer indicates that the communication is reached.
However, I am getting this error:
Error using ros.internal.getEmptyMessage>getMessageDataAndInfo (line 70)
How could I solve it so I can continue with the example execution?
Screenshot of the Matlab and urSim windows:

5 Comments

Jose
Jose on 10 Apr 2024
Edited: Jose on 10 Apr 2024
After minor configuration changes, I get this new error:
% >> ur = urROS2Node('RigidBodyTree',ur5e)
% Using user-defined rigid body tree model.
% Error using urROS2Node/initializeHardware (line 347)
% Unable to configure the robot and a loaded program correctly. See the below information to
% understand the possible scenarios and their resolution.
% Scenario 1. You are creating this object for the first time after changing the robot mode to
% remote control mode without saving the program .
% - Resolution: Save the program on the teach pendent before changing it into remote control
% mode.
% Scenario 2. ROS2 connection error between MATLAB and teach pendent.
% - Resolution: Check the teach pendant for the errors and try to re-initiate the process.
%
% Error in urROS2Node (line 257)
% obj.initializeHardware;
Jose
Jose on 11 Apr 2024
After going deeper into this, I have realized that the matlab urcap is not installed on the ursim. The problem is that the usb disk is not recognized. I'll try to fix it. In the meanwhile, any suggestions will be welcome.
Jishnu Subramonian
Jishnu Subramonian on 17 Apr 2024
Edited: Jishnu Subramonian on 17 Apr 2024
Hello Jose,
It appears to me the necessary ur_dashboard_msgs for service creation is unavailable. We set this up while performing the Hardware setup screens, in case this was not performed earlier could you complete it by following steps below:
  1. Go to the Home tab.
  2. Select Add-Ons > Manage Add-Ons.
  3. Locate the Robotics System Toolbox Support Package for Universal Robots UR Series Manipulator and select the gear icon adjacent to it.
  4. This opens the Setup screen, choose ROS2 and follow the instructions to complete the setup.
After completing the setup, try creating the urROS2Node again, if the issue persist pl. let us know.
Thanks
Jose
Jose on 17 Apr 2024
Hi Jishnu,
thank you very much for your response. I followed the suggested steps, but unfortunatly I still cannot create the urnode. This is the new error:
```
Error using urROS2Node (line 202)
ROS 2 action server "/scaled_joint_trajectory_controller/follow_joint_trajectory" is currently unavailable. Relaunch the ROS2 driver node and create urROS2Node.
```
However, I managed to control a real UR10e robot. So, my issue is clearly with the URsim, and I will work directly with the real robot.
Thanks for the support.
Hello Jose,
Can you please create a help ticket with MATLAB techincal support so that we can proceed further with the debugging reg. why you were not able to proceed with the URSim,
Thanks

Sign in to comment.

Answers (1)

Wess Gates
Wess Gates on 12 Jul 2024
Edited: Wess Gates on 12 Jul 2024

0 votes

I am having a similar issue I have posted on the UR Forum. Insights for troubleshooting would be appreciated. It may also be possible some instructions following the MathWorks/UR pages are missing regarding spooling up the ROS2 driver perhaps as well as any variances for using a URSim Docker image rather than a virtual machine workflow?
For example in Hardware Setup Window for Joint Acquisition the second troubleshooting step suggest looking for "error messages on the terminal in the host machine with ROS2" this seems to suggest ROS2 perhaps should be spooled up or something but none of the documented steps seem to suggest whether this should be done by the user or if it is handeled by the setup in the background?

2 Comments

Hello Wess,
Can you please create a help ticket with MATLAB techincal support so that we can proceed further with the debugging,
Thanks
Wess Gates
Wess Gates on 16 Jul 2024
Edited: Wess Gates on 16 Jul 2024
Sure. I will create a help ticket. I will also describe a few things I have tried.
  1. On my home network I have a 192.x network and I was able to connect to the URSim docker via the MathWorks workflow.
  2. At work we use a 10.x network. In both cases (at home and at work) I used: docker rm network ursim_net just to be safe and make sure the bridge is bering created correctly. I cannot seem to get the workflow to work on 10.x network but I am unclear if this is directly related or not.
  3. Please see the attached image. When I try to complete the hardware setup on the 10.x netwrok the URSim terminates when requesting the joint angles.
  4. One feature that maybe helpful is allowing the selection of the UR model i.e. UR5e or UR10e during the Setup process etc... since this impacts which scripts should be launched

Sign in to comment.

Asked:

on 10 Apr 2024

Edited:

on 16 Jul 2024

Community Treasure Hunt

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

Start Hunting!