小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
Gazebo中只显示机器人名称而不显示模型
-
背景:Ubuntu 22.04, ROS2 humble, gazebo 11
问题描述:启动launch文件后,报错,Gazebo中只显示机器人名称而不显示模型,rviz正常启动并显示。(这个是用了下载的ur—description功能包)
[Err] [Model.cc:123] Error Code 23 Msg: FrameAttachedToGraph error, Non-LINK vertex with name [model] is disconnected; it should have 1 outgoing edge in MODEL attached_to graph.
[gazebo-4] [Err] [Model.cc:123] Error Code 23 Msg: Graph with model scope has sink vertex named [model] when starting from vertex with name [model], which is not permitted.
[spawn_entity.py-3] [INFO] [1724511616.807076118] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [ur5e]
[INFO] [spawn_entity.py-3]: process has finished cleanly [pid 17160]
[gazebo-4] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call
[joint_state_publisher_gui-1] [INFO] [1724511617.525790132] [joint_state_publisher]: Centering尝试过的解决方法:看到网上说向链接添加惯性解决,但是我看到xacro中有这个惯性,故不知道怎么办了
-
针对您遇到的问题,这里有几个可能的解决步骤和检查点,这些可以帮助您诊断和解决Gazebo中只显示机器人名称而不显示模型的问题:
-
检查URDF/XACRO文件:
- 确保URDF或XACRO文件中所有链接(link)都正确连接到了关节(joint)。每个链接都应该通过至少一个关节连接到另一个链接或基础框架。
- 检查是否有任何链接或关节的名称重复或拼写错误。
- 确保每个链接都有正确的惯性(inertial)标签,即使您已经看到它存在,也请再次确认其参数(如质量、惯性矩阵等)是否合理。
-
检查SDF文件:
- 当您使用ROS和Gazebo时,URDF/XACRO文件通常会被转换为SDF文件。检查生成的SDF文件是否包含所有必要的元素,特别是链接和关节的定义。
- 您可以使用
ros2 run gazebo_ros gazebo_models
命令来查看或生成SDF文件,并检查其内容。
-
检查Gazebo插件和传感器:
- 如果您的URDF/XACRO文件中包含了Gazebo特定的插件或传感器,请确保这些插件已正确安装,并且与您的ROS2和Gazebo版本兼容。
- 检查是否有任何插件或传感器配置错误,这可能会导致加载模型时出现问题。
-
检查ROS2和Gazebo的日志:
- 仔细查看ROS2和Gazebo的日志文件,以获取更多关于错误的详细信息。这些日志通常可以提供关于哪个部分或哪个文件导致问题的线索。
-
更新和兼容性:
- 确保您的ROS2和Gazebo版本是最新的,或者至少是彼此兼容的。有时,软件包的旧版本可能包含未修复的bug。
- 如果您使用的是第三方软件包(如
ur_description
),请检查其是否支持您当前的ROS2和Gazebo版本。
-
简化问题:
- 尝试使用一个简单的URDF/XACRO文件(例如,只有一个链接和一个关节的模型)来测试Gazebo是否能正确加载。这有助于确定问题是否出在您的模型文件上。
-
社区和文档:
- 查阅ROS2和Gazebo的官方文档,看看是否有其他人遇到了类似的问题,并找到了解决方案。
- 在ROS2和Gazebo的社区论坛或GitHub仓库中搜索或提问,以获取来自社区的帮助。
-
重新安装和配置:
- 如果上述步骤都无法解决问题,考虑重新安装ROS2和Gazebo,并重新配置您的环境。
希望这些步骤能帮助您解决问题!如果问题仍然存在,请提供更多的日志和配置文件信息,以便进一步分析。
以上为生成回答,仅供参考~
-
-
下面是urdf文件:ur.urdf.xacro
<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro" name="$(arg name)">
<!-- robot name parameter -->
<xacro:arg name="name" default="ur"/>
<!-- import main macro -->
<xacro:include filename="$(find ur_robotss)/urdf/ur_macro.xacro"/><!-- possible 'ur_type' values: ur3, ur3e, ur5, ur5e, ur10, ur10e, ur16e, ur20, ur30 -->
<!-- the default value should raise an error in case this was called without defining the type -->
<xacro:arg name="ur_type" default="ur5x"/><!-- parameters -->
<xacro:arg name="tf_prefix" default="" />
<xacro:arg name="joint_limit_params" default="$(find ur_robotss)/config/$(arg ur_type)/joint_limits.yaml"/>
<xacro:arg name="kinematics_params" default="$(find ur_robotss)/config/$(arg ur_type)/default_kinematics.yaml"/>
<xacro:arg name="physical_params" default="$(find ur_robotss)/config/$(arg ur_type)/physical_parameters.yaml"/>
<xacro:arg name="visual_params" default="$(find ur_robotss)/config/$(arg ur_type)/visual_parameters.yaml"/>
<xacro:arg name="transmission_hw_interface" default=""/>
<xacro:arg name="safety_limits" default="false"/>
<xacro:arg name="safety_pos_margin" default="0.15"/>
<xacro:arg name="safety_k_position" default="20"/>
<!-- ros2_control related parameters -->
<xacro:arg name="headless_mode" default="false" />
<xacro:arg name="robot_ip" default="0.0.0.0" />
<xacro:arg name="script_filename" default=""/>
<xacro:arg name="output_recipe_filename" default=""/>
<xacro:arg name="input_recipe_filename" default=""/>
<xacro:arg name="reverse_ip" default="0.0.0.0"/>
<xacro:arg name="script_command_port" default="50004"/>
<xacro:arg name="reverse_port" default="50001"/>
<xacro:arg name="script_sender_port" default="50002"/>
<xacro:arg name="trajectory_port" default="50003"/>
<!-- tool communication related parameters-->
<xacro:arg name="use_tool_communication" default="false" />
<xacro:arg name="tool_voltage" default="0" />
<xacro:arg name="tool_parity" default="0" />
<xacro:arg name="tool_baud_rate" default="115200" />
<xacro:arg name="tool_stop_bits" default="1" />
<xacro:arg name="tool_rx_idle_chars" default="1.5" />
<xacro:arg name="tool_tx_idle_chars" default="3.5" />
<xacro:arg name="tool_device_name" default="/tmp/ttyUR" />
<xacro:arg name="tool_tcp_port" default="54321" /><!-- Simulation parameters -->
<xacro:arg name="use_fake_hardware" default="false" />
<xacro:arg name="fake_sensor_commands" default="false" />
<xacro:arg name="sim_gazebo" default="false" />
<xacro:arg name="sim_ignition" default="false" />
<xacro:arg name="simulation_controllers" default="" /><!-- initial position for simulations (Fake Hardware, Gazebo, Ignition) -->
<xacro:arg name="initial_positions_file" default="$(find ur_robotss)/config/initial_positions.yaml"/><!-- convert to property to use substitution in function -->
<xacro:property name="initial_positions_file" default="$(arg initial_positions_file)"/><!-- create link fixed to the "world" -->
<link name="world" /><!-- arm -->
<xacro:ur_robot
name="$(arg name)"
tf_prefix="$(arg tf_prefix)"
parent="world"
joint_limits_parameters_file="$(arg joint_limit_params)"
kinematics_parameters_file="$(arg kinematics_params)"
physical_parameters_file="$(arg physical_params)"
visual_parameters_file="$(arg visual_params)"
transmission_hw_interface="$(arg transmission_hw_interface)"
safety_limits="$(arg safety_limits)"
safety_pos_margin="$(arg safety_pos_margin)"
safety_k_position="$(arg safety_k_position)"
use_fake_hardware="$(arg use_fake_hardware)"
fake_sensor_commands="$(arg fake_sensor_commands)"
sim_gazebo="$(arg sim_gazebo)"
sim_ignition="$(arg sim_ignition)"
headless_mode="$(arg headless_mode)"
initial_positions="${xacro.load_yaml(initial_positions_file)}"
use_tool_communication="$(arg use_tool_communication)"
tool_voltage="$(arg tool_voltage)"
tool_parity="$(arg tool_parity)"
tool_baud_rate="$(arg tool_baud_rate)"
tool_stop_bits="$(arg tool_stop_bits)"
tool_rx_idle_chars="$(arg tool_rx_idle_chars)"
tool_tx_idle_chars="$(arg tool_tx_idle_chars)"
tool_device_name="$(arg tool_device_name)"
tool_tcp_port="$(arg tool_tcp_port)"
robot_ip="$(arg robot_ip)"
script_filename="$(arg script_filename)"
output_recipe_filename="$(arg output_recipe_filename)"
input_recipe_filename="$(arg input_recipe_filename)"
reverse_ip="$(arg reverse_ip)"
script_command_port="$(arg script_command_port)"
reverse_port="$(arg reverse_port)"
script_sender_port="$(arg script_sender_port)"
trajectory_port="$(arg trajectory_port)"
>
<origin xyz="0 0 0" rpy="0 0 0" /> <!-- position robot in the world -->
</xacro:ur_robot><xacro:if value="$(arg sim_gazebo)">
<!-- Gazebo plugins -->
<gazebo reference="world">
</gazebo>
<gazebo>
<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
<parameters>$(arg simulation_controllers)</parameters>
</plugin>
</gazebo>
</xacro:if><xacro:if value="$(arg sim_ignition)">
<!-- Gazebo plugins -->
<gazebo reference="world">
</gazebo>
<gazebo>
<plugin filename="libign_ros2_control-system.so" name="ign_ros2_control::IgnitionROS2ControlPlugin">
<parameters>$(arg simulation_controllers)</parameters>
<controller_manager_node_name>$(arg tf_prefix)controller_manager</controller_manager_node_name>
</plugin>
</gazebo>
</xacro:if></robot>
-
下面是urdf文件:这是ur_common.xacro<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro">
<!--
NOTE the macros defined in this file are NOT part of the public API of this
package. Users CANNOT rely on this file being available, or stored in
this location. Nor can they rely on the existence of the two macros.
The macros store the defined properties in the scope of the caller.
However, users MUST NOT rely on these properties, their contents or their
names.Author: Ludovic Delval Contributor: Felix Messmer
-->
<xacro:macro name="cylinder_inertial" params="radius length mass *origin">
<inertial>
<mass value="${mass}" />
<xacro:insert_block name="origin" />
<inertia ixx="${0.0833333 * mass * (3 * radius * radius + length * length)}" ixy="0.0" ixz="0.0"
iyy="${0.0833333 * mass * (3 * radius * radius + length * length)}" iyz="0.0"
izz="${0.5 * mass * radius * radius}" />
</inertial>
</xacro:macro><xacro:macro name="get_visual_params" params="name:=^ type:=^" >
<xacro:property name="visual_params" value="${sec_mesh_files[name][type]}" scope="parent"/>
</xacro:macro><!-- Simplification of getting meshes. Available types can be seen in the visual_parameters.yaml (At the time of writing: visual, collision) -->
<xacro:macro name="get_mesh_path" params="name:=^ type:=^" >
<xacro:get_visual_params />
<xacro:if value="${force_abs_paths}">
<xacro:property name="mesh" value="file://$(find ${visual_params['mesh']['package']})/${visual_params['mesh']['path']}" scope="parent"/>
</xacro:if>
<xacro:unless value="${force_abs_paths}">
<xacro:property name="mesh" value="package://${visual_params['mesh']['package']}/${visual_params['mesh']['path']}" scope="parent"/>
</xacro:unless>
</xacro:macro><xacro:macro name="get_mesh" params="name type" >
xacro:get_mesh_path/
<mesh filename="${mesh}"/>
</xacro:macro><xacro:macro name="read_model_data" params="joint_limits_parameters_file kinematics_parameters_file physical_parameters_file visual_parameters_file force_abs_paths">
<xacro:property name="force_abs_paths" value="${force_abs_paths}" scope="parent"/> <!-- Read .yaml files from disk, load content into properties --> <xacro:property name="config_joint_limit_parameters" value="${xacro.load_yaml(joint_limits_parameters_file)}"/> <xacro:property name="config_kinematics_parameters" value="${xacro.load_yaml(kinematics_parameters_file)}"/> <xacro:property name="config_physical_parameters" value="${xacro.load_yaml(physical_parameters_file)}"/> <xacro:property name="config_visual_parameters" value="${xacro.load_yaml(visual_parameters_file)}"/> <!-- Extract subsections from yaml dictionaries --> <xacro:property name="sec_limits" value="${config_joint_limit_parameters['joint_limits']}"/> <xacro:property name="sec_dh_parameters" value="${config_physical_parameters['dh_parameters']}"/> <xacro:property name="sec_offsets" value="${config_physical_parameters['offsets']}"/> <xacro:property name="sec_inertia_parameters" value="${config_physical_parameters['inertia_parameters']}" /> <xacro:property name="sec_mesh_files" value="${config_visual_parameters['mesh_files']}" scope="parent"/> <xacro:property name="sec_kinematics" value="${config_kinematics_parameters['kinematics']}" /> <!-- JOINTS LIMIT PARAMETERS --> <xacro:property name="shoulder_pan_lower_limit" value="${sec_limits['shoulder_pan_joint']['min_position']}" scope="parent"/> <xacro:property name="shoulder_pan_upper_limit" value="${sec_limits['shoulder_pan_joint']['max_position']}" scope="parent"/> <xacro:property name="shoulder_pan_velocity_limit" value="${sec_limits['shoulder_pan_joint']['max_velocity']}" scope="parent"/> <xacro:property name="shoulder_pan_effort_limit" value="${sec_limits['shoulder_pan_joint']['max_effort']}" scope="parent"/> <xacro:property name="shoulder_lift_lower_limit" value="${sec_limits['shoulder_lift_joint']['min_position']}" scope="parent"/> <xacro:property name="shoulder_lift_upper_limit" value="${sec_limits['shoulder_lift_joint']['max_position']}" scope="parent"/> <xacro:property name="shoulder_lift_velocity_limit" value="${sec_limits['shoulder_lift_joint']['max_velocity']}" scope="parent"/> <xacro:property name="shoulder_lift_effort_limit" value="${sec_limits['shoulder_lift_joint']['max_effort']}" scope="parent"/> <xacro:property name="elbow_joint_lower_limit" value="${sec_limits['elbow_joint']['min_position']}" scope="parent"/> <xacro:property name="elbow_joint_upper_limit" value="${sec_limits['elbow_joint']['max_position']}" scope="parent"/> <xacro:property name="elbow_joint_velocity_limit" value="${sec_limits['elbow_joint']['max_velocity']}" scope="parent"/> <xacro:property name="elbow_joint_effort_limit" value="${sec_limits['elbow_joint']['max_effort']}" scope="parent"/> <xacro:property name="wrist_1_lower_limit" value="${sec_limits['wrist_1_joint']['min_position']}" scope="parent"/> <xacro:property name="wrist_1_upper_limit" value="${sec_limits['wrist_1_joint']['max_position']}" scope="parent"/> <xacro:property name="wrist_1_velocity_limit" value="${sec_limits['wrist_1_joint']['max_velocity']}" scope="parent"/> <xacro:property name="wrist_1_effort_limit" value="${sec_limits['wrist_1_joint']['max_effort']}" scope="parent"/> <xacro:property name="wrist_2_lower_limit" value="${sec_limits['wrist_2_joint']['min_position']}" scope="parent"/> <xacro:property name="wrist_2_upper_limit" value="${sec_limits['wrist_2_joint']['max_position']}" scope="parent"/> <xacro:property name="wrist_2_velocity_limit" value="${sec_limits['wrist_2_joint']['max_velocity']}" scope="parent"/> <xacro:property name="wrist_2_effort_limit" value="${sec_limits['wrist_2_joint']['max_effort']}" scope="parent"/> <xacro:property name="wrist_3_lower_limit" value="${sec_limits['wrist_3_joint']['min_position']}" scope="parent"/> <xacro:property name="wrist_3_upper_limit" value="${sec_limits['wrist_3_joint']['max_position']}" scope="parent"/> <xacro:property name="wrist_3_velocity_limit" value="${sec_limits['wrist_3_joint']['max_velocity']}" scope="parent"/> <xacro:property name="wrist_3_effort_limit" value="${sec_limits['wrist_3_joint']['max_effort']}" scope="parent"/> <!-- DH PARAMETERS --> <xacro:property name="d1" value="${sec_dh_parameters['d1']}" scope="parent"/> <xacro:property name="a2" value="${sec_dh_parameters['a2']}" scope="parent"/> <xacro:property name="a3" value="${sec_dh_parameters['a3']}" scope="parent"/> <xacro:property name="d4" value="${sec_dh_parameters['d4']}" scope="parent"/> <xacro:property name="d5" value="${sec_dh_parameters['d5']}" scope="parent"/> <xacro:property name="d6" value="${sec_dh_parameters['d6']}" scope="parent"/> <!-- kinematics --> <xacro:property name="shoulder_x" value="${sec_kinematics['shoulder']['x']}" scope="parent"/> <xacro:property name="shoulder_y" value="${sec_kinematics['shoulder']['y']}" scope="parent"/> <xacro:property name="shoulder_z" value="${sec_kinematics['shoulder']['z']}" scope="parent"/> <xacro:property name="shoulder_roll" value="${sec_kinematics['shoulder']['roll']}" scope="parent"/> <xacro:property name="shoulder_pitch" value="${sec_kinematics['shoulder']['pitch']}" scope="parent"/> <xacro:property name="shoulder_yaw" value="${sec_kinematics['shoulder']['yaw']}" scope="parent"/> <xacro:property name="upper_arm_x" value="${sec_kinematics['upper_arm']['x']}" scope="parent"/> <xacro:property name="upper_arm_y" value="${sec_kinematics['upper_arm']['y']}" scope="parent"/> <xacro:property name="upper_arm_z" value="${sec_kinematics['upper_arm']['z']}" scope="parent"/> <xacro:property name="upper_arm_roll" value="${sec_kinematics['upper_arm']['roll']}" scope="parent"/> <xacro:property name="upper_arm_pitch" value="${sec_kinematics['upper_arm']['pitch']}" scope="parent"/> <xacro:property name="upper_arm_yaw" value="${sec_kinematics['upper_arm']['yaw']}" scope="parent"/> <xacro:property name="forearm_x" value="${sec_kinematics['forearm']['x']}" scope="parent"/> <xacro:property name="forearm_y" value="${sec_kinematics['forearm']['y']}" scope="parent"/> <xacro:property name="forearm_z" value="${sec_kinematics['forearm']['z']}" scope="parent"/> <xacro:property name="forearm_roll" value="${sec_kinematics['forearm']['roll']}" scope="parent"/> <xacro:property name="forearm_pitch" value="${sec_kinematics['forearm']['pitch']}" scope="parent"/> <xacro:property name="forearm_yaw" value="${sec_kinematics['forearm']['yaw']}" scope="parent"/> <xacro:property name="wrist_1_x" value="${sec_kinematics['wrist_1']['x']}" scope="parent"/> <xacro:property name="wrist_1_y" value="${sec_kinematics['wrist_1']['y']}" scope="parent"/> <xacro:property name="wrist_1_z" value="${sec_kinematics['wrist_1']['z']}" scope="parent"/> <xacro:property name="wrist_1_roll" value="${sec_kinematics['wrist_1']['roll']}" scope="parent"/> <xacro:property name="wrist_1_pitch" value="${sec_kinematics['wrist_1']['pitch']}" scope="parent"/> <xacro:property name="wrist_1_yaw" value="${sec_kinematics['wrist_1']['yaw']}" scope="parent"/> <xacro:property name="wrist_2_x" value="${sec_kinematics['wrist_2']['x']}" scope="parent"/> <xacro:property name="wrist_2_y" value="${sec_kinematics['wrist_2']['y']}" scope="parent"/> <xacro:property name="wrist_2_z" value="${sec_kinematics['wrist_2']['z']}" scope="parent"/> <xacro:property name="wrist_2_roll" value="${sec_kinematics['wrist_2']['roll']}" scope="parent"/> <xacro:property name="wrist_2_pitch" value="${sec_kinematics['wrist_2']['pitch']}" scope="parent"/> <xacro:property name="wrist_2_yaw" value="${sec_kinematics['wrist_2']['yaw']}" scope="parent"/> <xacro:property name="wrist_3_x" value="${sec_kinematics['wrist_3']['x']}" scope="parent"/> <xacro:property name="wrist_3_y" value="${sec_kinematics['wrist_3']['y']}" scope="parent"/> <xacro:property name="wrist_3_z" value="${sec_kinematics['wrist_3']['z']}" scope="parent"/> <xacro:property name="wrist_3_roll" value="${sec_kinematics['wrist_3']['roll']}" scope="parent"/> <xacro:property name="wrist_3_pitch" value="${sec_kinematics['wrist_3']['pitch']}" scope="parent"/> <xacro:property name="wrist_3_yaw" value="${sec_kinematics['wrist_3']['yaw']}" scope="parent"/> <!-- OFFSETS --> <xacro:property name="shoulder_offset" value="${sec_offsets['shoulder_offset']}" scope="parent"/> <xacro:property name="elbow_offset" value="${sec_offsets['elbow_offset']}" scope="parent"/> <!-- INERTIA PARAMETERS --> <!-- mass --> <xacro:property name="base_mass" value="${sec_inertia_parameters['base_mass']}" scope="parent"/> <xacro:property name="shoulder_mass" value="${sec_inertia_parameters['shoulder_mass']}" scope="parent"/> <xacro:property name="upper_arm_mass" value="${sec_inertia_parameters['upper_arm_mass']}" scope="parent"/> <xacro:property name="upper_arm_inertia_offset" value="${sec_inertia_parameters['upper_arm_inertia_offset']}" scope="parent"/> <xacro:property name="forearm_mass" value="${sec_inertia_parameters['forearm_mass']}" scope="parent"/> <xacro:property name="wrist_1_mass" value="${sec_inertia_parameters['wrist_1_mass']}" scope="parent"/> <xacro:property name="wrist_2_mass" value="${sec_inertia_parameters['wrist_2_mass']}" scope="parent"/> <xacro:property name="wrist_3_mass" value="${sec_inertia_parameters['wrist_3_mass']}" scope="parent"/> <!-- link inertia parameter --> <xacro:property name="intertia_links" value="${sec_inertia_parameters['links']}" scope="parent"/> <xacro:property name="base_inertia_radius" value="${intertia_links['base']['radius']}" scope="parent"/> <xacro:property name="base_inertia_length" value="${intertia_links['base']['length']}" scope="parent"/> <xacro:property name="shoulder_inertia_radius" value="${intertia_links['shoulder']['radius']}" scope="parent"/> <xacro:property name="shoulder_inertia_length" value="${intertia_links['shoulder']['length']}" scope="parent"/> <xacro:property name="upperarm_inertia_radius" value="${intertia_links['upperarm']['radius']}" scope="parent"/> <xacro:property name="upperarm_inertia_length" value="${intertia_links['upperarm']['length']}" scope="parent"/> <xacro:property name="forearm_inertia_radius" value="${intertia_links['forearm']['radius']}" scope="parent"/> <xacro:property name="forearm_inertia_length" value="${intertia_links['forearm']['length']}" scope="parent"/> <xacro:property name="wrist_1_inertia_radius" value="${intertia_links['wrist_1']['radius']}" scope="parent"/> <xacro:property name="wrist_1_inertia_length" value="${intertia_links['wrist_1']['length']}" scope="parent"/> <xacro:property name="wrist_2_inertia_radius" value="${intertia_links['wrist_2']['radius']}" scope="parent"/> <xacro:property name="wrist_2_inertia_length" value="${intertia_links['wrist_2']['length']}" scope="parent"/> <xacro:property name="wrist_3_inertia_radius" value="${intertia_links['wrist_3']['radius']}" scope="parent"/> <xacro:property name="wrist_3_inertia_length" value="${intertia_links['wrist_3']['length']}" scope="parent"/> <!-- center of mass --> <xacro:property name="prop_shoulder_cog" value="${sec_inertia_parameters['center_of_mass']['shoulder_cog']}" scope="parent"/> <xacro:property name="prop_upper_arm_cog" value="${sec_inertia_parameters['center_of_mass']['upper_arm_cog']}" scope="parent"/> <xacro:property name="prop_forearm_cog" value="${sec_inertia_parameters['center_of_mass']['forearm_cog']}" scope="parent"/> <xacro:property name="prop_wrist_1_cog" value="${sec_inertia_parameters['center_of_mass']['wrist_1_cog']}" scope="parent"/> <xacro:property name="prop__wrist_2_cog" value="${sec_inertia_parameters['center_of_mass']['wrist_2_cog']}" scope="parent"/> <xacro:property name="prop_wrist_3_cog" value="${sec_inertia_parameters['center_of_mass']['wrist_3_cog']}" scope="parent"/> <xacro:property name="shoulder_cog" value="${prop_shoulder_cog['x']} ${prop_shoulder_cog['y']} ${prop_shoulder_cog['z']}" scope="parent"/> <xacro:property name="upper_arm_cog" value="${prop_upper_arm_cog['x']} ${prop_upper_arm_cog['y']} ${prop_upper_arm_cog['z']}" scope="parent"/> <xacro:property name="forearm_cog" value="${prop_forearm_cog['x']} ${prop_forearm_cog['y']} ${prop_forearm_cog['z']}" scope="parent"/> <xacro:property name="wrist_1_cog" value="${prop_wrist_1_cog['x']} ${prop_wrist_1_cog['y']} ${prop_wrist_1_cog['z']}" scope="parent"/> <xacro:property name="wrist_2_cog" value="${prop__wrist_2_cog['x']} ${prop__wrist_2_cog['y']} ${prop__wrist_2_cog['z']}" scope="parent"/> <xacro:property name="wrist_3_cog" value="${prop_wrist_3_cog['x']} ${prop_wrist_3_cog['y']} ${prop_wrist_3_cog['z']}" scope="parent"/> <!-- cylinder radius --> <xacro:property name="shoulder_radius" value="${sec_inertia_parameters['shoulder_radius']}" scope="parent"/> <xacro:property name="upper_arm_radius" value="${sec_inertia_parameters['upper_arm_radius']}" scope="parent"/> <xacro:property name="elbow_radius" value="${sec_inertia_parameters['elbow_radius']}" scope="parent"/> <xacro:property name="forearm_radius" value="${sec_inertia_parameters['forearm_radius']}" scope="parent"/> <xacro:property name="wrist_radius" value="${sec_inertia_parameters['wrist_radius']}" scope="parent"/> <!--KINEMATICS HASH--> <xacro:property name="kinematics_hash" value="${sec_kinematics['hash']}" scope="parent"/>
</xacro:macro>
</robot> -
ur_macro.xacro
<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro">
<!--
Base UR robot series xacro macro.NOTE this is NOT a URDF. It cannot directly be loaded by consumers expecting a flattened '.urdf' file. See the top-level '.xacro' for that (but note that .xacro must still be processed by the xacro command). This file models the base kinematic chain of a UR robot, which then gets parameterised by various configuration files to convert it into a UR3(e), UR5(e), UR10(e) or UR16e. NOTE the default kinematic parameters (i.e., link lengths, frame locations, offsets, etc) do not correspond to any particular robot. They are defaults only. There WILL be non-zero offsets between the Forward Kinematics results in TF (i.e., robot_state_publisher) and the values reported by the Teach Pendant. For accurate (and robot-specific) transforms, the 'kinematics_parameters_file' parameter MUST point to a .yaml file containing the appropriate values for the targeted robot. If using the UniversalRobots/Universal_Robots_ROS_Driver, follow the steps described in the readme of that repository to extract the kinematic calibration from the controller and generate the required .yaml file. Main author of the migration to yaml configs Ludovic Delval.
-->
<xacro:include filename="$(find ur_robotss)/urdf/ur_transmissions.xacro" />
<xacro:include filename="$(find ur_robotss)/urdf/ur_common.xacro" /><xacro:macro name="ur_robot" params="
name
tf_prefix
parent
*origin
joint_limits_parameters_file
kinematics_parameters_file
physical_parameters_file
visual_parameters_file
generate_ros2_control_tag:=true
transmission_hw_interface:=hardware_interface/PositionJointInterface
safety_limits:=false
safety_pos_margin:=0.15
safety_k_position:=20
use_fake_hardware:=false
fake_sensor_commands:=false
sim_gazebo:=false
sim_ignition:=false
headless_mode:=false
initial_positions:=${dict(shoulder_pan_joint=0.0,shoulder_lift_joint=-1.57,elbow_joint=0.0,wrist_1_joint=-1.57,wrist_2_joint=0.0,wrist_3_joint=0.0)}
use_tool_communication:=false
tool_voltage:=0
tool_parity:=0
tool_baud_rate:=115200
tool_stop_bits:=1
tool_rx_idle_chars:=1.5
tool_tx_idle_chars:=3.5
tool_device_name:=/tmp/ttyUR
tool_tcp_port:=54321
robot_ip:=0.0.0.0
script_filename:=to_be_filled_by_ur_robot_driver
output_recipe_filename:=to_be_filled_by_ur_robot_driver
input_recipe_filename:=to_be_filled_by_ur_robot_driver
reverse_port:=50001
script_sender_port:=50002
reverse_ip:=0.0.0.0
script_command_port:=50004
trajectory_port:=50003
non_blocking_read:=true
keep_alive_count:=2"> <!-- Load configuration data from the provided .yaml files --> <xacro:read_model_data joint_limits_parameters_file="${joint_limits_parameters_file}" kinematics_parameters_file="${kinematics_parameters_file}" physical_parameters_file="${physical_parameters_file}" visual_parameters_file="${visual_parameters_file}" force_abs_paths="${sim_gazebo or sim_ignition}"/> <xacro:if value="${generate_ros2_control_tag}"> <!-- ros2 control include --> <xacro:include filename="$(find ur_robotss)/urdf/ur.ros2_control.xacro" /> <!-- ros2 control instance --> <xacro:ur_ros2_control name="${name}" use_fake_hardware="${use_fake_hardware}" initial_positions="${initial_positions}" fake_sensor_commands="${fake_sensor_commands}" headless_mode="${headless_mode}" sim_gazebo="${sim_gazebo}" sim_ignition="${sim_ignition}" script_filename="${script_filename}" output_recipe_filename="${output_recipe_filename}" input_recipe_filename="${input_recipe_filename}" tf_prefix="${tf_prefix}" hash_kinematics="${kinematics_hash}" robot_ip="${robot_ip}" use_tool_communication="${use_tool_communication}" tool_voltage="${tool_voltage}" tool_parity="${tool_parity}" tool_baud_rate="${tool_baud_rate}" tool_stop_bits="${tool_stop_bits}" tool_rx_idle_chars="${tool_rx_idle_chars}" tool_tx_idle_chars="${tool_tx_idle_chars}" tool_device_name="${tool_device_name}" tool_tcp_port="${tool_tcp_port}" reverse_port="${reverse_port}" script_sender_port="${script_sender_port}" reverse_ip="${reverse_ip}" script_command_port="${script_command_port}" trajectory_port="${trajectory_port}" non_blocking_read="${non_blocking_read}" keep_alive_count="${keep_alive_count}" /> </xacro:if> <!-- Add URDF transmission elements (for ros_control) --> <!--<xacro:ur_arm_transmission prefix="${prefix}" hw_interface="${transmission_hw_interface}" />--> <!-- Placeholder for ros2_control transmission which don't yet exist --> <!-- links - main serial chain --> <link name="${tf_prefix}base_link"/> <link name="${tf_prefix}base_link_inertia"> <visual> <origin xyz="0 0 0" rpy="0 0 ${pi}"/> <geometry> <xacro:get_mesh name="base" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 ${pi}"/> <geometry> <xacro:get_mesh name="base" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${base_inertia_radius}" length="${base_inertia_length}" mass="${base_mass}"> <origin xyz="0 0 0" rpy="0 0 0" /> </xacro:cylinder_inertial> </link> <link name="${tf_prefix}shoulder_link"> <visual> <origin xyz="0 0 0" rpy="0 0 ${pi}"/> <geometry> <xacro:get_mesh name="shoulder" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 ${pi}"/> <geometry> <xacro:get_mesh name="shoulder" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${shoulder_inertia_radius}" length="${shoulder_inertia_length}" mass="${shoulder_mass}"> <origin xyz="0 0 0" rpy="0 0 0" /> </xacro:cylinder_inertial> </link> <link name="${tf_prefix}upper_arm_link"> <visual> <origin xyz="0 0 ${shoulder_offset}" rpy="${pi/2} 0 ${-pi/2}"/> <geometry> <xacro:get_mesh name="upper_arm" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 ${shoulder_offset}" rpy="${pi/2} 0 ${-pi/2}"/> <geometry> <xacro:get_mesh name="upper_arm" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${upperarm_inertia_radius}" length="${upperarm_inertia_length}" mass="${upper_arm_mass}"> <origin xyz="${-0.5 * upperarm_inertia_length} 0.0 ${upper_arm_inertia_offset}" rpy="0 ${pi/2} 0" /> </xacro:cylinder_inertial> </link> <link name="${tf_prefix}forearm_link"> <visual> <origin xyz="0 0 ${elbow_offset}" rpy="${pi/2} 0 ${-pi/2}"/> <geometry> <xacro:get_mesh name="forearm" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 ${elbow_offset}" rpy="${pi/2} 0 ${-pi/2}"/> <geometry> <xacro:get_mesh name="forearm" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${forearm_inertia_radius}" length="${forearm_inertia_length}" mass="${forearm_mass}"> <origin xyz="${-0.5 * forearm_inertia_length} 0.0 ${elbow_offset}" rpy="0 ${pi/2} 0" /> </xacro:cylinder_inertial> </link> <link name="${tf_prefix}wrist_1_link"> <xacro:get_visual_params name="wrist_1" type="visual_offset"/> <visual> <origin xyz="0 0 ${visual_params}" rpy="${pi/2} 0 0"/> <geometry> <xacro:get_mesh name="wrist_1" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 ${visual_params}" rpy="${pi/2} 0 0"/> <geometry> <xacro:get_mesh name="wrist_1" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${wrist_1_inertia_radius}" length="${wrist_1_inertia_length}" mass="${wrist_1_mass}"> <origin xyz="0 0 0" rpy="0 0 0" /> </xacro:cylinder_inertial> </link> <link name="${tf_prefix}wrist_2_link"> <xacro:get_visual_params name="wrist_2" type="visual_offset"/> <visual> <origin xyz="0 0 ${visual_params}" rpy="0 0 0"/> <geometry> <xacro:get_mesh name="wrist_2" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 ${visual_params}" rpy="0 0 0"/> <geometry> <xacro:get_mesh name="wrist_2" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${wrist_2_inertia_radius}" length="${wrist_2_inertia_length}" mass="${wrist_2_mass}"> <origin xyz="0 0 0" rpy="0 0 0" /> </xacro:cylinder_inertial> </link> <link name="${tf_prefix}wrist_3_link"> <xacro:get_visual_params name="wrist_3" type="visual_offset"/> <visual> <origin xyz="0 0 ${visual_params}" rpy="${pi/2} 0 0"/> <geometry> <xacro:get_mesh name="wrist_3" type="visual"/> </geometry> </visual> <collision> <origin xyz="0 0 ${visual_params}" rpy="${pi/2} 0 0"/> <geometry> <xacro:get_mesh name="wrist_3" type="collision"/> </geometry> </collision> <xacro:cylinder_inertial radius="${wrist_3_inertia_radius}" length="${wrist_3_inertia_length}" mass="${wrist_3_mass}"> <origin xyz="0.0 0.0 ${-0.5 * wrist_3_inertia_length}" rpy="0 0 0" /> </xacro:cylinder_inertial> </link> <!-- base_joint fixes base_link to the environment --> <joint name="${tf_prefix}base_joint" type="fixed"> <xacro:insert_block name="origin" /> <parent link="${parent}" /> <child link="${tf_prefix}base_link" /> </joint> <!-- joints - main serial chain --> <joint name="${tf_prefix}base_link-base_link_inertia" type="fixed"> <parent link="${tf_prefix}base_link" /> <child link="${tf_prefix}base_link_inertia" /> <!-- 'base_link' is REP-103 aligned (so X+ forward), while the internal frames of the robot/controller have X+ pointing backwards. Use the joint between 'base_link' and 'base_link_inertia' (a dummy link/frame) to introduce the necessary rotation over Z (of pi rad). --> <origin xyz="0 0 0" rpy="0 0 ${pi}" /> </joint> <joint name="${tf_prefix}shoulder_pan_joint" type="revolute"> <parent link="${tf_prefix}base_link_inertia" /> <child link="${tf_prefix}shoulder_link" /> <origin xyz="${shoulder_x} ${shoulder_y} ${shoulder_z}" rpy="${shoulder_roll} ${shoulder_pitch} ${shoulder_yaw}" /> <axis xyz="0 0 1" /> <limit lower="${shoulder_pan_lower_limit}" upper="${shoulder_pan_upper_limit}" effort="${shoulder_pan_effort_limit}" velocity="${shoulder_pan_velocity_limit}"/> <xacro:if value="${safety_limits}"> <safety_controller soft_lower_limit="${shoulder_pan_lower_limit + safety_pos_margin}" soft_upper_limit="${shoulder_pan_upper_limit - safety_pos_margin}" k_position="${safety_k_position}" k_velocity="0.0"/> </xacro:if> <dynamics damping="0" friction="0"/> </joint> <joint name="${tf_prefix}shoulder_lift_joint" type="revolute"> <parent link="${tf_prefix}shoulder_link" /> <child link="${tf_prefix}upper_arm_link" /> <origin xyz="${upper_arm_x} ${upper_arm_y} ${upper_arm_z}" rpy="${upper_arm_roll} ${upper_arm_pitch} ${upper_arm_yaw}" /> <axis xyz="0 0 1" /> <limit lower="${shoulder_lift_lower_limit}" upper="${shoulder_lift_upper_limit}" effort="${shoulder_lift_effort_limit}" velocity="${shoulder_lift_velocity_limit}"/> <xacro:if value="${safety_limits}"> <safety_controller soft_lower_limit="${shoulder_lift_lower_limit + safety_pos_margin}" soft_upper_limit="${shoulder_lift_upper_limit - safety_pos_margin}" k_position="${safety_k_position}" k_velocity="0.0"/> </xacro:if> <dynamics damping="0" friction="0"/> </joint> <joint name="${tf_prefix}elbow_joint" type="revolute"> <parent link="${tf_prefix}upper_arm_link" /> <child link="${tf_prefix}forearm_link" /> <origin xyz="${forearm_x} ${forearm_y} ${forearm_z}" rpy="${forearm_roll} ${forearm_pitch} ${forearm_yaw}" /> <axis xyz="0 0 1" /> <limit lower="${elbow_joint_lower_limit}" upper="${elbow_joint_upper_limit}" effort="${elbow_joint_effort_limit}" velocity="${elbow_joint_velocity_limit}"/> <xacro:if value="${safety_limits}"> <safety_controller soft_lower_limit="${elbow_joint_lower_limit + safety_pos_margin}" soft_upper_limit="${elbow_joint_upper_limit - safety_pos_margin}" k_position="${safety_k_position}" k_velocity="0.0"/> </xacro:if> <dynamics damping="0" friction="0"/> </joint> <joint name="${tf_prefix}wrist_1_joint" type="revolute"> <parent link="${tf_prefix}forearm_link" /> <child link="${tf_prefix}wrist_1_link" /> <origin xyz="${wrist_1_x} ${wrist_1_y} ${wrist_1_z}" rpy="${wrist_1_roll} ${wrist_1_pitch} ${wrist_1_yaw}" /> <axis xyz="0 0 1" /> <limit lower="${wrist_1_lower_limit}" upper="${wrist_1_upper_limit}" effort="${wrist_1_effort_limit}" velocity="${wrist_1_velocity_limit}"/> <xacro:if value="${safety_limits}"> <safety_controller soft_lower_limit="${wrist_1_lower_limit + safety_pos_margin}" soft_upper_limit="${wrist_1_upper_limit - safety_pos_margin}" k_position="${safety_k_position}" k_velocity="0.0"/> </xacro:if> <dynamics damping="0" friction="0"/> </joint> <joint name="${tf_prefix}wrist_2_joint" type="revolute"> <parent link="${tf_prefix}wrist_1_link" /> <child link="${tf_prefix}wrist_2_link" /> <origin xyz="${wrist_2_x} ${wrist_2_y} ${wrist_2_z}" rpy="${wrist_2_roll} ${wrist_2_pitch} ${wrist_2_yaw}" /> <axis xyz="0 0 1" /> <limit lower="${wrist_2_lower_limit}" upper="${wrist_2_upper_limit}" effort="${wrist_2_effort_limit}" velocity="${wrist_2_velocity_limit}"/> <xacro:if value="${safety_limits}"> <safety_controller soft_lower_limit="${wrist_2_lower_limit + safety_pos_margin}" soft_upper_limit="${wrist_2_upper_limit - safety_pos_margin}" k_position="${safety_k_position}" k_velocity="0.0"/> </xacro:if> <dynamics damping="0" friction="0"/> </joint> <joint name="${tf_prefix}wrist_3_joint" type="revolute"> <parent link="${tf_prefix}wrist_2_link" /> <child link="${tf_prefix}wrist_3_link" /> <origin xyz="${wrist_3_x} ${wrist_3_y} ${wrist_3_z}" rpy="${wrist_3_roll} ${wrist_3_pitch} ${wrist_3_yaw}" /> <axis xyz="0 0 1" /> <limit lower="${wrist_3_lower_limit}" upper="${wrist_3_upper_limit}" effort="${wrist_3_effort_limit}" velocity="${wrist_3_velocity_limit}"/> <xacro:if value="${safety_limits}"> <safety_controller soft_lower_limit="${wrist_3_lower_limit + safety_pos_margin}" soft_upper_limit="${wrist_3_upper_limit - safety_pos_margin}" k_position="${safety_k_position}" k_velocity="0.0"/> </xacro:if> <dynamics damping="0" friction="0"/> </joint> <link name="${tf_prefix}ft_frame"/> <joint name="${tf_prefix}wrist_3_link-ft_frame" type="fixed"> <parent link="${tf_prefix}wrist_3_link"/> <child link="${tf_prefix}ft_frame"/> <origin xyz="0 0 0" rpy="${pi} 0 0"/> </joint> <!-- ROS-Industrial 'base' frame - base_link to UR 'Base' Coordinates transform --> <link name="${tf_prefix}base"/> <joint name="${tf_prefix}base_link-base_fixed_joint" type="fixed"> <!-- Note the rotation over Z of pi radians - as base_link is REP-103 aligned (i.e., has X+ forward, Y+ left and Z+ up), this is needed to correctly align 'base' with the 'Base' coordinate system of the UR controller. --> <origin xyz="0 0 0" rpy="0 0 ${pi}"/> <parent link="${tf_prefix}base_link"/> <child link="${tf_prefix}base"/> </joint> <!-- ROS-Industrial 'flange' frame - attachment point for EEF models --> <link name="${tf_prefix}flange" /> <joint name="${tf_prefix}wrist_3-flange" type="fixed"> <parent link="${tf_prefix}wrist_3_link" /> <child link="${tf_prefix}flange" /> <origin xyz="0 0 0" rpy="0 ${-pi/2.0} ${-pi/2.0}" /> </joint> <!-- ROS-Industrial 'tool0' frame - all-zeros tool frame --> <link name="${tf_prefix}tool0"/> <joint name="${tf_prefix}flange-tool0" type="fixed"> <!-- default toolframe - X+ left, Y+ up, Z+ front --> <origin xyz="0 0 0" rpy="${pi/2.0} 0 ${pi/2.0}"/> <parent link="${tf_prefix}flange"/> <child link="${tf_prefix}tool0"/> </joint>
</xacro:macro>
</robot> -
@小伊 我现在提供了urdf文件,可以看看吗
-
由于我无法直接查看或接收文件(特别是像URDF文件这样的大型或特定格式的文件),我无法直接查看你提供的URDF文件。但是,我可以向你解释一些基本的步骤和技巧,以便你自己检查URDF文件并验证其是否正确。
URDF(Universal Robot Description Format)文件是一种用于描述机器人模型(包括其关节、连杆和传感器等)的XML格式文件。以下是一些检查URDF文件的基本步骤:
-
文件结构检查:
- 确保URDF文件是一个有效的XML文件。你可以使用任何文本编辑器打开它,并检查是否有未闭合的标签、拼写错误或格式错误。
- 确保文件以
<?xml version="1.0"?>
开头,并遵循XML的命名空间和结构规则。
-
使用URDF验证工具:
- 你可以使用ROS(Robot Operating System)中的
check_urdf
命令来验证URDF文件。首先,你需要确保你的环境中已经安装了ROS,并且urdfdom_py
包是可用的。 - 在终端中,你可以使用类似下面的命令来验证URDF文件(假设你的URDF文件名为
your_robot.urdf
):check_urdf your_robot.urdf
- 这个命令会输出文件是否有任何错误或警告。
- 你可以使用ROS(Robot Operating System)中的
-
可视化URDF文件:
- 使用ROS的
rviz
工具或urdf_tutorial
包中的view_urdf.launch
文件来可视化你的URDF模型。 - 确保你已经按照ROS的教程设置了你的环境,并且已经安装了必要的包。
- 使用类似下面的命令来启动可视化(假设你的URDF文件位于
~/catkin_ws/src/your_package/urdf/
目录下,并且你的ROS包已经构建):roslaunch your_package view_urdf.launch model:=path/to/your_robot.urdf
- 注意替换
your_package
和path/to/your_robot.urdf
为你的ROS包名和URDF文件的实际路径。
- 使用ROS的
-
检查物理和动力学属性:
- 确保你的URDF文件中定义了正确的质量、惯性矩阵、关节限制等物理和动力学属性。
- 这些属性对于仿真和机器人控制至关重要。
-
参考文档和社区:
- 如果你在检查或修改URDF文件时遇到任何问题,可以查阅ROS的官方文档或搜索相关的社区论坛和问答网站。
希望这些步骤对你有所帮助!如果你需要更具体的帮助,并且能够分享URDF文件的一部分内容(例如,通过代码段或错误消息),我可以提供更具体的建议。
以上为生成回答,仅供参考~
-