86 lines
3.1 KiB
Python
86 lines
3.1 KiB
Python
import os
|
|
|
|
from launch import LaunchDescription
|
|
from launch.actions import DeclareLaunchArgument
|
|
from launch.substitutions import LaunchConfiguration
|
|
from launch_ros.actions import Node
|
|
|
|
|
|
def generate_launch_description():
|
|
"""启动 origincar_bridge 节点,所有参数可通过命令行覆盖。"""
|
|
|
|
declare_http_host = DeclareLaunchArgument(
|
|
"http_host", default_value="192.168.11.159",
|
|
description="仿真机 IP 地址",
|
|
)
|
|
declare_http_port = DeclareLaunchArgument(
|
|
"http_port", default_value="8765",
|
|
description="HTTP API 端口",
|
|
)
|
|
declare_timeout = DeclareLaunchArgument(
|
|
"timeout", default_value="1.0",
|
|
description="HTTP 请求超时 (秒)",
|
|
)
|
|
declare_sync_rate = DeclareLaunchArgument(
|
|
"sync_rate", default_value="30.0",
|
|
description="scan/odom/imu/power 同步频率 (Hz)",
|
|
)
|
|
declare_image_rate = DeclareLaunchArgument(
|
|
"image_rate", default_value="10.0",
|
|
description="图像拉取频率 (Hz)",
|
|
)
|
|
|
|
# 话题名称
|
|
declare_image_topic = DeclareLaunchArgument(
|
|
"image_topic", default_value="/image",
|
|
description="图像发布话题",
|
|
)
|
|
declare_imu_topic = DeclareLaunchArgument(
|
|
"imu_topic", default_value="/imu/data_raw",
|
|
description="IMU 发布话题",
|
|
)
|
|
declare_scan_topic = DeclareLaunchArgument(
|
|
"scan_topic", default_value="/scan",
|
|
description="激光雷达发布话题",
|
|
)
|
|
declare_odom_topic = DeclareLaunchArgument(
|
|
"odom_topic", default_value="/odom",
|
|
description="里程计发布话题",
|
|
)
|
|
declare_power_topic = DeclareLaunchArgument(
|
|
"power_topic", default_value="/PowerVoltage",
|
|
description="电池电压发布话题",
|
|
)
|
|
declare_cmd_vel_topic = DeclareLaunchArgument(
|
|
"cmd_vel_topic", default_value="/cmd_vel",
|
|
description="控制指令订阅话题",
|
|
)
|
|
|
|
bridge_node = Node(
|
|
package="origincar_bridge",
|
|
executable="bridge_node",
|
|
name="origincar_bridge",
|
|
output="screen",
|
|
parameters=[{
|
|
"http_host": LaunchConfiguration("http_host"),
|
|
"http_port": LaunchConfiguration("http_port"),
|
|
"timeout": LaunchConfiguration("timeout"),
|
|
"sync_rate": LaunchConfiguration("sync_rate"),
|
|
"image_rate": LaunchConfiguration("image_rate"),
|
|
"image_topic": LaunchConfiguration("image_topic"),
|
|
"imu_topic": LaunchConfiguration("imu_topic"),
|
|
"scan_topic": LaunchConfiguration("scan_topic"),
|
|
"odom_topic": LaunchConfiguration("odom_topic"),
|
|
"power_topic": LaunchConfiguration("power_topic"),
|
|
"cmd_vel_topic": LaunchConfiguration("cmd_vel_topic"),
|
|
}],
|
|
)
|
|
|
|
return LaunchDescription([
|
|
declare_http_host, declare_http_port, declare_timeout,
|
|
declare_sync_rate, declare_image_rate,
|
|
declare_image_topic, declare_imu_topic, declare_scan_topic,
|
|
declare_odom_topic, declare_power_topic, declare_cmd_vel_topic,
|
|
bridge_node,
|
|
])
|