ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

UR Robot arm + Gazebo Simulation

asked 2023-07-24 16:19:28 -0600

Jacob G. gravatar image

Hi guys, ROS-newbie here :-)

Specs:

Version of Ubuntu: 20.04 -- ROS2: Galactic -- Kernel version: 5.15.0-76-generic

The code

  1. I have built the Galactic version of this: https://github.com/UniversalRobots/Un... in a workspace
  2. I generated a static URDF file using from the ros2 run xacro xacro --inorder ur.urdf.xacro ur_type:=ur5 > ur5_robot.urdf. This converted the .urdf.xacro file from Github to a .urdf file that Gazebo can read. (To my understanding, Gazebo needs a static URDF file in order to function properly.) - I will supply the URDF file in the bottom of this post, since it is very long, and I don't want to crowd the post up here :D.
  3. I created a launch file that now calls this URDF file and gazebo_ros:

Which is here:

from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import ThisLaunchFileDir
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():

urdf = '/home/user/ur_gazebo_ws/src/ur_gazebo/launch/ur5_robot.urdf'
gazebo_ros_pkg_path = get_package_share_directory('gazebo_ros')

return LaunchDescription([
    IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(gazebo_ros_pkg_path, 'launch', 'gazebo.launch.py')
        )
    ),
    Node(
        package='gazebo_ros', 
        executable='spawn_entity.py', 
        arguments=['-entity', 'ur5', '-file', urdf], 
        output='screen'
    ),
])

The problem:

I am trying to run Gazebo simulation with a UR robot arm. (I don't care about changing versions of ROS or Ubuntu if that is required. What I care about, is being able to at least use Python3, since another part of my project requires that.)

I can get Gazebo up and running, and it also tells me that the UR5 arm was successfully loaded into the simulation. There are no visible errors in the terminal. Here is the output from the terminal:

INFO] [gzserver-1]: process started with pid [43474]
[INFO] [gzclient   -2]: process started with pid [43476]
[INFO] [spawn_entity.py-3]: process started with pid [43479]
[spawn_entity.py-3] [INFO] [1690231181.844320968] [spawn_entity]: Spawn Entity started
[spawn_entity.py-3] [INFO] [1690231181.844773432] [spawn_entity]: Loading entity XML from file /home/user/ur_gazebo_ws/src/ur_gazebo/launch/ur5_robot.urdf
[spawn_entity.py-3] [INFO] [1690231181.845936152] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5
[spawn_entity.py-3] [INFO] [1690231181.846375949] [spawn_entity]: Waiting for service /spawn_entity
[spawn_entity.py-3] [INFO] [1690231182.601153155] [spawn_entity]: Calling service /spawn_entity
[spawn_entity.py-3] [INFO] [1690231182.827232744] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [ur5]
[INFO] [spawn_entity.py-3]: process has finished cleanly [pid 43479]

Here is a screenshot of Gazebo, where you can see that the UR arm in fact is loaded into the simulation: image description

It seems to me that something is wrong with the .urdf file that Gazebo is using to create the robot, but I know very little about ROS, so I might be wrong.

If you want to take a look, here is the .urdf file, here is a link: https://drive.google.com/file/d/1qbU1...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-24 22:23:33 -0600

danzimmerman gravatar image

updated 2023-07-24 22:24:39 -0600

I don't think it's necessarily your problem because it looks like you already have absolute paths to your meshes in your URDF but I believe you will want to pass sim_gazebo:=true to the .xacro

Even if that doesn't fix the robot visibility issue, without that argument you won't have the right ros2_control plugin loaded to control the robot. Maybe that will have some effect on visibility too, I'm not 100% sure about that.

I'd also double-check that the meshes are actually present in the install directory of your ur_desc_ws as specified in the URDF. Did you run colcon build on that workspace?

edit flag offensive delete link more

Comments

Hey man, really appreciate the help!

After double checking the path, i found an error. Correcting that so it lead to the correct mesh files made it work!

Also, if someone else wants to add that sim_gazebo:=true to the .xacro, here is what it should be in .urdf format, (as far as I did it at least)

<gazebo>
  <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
     <robotNamespace></robotNamespace>
    <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
  </plugin>
</gazebo>

I added this in the end of the <robot> tag.

Jacob G. gravatar image Jacob G.  ( 2023-07-25 13:48:03 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2023-07-24 16:19:28 -0600

Seen: 365 times

Last updated: Jul 24 '23