From 240f581bc25c2977cec2966921b110cb108cf3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=98=B1=E5=8D=93?= <18813864538@163.com> Date: Sun, 14 Dec 2025 15:45:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=92=8C=E6=98=BE=E7=A4=BA=E6=9C=BA=E5=99=A8=E4=BA=BA=E6=89=80?= =?UTF-8?q?=E7=94=A8=E7=9A=84launch=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 创建和显示机器人所用的launch文件 | 41 -------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 创建和显示机器人所用的launch文件 diff --git a/创建和显示机器人所用的launch文件 b/创建和显示机器人所用的launch文件 deleted file mode 100644 index e4a6498..0000000 --- a/创建和显示机器人所用的launch文件 +++ /dev/null @@ -1,41 +0,0 @@ -import launch -import launch_ros -from ament_index_python.packages import get_package_share_directory -import os -def generate_launch_description(): - #获取urdf路径 - urdf_package_path = get_package_share_directory("fishbot_description") - default_rviz_config_path = os.path.join(urdf_package_path,"config","display_robot_model.rviz") - default_urdf_path = os.path.join(urdf_package_path,"urdf","first_robot.urdf") - #声明一个urdf目录的参数,方便修改 - action_declare_arg_mode_path = launch.actions.DeclareLaunchArgument( - name="model",default_value=str(default_urdf_path),description="加载模型文件路径" - ) - #通过文件路径,获取内容,并转化成数值对象,以供传入 robot_state_publisher - substitutions_command_result = launch.substitutions.Command(["xacro ",launch.substitutions.LaunchConfiguration("model")]) - - robot_description_value = launch_ros.parameter_descriptions.ParameterValue(substitutions_command_result,value_type=str) - - action_robot_state_publisher = launch_ros.actions.Node( - package="robot_state_publisher", - executable="robot_state_publisher", - parameters=[{f"robot_description":robot_description_value}] - ) - - action_joint_state_publisher = launch_ros.actions.Node( - package="joint_state_publisher", - executable="joint_state_publisher" - ) - - action_rviz_node = launch_ros.actions.Node( - package="rviz2", - executable="rviz2", - arguments=["-d",default_rviz_config_path] - ) - - return launch.LaunchDescription([ - action_declare_arg_mode_path, - action_robot_state_publisher, - action_joint_state_publisher, - action_rviz_node, - ]) \ No newline at end of file