可正常于显示rviz中显示模型
This commit is contained in:
43
simulation_ws/trolley/launch/display.launch.py
Normal file
43
simulation_ws/trolley/launch/display.launch.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
import launch
|
||||
import launch_ros
|
||||
from launch_ros.actions import Node
|
||||
from launch import LaunchDescription
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
import xacro
|
||||
|
||||
def generate_launch_description():
|
||||
# 获取默认的urdf文件路径
|
||||
pkg_trolley = get_package_share_directory('trolley')
|
||||
xacro_path = os.path.join(pkg_trolley, 'urdf', 'miniBox.urdf.xacro')
|
||||
# 处理xacro文件,生成robot_description参数
|
||||
robot_description_config = xacro.process_file(xacro_path).toxml()
|
||||
|
||||
# 创建Node节点,发布robot_description参数
|
||||
rsp = Node(
|
||||
package='robot_state_publisher',
|
||||
executable='robot_state_publisher',
|
||||
output='screen',
|
||||
parameters=[{'robot_description': robot_description_config}]
|
||||
)
|
||||
|
||||
# 给可动关节提供 joint_states 发布器
|
||||
jsp=Node(
|
||||
package='joint_state_publisher',
|
||||
executable='joint_state_publisher',
|
||||
output='screen',
|
||||
parameters=[]
|
||||
)
|
||||
|
||||
rviz = Node(
|
||||
package='rviz2',
|
||||
executable='rviz2',
|
||||
output='screen',
|
||||
arguments=[]
|
||||
)
|
||||
|
||||
return launch.LaunchDescription([
|
||||
rsp,
|
||||
jsp,
|
||||
rviz
|
||||
])
|
||||
Reference in New Issue
Block a user