forked from zbw/yiliao2026
修了一下障碍物相关
This commit is contained in:
@@ -6,8 +6,13 @@ def generate_launch_description():
|
||||
robot_parameters = [
|
||||
{'usart_port_name': '/dev/ttyACM0',
|
||||
'serial_baud_rate': 115200,
|
||||
'robot_frame_id': 'base_link',
|
||||
'robot_frame_id': 'base_footprint',
|
||||
'odom_frame_id': 'odom',
|
||||
'combined_odom_topic': 'odom_combined',
|
||||
'scan_topic': '/scan',
|
||||
'wall_config_path': '/home/sunrise/yiliao_ws/src/origincar_base/config/wall_fit.json',
|
||||
'publish_tf': True,
|
||||
'wall_scan_stride': 2,
|
||||
'cmd_vel': 'cmd_vel',
|
||||
'akm_cmd_vel': 'none',
|
||||
'product_number': 0,
|
||||
|
||||
@@ -1,99 +1,87 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import launch
|
||||
from launch.actions import SetEnvironmentVariable
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (DeclareLaunchArgument, GroupAction,
|
||||
IncludeLaunchDescription, SetEnvironmentVariable)
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
|
||||
from launch.conditions import IfCondition
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration, PythonExpression
|
||||
from launch_ros.actions import PushRosNamespace
|
||||
import launch_ros.actions
|
||||
from launch.conditions import UnlessCondition
|
||||
from launch.substitutions import Command, LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
from launch_ros.parameter_descriptions import ParameterValue
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Get the launch directory
|
||||
bringup_dir = get_package_share_directory('origincar_base')
|
||||
launch_dir = os.path.join(bringup_dir, 'launch')
|
||||
ekf_config = Path(get_package_share_directory('origincar_base'), 'config', 'ekf.yaml')
|
||||
imu_config = Path(get_package_share_directory('origincar_base'), 'config', 'imu.yaml')
|
||||
|
||||
|
||||
carto_slam = LaunchConfiguration('carto_slam', default='false')
|
||||
carto_slam_dec = DeclareLaunchArgument('carto_slam',default_value='false')
|
||||
akmcar = LaunchConfiguration('akmcar', default='true')
|
||||
wall_preview = LaunchConfiguration('wall_preview', default='false')
|
||||
wall_preview_port = LaunchConfiguration('wall_preview_port', default='8772')
|
||||
|
||||
akmcar = LaunchConfiguration('akmcar', default='false')
|
||||
akmcar_dec = DeclareLaunchArgument('akmcar', default_value='true',
|
||||
description='阿克曼底盘模式 (true=阿克曼, false=差速)')
|
||||
|
||||
origincar_base = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'base_serial.launch.py')),
|
||||
launch_arguments={'akmcar': akmcar}.items(),
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'base_serial.launch.py')),
|
||||
launch_arguments={'akmcar': akmcar}.items(),
|
||||
)
|
||||
|
||||
choose_car = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'robot_mode_description.launch.py')),
|
||||
robot_mode_description = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'robot_mode_description.launch.py')),
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
base_to_gyro = launch_ros.actions.Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='base_to_gyro',
|
||||
arguments=['0', '0', '0','0', '0','0','base_footprint','gyro_link'],
|
||||
)
|
||||
|
||||
link_to_laser = launch_ros.actions.Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='link_to_laser',
|
||||
arguments=['0', '0', '0','0', '0','0','base_link','laser'],
|
||||
base_to_gyro = Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='base_to_gyro',
|
||||
arguments=['0', '0', '0', '0', '0', '0', 'base_footprint', 'gyro_link'],
|
||||
)
|
||||
|
||||
imu_filter_node = launch_ros.actions.Node(
|
||||
link_to_laser = Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='link_to_laser',
|
||||
arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'laser'],
|
||||
)
|
||||
|
||||
imu_filter_node = Node(
|
||||
package='imu_filter_madgwick',
|
||||
executable='imu_filter_madgwick_node',
|
||||
parameters=[imu_config]
|
||||
parameters=[imu_config],
|
||||
)
|
||||
|
||||
wall_preview_server = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'wall_localization.launch.py')),
|
||||
condition=IfCondition(wall_preview),
|
||||
launch_arguments={
|
||||
'port': wall_preview_port,
|
||||
}.items(),
|
||||
)
|
||||
|
||||
robot_ekf = launch_ros.actions.Node(
|
||||
condition=UnlessCondition(carto_slam),
|
||||
package='robot_localization',
|
||||
executable='ekf_node',
|
||||
parameters=[ekf_config],
|
||||
remappings=[("odometry/filtered", "odom_combined")]
|
||||
)
|
||||
|
||||
# 从 URDF 生成 robot_description,供 joint_state_publisher 和 robot_state_publisher 共用
|
||||
from launch_ros.parameter_descriptions import ParameterValue
|
||||
from launch.substitutions import Command
|
||||
|
||||
robot_description = ParameterValue(
|
||||
Command(['xacro ', os.path.join(
|
||||
get_package_share_directory('origincar_description'),
|
||||
'urdf', 'origincar.urdf')]),
|
||||
value_type=str)
|
||||
|
||||
joint_state_publisher_node = launch_ros.actions.Node(
|
||||
package='joint_state_publisher',
|
||||
executable='joint_state_publisher',
|
||||
name='joint_state_publisher',
|
||||
parameters=[{'robot_description': robot_description}],
|
||||
Command([
|
||||
'xacro ',
|
||||
os.path.join(get_package_share_directory('origincar_description'), 'urdf', 'origincar.urdf'),
|
||||
]),
|
||||
value_type=str,
|
||||
)
|
||||
|
||||
ld = LaunchDescription()
|
||||
|
||||
ld.add_action(carto_slam_dec)
|
||||
ld.add_action(akmcar_dec)
|
||||
ld.add_action(origincar_base)
|
||||
ld.add_action(base_to_gyro)
|
||||
ld.add_action(joint_state_publisher_node)
|
||||
ld.add_action(choose_car)
|
||||
ld.add_action(imu_filter_node)
|
||||
ld.add_action(robot_ekf)
|
||||
|
||||
return ld
|
||||
joint_state_publisher_node = Node(
|
||||
package='joint_state_publisher',
|
||||
executable='joint_state_publisher',
|
||||
name='joint_state_publisher',
|
||||
parameters=[{'robot_description': robot_description}],
|
||||
)
|
||||
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument('carto_slam', default_value='false'),
|
||||
DeclareLaunchArgument('akmcar', default_value='true'),
|
||||
DeclareLaunchArgument('wall_preview', default_value='false'),
|
||||
DeclareLaunchArgument('wall_preview_port', default_value='8772'),
|
||||
origincar_base,
|
||||
base_to_gyro,
|
||||
joint_state_publisher_node,
|
||||
robot_mode_description,
|
||||
imu_filter_node,
|
||||
wall_preview_server,
|
||||
])
|
||||
|
||||
33
src/origincar_base/launch/wall_localization.launch.py
Normal file
33
src/origincar_base/launch/wall_localization.launch.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
scan_topic = LaunchConfiguration('scan_topic')
|
||||
combined_odom_topic = LaunchConfiguration('combined_odom_topic')
|
||||
wall_config = LaunchConfiguration('wall_config')
|
||||
port = LaunchConfiguration('port')
|
||||
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument('scan_topic', default_value='/scan'),
|
||||
DeclareLaunchArgument('combined_odom_topic', default_value='/odom_combined'),
|
||||
DeclareLaunchArgument(
|
||||
'wall_config',
|
||||
default_value='/home/sunrise/yiliao_ws/src/origincar_base/config/wall_fit.json'),
|
||||
DeclareLaunchArgument('port', default_value='8772'),
|
||||
|
||||
Node(
|
||||
package='origincar_base',
|
||||
executable='wall_preview_server',
|
||||
name='wall_preview_server',
|
||||
output='screen',
|
||||
parameters=[{
|
||||
'scan_topic': scan_topic,
|
||||
'combined_odom_topic': combined_odom_topic,
|
||||
'config_path': wall_config,
|
||||
'port': port,
|
||||
}],
|
||||
),
|
||||
])
|
||||
Reference in New Issue
Block a user