ros-simulation / gazebo_ros_pkgs

Wrappers, tools and additional API's for using ROS with Gazebo
http://wiki.ros.org/gazebo_ros_pkgs
753 stars 770 forks source link

Cannot spawn mesh data in XML file using Spawn_Entity.py #1191

Open Drojas251 opened 3 years ago

Drojas251 commented 3 years ago

Description I am trying to spawn a robot model, described in a urdf, into gazebo 11 from a ros2 python launch file by using the spawn_entity.py node. I am publishing the xml data onto a topic with robot_state_publisher and reading that data from the topic with the spawn_entity node. I am able to spawn the robot successfully if the urdf is made up of built in geomotires ( box, cylinder..), however when I use a mesh to build my robot, spawn_entity node does now spawn those links with a mesh file in gazebo. I have tried multiple files types ( dae, stl, obj) and tried different urdf's.

To Reproduce I have used the launch file from gazebo_ros2_control_demos exactly. The only changes I made was just adding an additional link and joint to the urdf file that was used in that demo, and used a mesh for that link. I have provided a screen shot below. `

xacro_file = os.path.join(gazebo_ros2_control_demos_path,
                          'urdf',
                          'test_cart_position.xacro.urdf')

doc = xacro.parse(open(xacro_file))
xacro.process_doc(doc)
params = {'robot_description': doc.toxml()}

node_robot_state_publisher = Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    output='screen',
    parameters=[params]
)

spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                    arguments=['-topic', 'robot_description',
                               '-entity', 'cartpole'],
                    output='screen')

`

Expected behavior

I have made sure my files are in the shared folder and that everything is linked properly. If I can spawn a urdf with basic shapes, then I know that my launch file and the node is working as it should. However, I suspect that the mesh information is not completely being transferred from the robot_state_publisher topic to the spawn_entity node.

Screenshots

Here is the portion of the URDF that includes the mesh. I have simply added this link and joint to the test_cart_position.xacro.urdf file in gazebo_ros2_control_demo. The result in gazebo does not display the mesh model. As I said before, I tried multiple file types.

Screenshot from 2020-11-10 17-14-10

Environment (please complete the following information):

Additional context

I have tried the -database argument in the spawn_entity node and passed a gazebo model form the model data base, which is in sdf format and contains meshes, and that worked fine. However, publishing a urdf that contains meshes with robot stat publisher does not work for me.

KACHAPPILLY2021 commented 2 years ago

I know its late but still, try this. In mesh filename details, change 'package://' to absolute path on your system for every links. Hope this works

munjer1990 commented 10 months ago

hi Thanks a lot KACHAPPILLY2021. my case was filename="package://my_robot_description/meshes/.....STL" I changed it to filename="$(find my_robot_description)/meshes/.....STL" and meshes were appeared in Gazebo

ZAIDALI5 commented 10 months ago

@munjer1990 @KACHAPPILLY2021

I still have the same issue, I tried to put absolute path, tried $(find package), but nothing working. Ubuntu Humble 22.04 [spawn_entity.py-4] [INFO] [1699594524.611441036] [spawn_entity]: Waiting for entity xml on arduino_urdf the package is called arduino_urdf, which inside has meshes folder and urdf folder and launch folder.


this is from arduinobot.urdf.xacro

image


this is full gazebo.launch.py

import os from ament_index_python.packages import get_package_share_directory, get_package_prefix

from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, SetEnvironmentVariable from launch.substitutions import Command, LaunchConfiguration from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node from launch_ros.parameter_descriptions import ParameterValue

def generate_launch_description(): arduinobot_description_dir = get_package_share_directory('arduino_urdf') arduinobot_description_share = os.path.join(get_package_prefix('arduino_urdf'), 'share') gazebo_ros_dir = get_package_share_directory('gazebo_ros')

model_arg = DeclareLaunchArgument(name='model', default_value=os.path.join(
                                    arduinobot_description_dir, 'urdf', 'arduinobot.urdf.xacro'
                                    ),
                                  description='Absolute path to robot urdf file'
)

env_var = SetEnvironmentVariable('GAZEBO_MODEL_PATH', arduinobot_description_share)

robot_description = ParameterValue(Command(['xacro ', LaunchConfiguration('model')]),
                                   value_type=str)

robot_state_publisher_node = Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    parameters=[{'robot_description': robot_description}]
)

start_gazebo_server = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(gazebo_ros_dir, 'launch', 'gzserver.launch.py')
    )
)

start_gazebo_client = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(gazebo_ros_dir, 'launch', 'gzclient.launch.py')
    )
)

spawn_robot = Node(package='gazebo_ros', executable='spawn_entity.py',
                    arguments=['-topic', 'arduino_urdf',
                               '-entity', 'arduinobot'
                              ],
                    output='screen'
)

return LaunchDescription([
    env_var,
    model_arg,
    start_gazebo_server,
    start_gazebo_client,
    robot_state_publisher_node,
    spawn_robot
])
RobinWolf commented 4 months ago

Is there a fix yet? I suffer from the exact same problem!

rahgirrafi commented 3 months ago

In the gazebo launch file, try adding positional arguments like this:

spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description', '-entity', 'cartpole', "-x", "0.0", "-y", "0.0", "-z", "0.0" ], output='screen')