Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9393082
  • 博文数量: 1747
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 20060
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1747)

文章存档

2024年(23)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: 其他平台

2020-09-01 18:40:30

点击(此处)折叠或打开

  1. 启动小车
  2. $ ros2 launch turtlebot3_bringup robot.launch.py

  3. 运行控制节点
  4. $ ros2 run turtlebot3_teleop teleop_keyboard

  5. 运行RVIZ
  6. $ ros2 launch turtlebot3_bringup rviz2.launch.py

点击(此处)折叠或打开  turtlebot3_bringup robot.launch.py 分析

  1. import os

  2. from ament_index_python.packages import get_package_share_directory
  3. from launch import LaunchDescription
  4. from launch.actions import DeclareLaunchArgument
  5. from launch.actions import IncludeLaunchDescription
  6. from launch.launch_description_sources import PythonLaunchDescriptionSource
  7. from launch.substitutions import LaunchConfiguration
  8. from launch.substitutions import ThisLaunchFileDir
  9. from launch_ros.actions import Node


  10. def generate_launch_description():
  11.     TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']  //Burger: 获取SHELL环境变量的设定,即机器人类型

  12.     usb_port = LaunchConfiguration('usb_port', default='/dev/ttyACM0'

  13.     tb3_param_dir = LaunchConfiguration(
  14.         'tb3_param_dir',
  15.         default=os.path.join(
  16.             get_package_share_directory('turtlebot3_bringup'),
  17.             'param',
  18.             TURTLEBOT3_MODEL + '.yaml'))

  19.     lidar_pkg_dir = LaunchConfiguration(
  20.         'lidar_pkg_dir',
  21.         default=os.path.join(get_package_share_directory('hls_lfcd_lds_driver'), 'launch'))

  22.     use_sim_time = LaunchConfiguration('use_sim_time', default='false')

  23.     return LaunchDescription([
  24.         DeclareLaunchArgument(
  25.            'use_sim_time',
  26.            default_value=use_sim_time,
  27.            description='Use simulation (Gazebo) clock if true'),

  28.         DeclareLaunchArgument(
  29.             'usb_port',
  30.             default_value=usb_port,
  31.             description='Connected USB port with OpenCR'),

  32.         DeclareLaunchArgument(
  33.             'tb3_param_dir',
  34.             default_value=tb3_param_dir,
  35.             description='Full path to turtlebot3 parameter file to load'),

  36.         IncludeLaunchDescription(
  37.             PythonLaunchDescriptionSource(
  38.                 [ThisLaunchFileDir(), '/turtlebot3_state_publisher.launch.py']),
  39.             launch_arguments={'use_sim_time': use_sim_time}.items(),
  40.         ),

  41.         IncludeLaunchDescription(
  42.             PythonLaunchDescriptionSource([lidar_pkg_dir, '/hlds_laser.launch.py']),
  43.             launch_arguments={'port': '/dev/ttyUSB0', 'frame_id': 'base_scan'}.items(),
  44.         ),

  45.         Node(
  46.             package='turtlebot3_node',
  47.             node_executable='turtlebot3_ros',
  48.             parameters=[tb3_param_dir],
  49.             arguments=['-i', usb_port],
  50.             output='screen'),
  51.     ])

点击(此处)折叠或打开  turtlebot3_state_publisher.launch.py

  1. //主要时报 odom信息同步到底盘中心的base_linkde 坐标系上。
  2. import os

  3. from ament_index_python.packages import get_package_share_directory
  4. from launch import LaunchDescription
  5. from launch.actions import DeclareLaunchArgument
  6. from launch.substitutions import LaunchConfiguration
  7. from launch_ros.actions import Node


  8. def generate_launch_description():
  9.     TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']

  10.     use_sim_time = LaunchConfiguration('use_sim_time', default='false')
  11.     urdf_file_name = 'turtlebot3_' + TURTLEBOT3_MODEL + '.urdf'

  12.     print("urdf_file_name : {}".format(urdf_file_name))

  13.     urdf = os.path.join(
  14.         get_package_share_directory('turtlebot3_description'),
  15.         'urdf',
  16.         urdf_file_name)

  17.     return LaunchDescription([
  18.         DeclareLaunchArgument(
  19.             'use_sim_time',
  20.             default_value='false',
  21.             description='Use simulation (Gazebo) clock if true'),

  22.         Node(
  23.             package='robot_state_publisher',
  24.             node_executable='robot_state_publisher',
  25.             node_name='robot_state_publisher',
  26.             output='screen',
  27.             parameters=[{'use_sim_time': use_sim_time}],
  28.             arguments=[urdf]),
  29.     ])
Teleop就是简单的手动遥控操作的内容了

阅读(2103) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~