Main Content

Troubleshooting Connectivity Issue with ROS Action Server

Issue

After you install ROS packages and dependencies on a Linux Virtual Machine (VM), which is accessed from the same Windows PC with the support package installed, the following error appears when you try to establish connection using the urROSNode or universalrobot objects:

Error using codertarget.manipROSInterface.manipulatorROSInterface/initializeROSActionClient (line 359)

The ROS action server "/pos_joint_traj_controller/follow_joint_trajectory" is currently unavailable.

Solution

Initiate ROS Driver and Verify Action Server

You need to initiate the ROS Driver on the ROS Machine, by following the below steps on your Ubuntu PC. In the steps, ROS_IP refers to the IP address of the machine on which ROS is operating, while the robot_ip refers to the IP address of the robot:

  1. Open the Ubuntu terminal and run these commands. Change the value for ROS_IP accordingly.

    ~/ur_ws$ source devel/setup.bash 
    ~/ur_ws$ export ROS_IP=192.168.X.X

    Then, launch URSim or Gazebo based on your setup.

    To launch URSim, run this command on the Ubuntu terminal:

    ~/ur_ws$ roslaunch ur_robot_driver ur5e_bringup.launch robot_ip:=127.0.0.1

    To launch Gazebo, run this command on the Ubuntu terminal:

    ~/ur_ws$ roslaunch ur_gazebo ur5e_bringup.launch

  2. On the Ubuntu terminal, run the command rostopic list, and verify if the ROS action server is up on terminal. The command must return the following action servers with actions cancel, feedback, and so on:

    • For URSim: pos_joint_traj_controller and scaled_ pos_joint_traj_controller

    • For Gazebo: pos_joint_traj_controller

    If the action servers are not listed, perform Step 1 again (initiate ROS drivers)

Verify if MATLAB Detects Action Server

On the MATLAB command window, perform these steps:

  1. As part of the Hardware Setup process, you would have completed the step to register the dashboard_msgs. Verify if this was successful in MATLAB, by running the following command in the MATLAB command window:

    status = codertarget.manipROSInterface.addCustomROSmsg('ur')

  2. Create the urROSNode or universalrobot object, ur (replace X.X based on the actual IP).

    ur = urROSNode(“192.168.X.X”)

Update Network Settings

If the above two solutions do not resolve the issue, you need to update the network settings. Update the setting of Windows network to 'Private' and configure the virtual machine (VM) to use a 'Bridged Network' by following these steps:

  1. On Windows:

    Change the Network & internet settings to Private network as seen the image below. For detailed steps, refer to Make a Wi-Fi network public or private in Windows - Microsoft Support.

  2. On the VM:

    Switch the Network Adapter settings to Bridged (Automatic) and wait for about 2 minutes to see the IP address update.

  3. Perform the two steps mentioned in the previous section (Verify if MATLAB Detects Action Server) to verify that the connection works from MATLAB.