【Gazebo】ROS2加载URDF到Gazebo11

4 篇文章 1 订阅
1 篇文章 0 订阅

原文链接:【Gazebo】ROS2加载URDF到Gazebo11

ros2 加载urdf到gazebo11

图片

图片

笔记:

下载gazebo_model 解压到   ~/.bazebo/models目录下。  

killall gzserver  //第二次运行launch时关闭服务器  

killall gzclient//构建,获取安装,启动colcon build --packages-select irb52urdf . install/setup.bash
//启动前将irb52urdf包拷贝到models目录下ros2 launch irb52urdf gazebo.launch.py

不拷贝包到models目录下报错

 拷贝到这里

 

launch.py文件:


import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.launch_description_sources import PythonLaunchDescriptionSource
from scripts import GazeboRosPaths

def generate_launch_description():

  use_sim_time = LaunchConfiguration('use_sim_time', default='false')
  urdf_file_name = 'urdf/irb52urdf.urdf'#

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

  urdf = os.path.join(
      get_package_share_directory('irb52urdf'),
      urdf_file_name)

  return LaunchDescription([

        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use simulation (Gazebo) clock if true'),

        ExecuteProcess(
            cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'],
            output='screen'),

        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            name='robot_state_publisher',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time}],
            arguments=[urdf]),

        Node(
            package='joint_state_publisher',
            executable='joint_state_publisher',
            name='joint_state_publisher',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time}]
            ),

        Node(
            package='gazebo_ros',
            executable='spawn_entity.py',
            name='urdf_spawner',
            output='screen',
            arguments=["-topic", "/robot_description", "-entity", "irb52urdf", "-x", "0.0", "-y", "0.0", "-z", "0.0"],
            #arguments=["-topic", "robot_description", "-entity", "robot", "-x", "0.0", "-y", "0.0", "-z", "0.0"],
            #arguments=["-entity","irb52urdf","-b","-file", urdf,],
            
            )
  ])

参考:

http://gazebosim.org/tutorials

https://github.com/osrf/gazebo_models

https://www.ncnynl.com/archives/202110/4811.html

http://www.lxshaw.com/tech/ros/2021/05/22/gazebo%e5%85%a5%e9%97%a8%ef%bc%88%e4%b9%9d%ef%bc%89%ef%bc%9a%e4%b8%80%e4%b8%aa%e6%9b%b4%e5%a5%bd%e7%9a%84ros2-gazebo%e6%8f%92%e4%bb%b6%e6%a8%a1%e6%9d%bf/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值