在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>
其中下面这部分的command与args根据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模型。