在ROS工作空间创建gazebo的功能包(package)

在moveit! 与 gazebo的联合仿真的过程中,需要在ROS的工作空间创gazebo的package。这里简单介绍下流程,具体可观看这里

一、首先创建ros的工作空间

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
catkin_make

加入环境变量
source devel/setup.bash

以上环境变量设置仅为临时,通过在bash脚本中设置,可在终端启动时加入环境变量

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

二、创建gazebo功能包

cd ~/catkin_ws/src/
catkin_create_pkg probot_gazebo 

在probot_gazebo文件夹下生成了CMakeLists.txt 与 package.xml 两个文件,在probot_gazebo文件夹新建launch文件夹

cd probot_gazebo
sudo mkdir launch

在launch文件夹下创建probot_anno_gazebo_world.launch文件

cd launch
touch probot_anno_gazebo_world.launch

打开probot_anno_gazebo_world.launch文件,将以下内容复制进去

<launch>

  <!-- these are the arguments you can pass this launch file, for example paused:=true -->
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="gui" default="true"/>
  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>

  <!-- We resume the logic in empty_world.launch -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="paused" value="$(arg paused)"/>
    <arg name="use_sim_time" value="$(arg use_sim_time)"/>
    <arg name="headless" value="$(arg headless)"/>
  </include>

  <!-- Load the URDF into the ROS Parameter Server -->
  <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find marm_description)/urdf/marm.xacro'" /> 


  <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
	args="-urdf -model marm -param robot_description"/> 
</launch>

其中下面这部分的commandargs根据urdf文件路径与内容填写:

  <!-- Load the URDF into the ROS Parameter Server -->
  <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find marm_description)/urdf/marm.xacro'" /> 


  <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
	args="-urdf -model marm -param robot_description"/> 
</launch>

如果需要其他配置文件,可相应的文件夹与文件

三、编译工作空间

cd ~/catkin_ws/

catkin_make

四、测试

roslaunch probot_gazebo probot_anno_gazebo_world.launch

可启动gazebo,并加载marm.xacro模型。

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值