赞
踩
对于Gazebo而言,我们知道其是可以通过与ROS的连接完成机器人建图导航的,那我们是否可以通过Unity来完成相同的工作呢,答案是肯定的。这一讲我们就来讲述使用Unity的“Turtlebot3”模拟环境,来运行ROS2中的“Navigation 2”以及“slam_toolbox”。
安装步骤如下所示,首先先下载“Navigation 2 SLAM Example Demo”仓库
git clone --recurse-submodule git@github.com:Unity-Technologies/Robotics-Nav2-SLAM-Example.git
然后确保在Unity的版本以及开发包都已经安装完成,并在2020.2版本以后的Unity中打开Assets/Skenes/SimpleWarehouseScene
场景
选择Unity的菜单“Robotics→ROSSettings”,确认以下设置
・连接启动:打钩
・Protocol:ROS2
・ROS Port:10000
・显示HUD:打钩
docker build -t unity-robotics:nav2-slam-example ./
docker run -it --rm -p 6080:80 -p 10000:10000 --shm-size=1024m unity-robotics:nav2-slam-example
import os from launch import LaunchDescription from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from ament_index_python.packages import get_package_share_directory from launch_ros.actions import Node def generate_launch_description(): package_name = 'unity_slam_example' package_dir = get_package_share_directory(package_name) return LaunchDescription({ # ros的tcp节点启动 IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory( 'ros_tcp_endpoint'), 'launch', 'endpoint.py') ), ), # rviz2启动 Node( package='rviz2', executable='rviz2', output='screen', arguments=['-d', os.path.join(package_dir, 'nav2_unity.rviz')], parameters=[{'use_sim_time': True}] ), # Nav2启动 IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory( 'nav2_bringup'), 'launch', 'navigation_launch.py') ), launch_arguments={ 'use_sim_time': 'true' }.items() ), # SLAM Toolbox启动 IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory( 'slam_toolbox'), 'launch', 'online_async_launch.py') ), launch_arguments={ 'use_sim_time': 'true' }.items() ) })
・WS : 前後
・AD : 左右
・EQ : 上下
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。