1. 程式人生 > >ROS_安裝一個第三方模擬軟體包——機器人模擬世界

ROS_安裝一個第三方模擬軟體包——機器人模擬世界

本文記錄安裝一個第三方模擬軟體包的實戰,從下載到成功執行!
環境:ubuntu16.04 & ROS-Ubuntu2

下載原始碼包

在Ubuntu系統上,確保git已經安裝
sudo apt-get install git

然後再建立一個名為tutorial_ws的工作空間,在它的src路徑下克隆ROS-Academy-for-Beginners軟體包
cd
mkdir -p tutorial_ws/src           建立catkin工作空間
cd tutorial_ws/src                 進入src路徑,克隆教學軟體包
git clone https://github.com/DroidAITech/ROS-Academy-for-Beginners.git

安裝依賴

安裝依賴:

cd ~/tutorial_ws
rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y

過程圖:

9125154-3bcfd5cf9a52cc75.png
9125154-e7cc41df6841025a.png
9125154-512e58528c2ee62a.png

注意:以上命令非常重要,缺少依賴將導致軟體包無法正常編譯和執行。
在開始編譯之前,需要確保Gazebo在7.0版本以上

gazebo -V
9125154-462195736c51afe0.png

編譯

接著回到catkin_ws下編譯:

cd ~/tutorial_ws
catkin_make

過程圖:

9125154-f8a2cec0c561f248.png
9125154-074b6f3278a41079.png
9125154-a5ebb9c82d1d355b.png
9125154-815033b62a85f243.png
下面是重新整理環境的兩種方法:

source ~/tutorial_ws/devel/setup.bash
rospack profile

過程圖:

9125154-a7e6b0587303f63f.png

9125154-d826d016cf527096.png

執行模擬程式

首先需要解決一個問題,不然待會兒執行時會閃退:

roslaunch robot_sim_demo robot_spawn.launch

下面是執行過程圖(是的,一開始可能會遇到一個報錯[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name The traceback for the exception was written to the log file,然而下面的過程圖已經是從報錯到解決報錯成功執行的過程了):

9125154-176082a1db564bf7.png

[email protected]:~$ rospack profile
Full tree crawl took 0.189714 seconds.
Directories marked with (*) contain no manifest.  You may
want to delete these directories.
To get just of list of directories without manifests,
re-run the profile with --zombie-only
-------------------------------------------------------------
0.141810   /opt/ros/kinetic/share
0.000770 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev
0.000257 * /opt/ros/kinetic/share/doc
0.000043 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/haarcascades
0.000019 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/lbpcascades
0.000008 * /opt/ros/kinetic/share/doc/liborocos-kdl
[email protected]:~$ roslaunch robot_sim_demo robot_spawn.launch 
[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
The traceback for the exception was written to the log file
[email protected]:~$ roslaunch robot_sim_demo robot_spawn.launch 
[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
The traceback for the exception was written to the log file
[email protected]:~$ cd ~/tutorial_ws
[email protected]:~/tutorial_ws$ roslaunch robot_sim_demo robot_spawn.launch 
[robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
The traceback for the exception was written to the log file
[email protected]:~/tutorial_ws$ source ~/tutorial_ws/devel/setup.bash
[email protected]:~/tutorial_ws$ rospack profile
Full tree crawl took 0.025369 seconds.
Directories marked with (*) contain no manifest.  You may
want to delete these directories.
To get just of list of directories without manifests,
re-run the profile with --zombie-only
-------------------------------------------------------------
0.016329   /opt/ros/kinetic/share
0.008478   /home/liweipeng/tutorial_ws/src
0.008405   /home/liweipeng/tutorial_ws/src/ROS-Academy-for-Beginners
0.000169 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev
0.000036 * /opt/ros/kinetic/share/doc
0.000035 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/haarcascades
0.000015 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/lbpcascades
0.000006 * /opt/ros/kinetic/share/doc/liborocos-kdl
[email protected]:~/tutorial_ws$ roslaunch robot_sim_demo robot_spawn.launch 
... logging to /home/liweipeng/.ros/log/3bcd5ac4-be9d-11e8-a270-000c29f43d2c/roslaunch-liweipeng-virtual-machine-2603.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
xacro.py is deprecated; please use xacro instead
started roslaunch server http://liweipeng-virtual-machine:41819/

SUMMARY
========

PARAMETERS

9125154-3e2995762fbdd852.png
9125154-88d696568d681e73.png 9125154-07ccda2ec5d0e160.png 9125154-c61dbff42d98a7ff.png

再開啟一個終端,輸入以下命令,用鍵盤控制機器人移動,聚焦控制程式視窗,按下i、j、l等按鍵,控制機器人移動:

rosrun robot_sim_demo robot_keyboard_teleop.py

過程圖如下,記得執行前要重新整理環境,或者用上面的方法把重新整理命令新增到指令碼:

9125154-543c62da37910dc4.png

吶,對比上圖,我把它移到了簡介牌的右邊:

9125154-ccabd78b5ebe8ca6.png