installed with robostack
ros2 version: ros-humble.
gazebo -v: Gazebo multi-robot simulator, version 11.12.0 (according to this post version should support <preserveFixedJoint> tag)
the problem in this command:
gz sdf -p ./hrssd.urdf > ./hrssd.sdf
its always generate almost empty sdf file (below) if <preserveFixedJoint> included, if I remove this tags, all working correctly:
<sdf version='1.7'>
<model name='high_range_self_sustainable_drone'>
<static>0</static>
<plugin name='thrust_module_plugin' filename='libthrust_module_plugin.so'>
<thrustLinkNames>thrust_module_1,thrust_module_2,thrust_module_3,thrust_module_4</thrustLinkNames>
</plugin>
</model>
</sdf>
I tried two different methods for conversion:
Semi-manually
xacro ./src/hrssd/xacro/hrssd.urdf.xacro > ./hrssd.urdf
gz sdf -p ./hrssd.urdf > ./hrssd.sdf
ros2 launch hrssd hrssd.launch.py
launch.pyimport os from launch import LaunchDescription from launch_ros.actions import Node from launch.actions import ExecuteProcess # Gazebo classic def generate_launch_description(): script_dir = os.path.dirname(os.path.realpath(__file__)) current_dir = os.path.dirname(script_dir) # Get world default_world_path = os.path.join(current_dir, 'worlds', 'default.world') # Get drone model default_model_path = os.path.join(current_dir, 'models', 'hrssd_manual.sdf') # Launch Gazebo with an empty world, replace this with your world file if needed gazebo = ExecuteProcess( cmd=['gazebo', '--verbose', default_world_path, '-s', 'libgazebo_ros_factory.so'], output='screen' ) # Node to spawn the robot in Gazebo spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-entity', 'hrssd', '-file', default_model_path], output='screen') return LaunchDescription([ gazebo, spawn_entity, ])With gazebo_ros
ros2 launch hrssd hrssd2.launch.py
hrssd2.launch.pyimport os from launch import LaunchDescription from launch.actions import ExecuteProcess, DeclareLaunchArgument from launch.substitutions import LaunchConfiguration, Command from launch_ros.actions import Node from ament_index_python.packages import get_package_share_directory def generate_launch_description(): # Define the package name package_name = 'hrssd' # Define paths pkg_dir = get_package_share_directory(package_name) default_world_path = os.path.join(pkg_dir, 'worlds', 'default.world') # Define launch arguments xacro_file = os.path.join(pkg_dir, 'xacro', 'hrssd.urdf.xacro') # Convert Xacro to URDF robot_description = Command(['xacro ', xacro_file]) # Launch Gazebo with the specified world file gazebo = ExecuteProcess( cmd=['gazebo', '--verbose', default_world_path, '-s', 'libgazebo_ros_factory.so'], output='screen' ) # Node to spawn the robot in Gazebo spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-entity', 'hrssd', '-topic', 'robot_description'], output='screen') # Node to provide the robot_description to the ROS parameter server robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', output='both', parameters=[{'robot_description': robot_description}], ) return LaunchDescription([ gazebo, robot_state_publisher, spawn_entity, ])
I manually edit sdf file, its worked correctly in gazebo. In rviz2 same story. All working.
So I am pretty sure problem is here:
gz sdf -p ./hrssd.urdf > ./hrssd.sdf
or in an underlying command that uses gazebo_ros package
usage of tag itself:
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Macro for a drone motor -->
<xacro:macro name="thrust_module" params="name parent link_position rotor_area">
<!-- Link for the motor -->
<link name="${name}">
<visual>
<origin xyz="${link_position}" rpy="0 0 0"/>
<geometry>
<cylinder length="0.1" radius="${rotor_area}"/>
</geometry>
</visual>
<collision>
<origin xyz="${link_position}" rpy="0 0 0" />
<geometry>
<cylinder length="0.1" radius="${rotor_area}"/>
</geometry>
</collision>
<inertial>
<mass value="0.2"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<!-- Joint connecting the motor to the parent link -->
<joint name="${name}_joint" type="fixed">
<origin xyz="${link_position}" rpy="0 0 0"/>
<parent link="${parent}"/>
<child link="${name}"/>
</joint>
<!-- Preserving a specific fixed joint -->
<gazebo reference="${name}_joint">
<preserveFixedJoint>true</preserveFixedJoint>
</gazebo>
</xacro:macro>
</robot>
Please, advise. Thank you!