ROS_安裝一個第三方模擬軟體包——機器人模擬世界
阿新 • • 發佈:2018-11-12
本文記錄安裝一個第三方模擬軟體包的實戰,從下載到成功執行!
環境: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
過程圖:
注意:以上命令非常重要,缺少依賴將導致軟體包無法正常編譯和執行。
在開始編譯之前,需要確保Gazebo在7.0版本以上
gazebo -V
編譯
接著回到catkin_ws下編譯:
cd ~/tutorial_ws
catkin_make
過程圖:
下面是重新整理環境的兩種方法:
source ~/tutorial_ws/devel/setup.bash
rospack profile
過程圖:
執行模擬程式
首先需要解決一個問題,不然待會兒執行時會閃退:
- 虛擬機器上無法執行Gazebo的問題?
然後進入工作空間,輸入下方程式碼即可:
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]:~$ 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
再開啟一個終端,輸入以下命令,用鍵盤控制機器人移動,聚焦控制程式視窗,按下i、j、l等按鍵,控制機器人移動:
rosrun robot_sim_demo robot_keyboard_teleop.py
過程圖如下,記得執行前要重新整理環境,或者用上面的方法把重新整理命令新增到指令碼:
吶,對比上圖,我把它移到了簡介牌的右邊: