分享

ROS

 felwell 2019-06-05

本文记录安装一个第三方仿真软件包的实战,从下载到成功运行!
环境:ubuntu16.04 & ROS-Ubuntu2

下载源码包

  1. 在Ubuntu系统上,确保git已经安装
  2. sudo apt-get install git
  3. 然后再创建一个名为tutorial_ws的工作空间,在它的src路径下克隆ROS-Academy-for-Beginners软件包
  4. cd
  5. mkdir -p tutorial_ws/src 创建catkin工作空间
  6. cd tutorial_ws/src 进入src路径,克隆教学软件包
  7. git clone https://github.com/DroidAITech/ROS-Academy-for-Beginners.git

安装依赖

安装依赖:

  1. cd ~/tutorial_ws
  2. 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下编译:

  1. cd ~/tutorial_ws
  2. catkin_make

过程图:

9125154-f8a2cec0c561f248.png

9125154-074b6f3278a41079.png

9125154-a5ebb9c82d1d355b.png

9125154-815033b62a85f243.png

下面是刷新环境的两种方法:
  1. source ~/tutorial_ws/devel/setup.bash
  2. 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
  1. liweipeng@liweipeng-virtual-machine:~$ rospack profile
  2. Full tree crawl took 0.189714 seconds.
  3. Directories marked with (*) contain no manifest. You may
  4. want to delete these directories.
  5. To get just of list of directories without manifests,
  6. re-run the profile with --zombie-only
  7. -------------------------------------------------------------
  8. 0.141810 /opt/ros/kinetic/share
  9. 0.000770 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev
  10. 0.000257 * /opt/ros/kinetic/share/doc
  11. 0.000043 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/haarcascades
  12. 0.000019 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/lbpcascades
  13. 0.000008 * /opt/ros/kinetic/share/doc/liborocos-kdl
  14. liweipeng@liweipeng-virtual-machine:~$ roslaunch robot_sim_demo robot_spawn.launch
  15. [robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
  16. The traceback for the exception was written to the log file
  17. liweipeng@liweipeng-virtual-machine:~$ roslaunch robot_sim_demo robot_spawn.launch
  18. [robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
  19. The traceback for the exception was written to the log file
  20. liweipeng@liweipeng-virtual-machine:~$ cd ~/tutorial_ws
  21. liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ roslaunch robot_sim_demo robot_spawn.launch
  22. [robot_spawn.launch] is neither a launch file in package [robot_sim_demo] nor is [robot_sim_demo] a launch file name
  23. The traceback for the exception was written to the log file
  24. liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ source ~/tutorial_ws/devel/setup.bash
  25. liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ rospack profile
  26. Full tree crawl took 0.025369 seconds.
  27. Directories marked with (*) contain no manifest. You may
  28. want to delete these directories.
  29. To get just of list of directories without manifests,
  30. re-run the profile with --zombie-only
  31. -------------------------------------------------------------
  32. 0.016329 /opt/ros/kinetic/share
  33. 0.008478 /home/liweipeng/tutorial_ws/src
  34. 0.008405 /home/liweipeng/tutorial_ws/src/ROS-Academy-for-Beginners
  35. 0.000169 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev
  36. 0.000036 * /opt/ros/kinetic/share/doc
  37. 0.000035 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/haarcascades
  38. 0.000015 * /opt/ros/kinetic/share/OpenCV-3.3.1-dev/lbpcascades
  39. 0.000006 * /opt/ros/kinetic/share/doc/liborocos-kdl
  40. liweipeng@liweipeng-virtual-machine:~/tutorial_ws$ roslaunch robot_sim_demo robot_spawn.launch
  41. ... logging to /home/liweipeng/.ros/log/3bcd5ac4-be9d-11e8-a270-000c29f43d2c/roslaunch-liweipeng-virtual-machine-2603.log
  42. Checking log directory for disk usage. This may take awhile.
  43. Press Ctrl-C to interrupt
  44. Done checking log file disk usage. Usage is <1GB.
  45. xacro: Traditional processing is deprecated. Switch to --inorder processing!
  46. To check for compatibility of your document, use option --check-order.
  47. For more infos, see http://wiki./xacro#Processing_Order
  48. xacro.py is deprecated; please use xacro instead
  49. started roslaunch server http://liweipeng-virtual-machine:41819/
  50. SUMMARY
  51. ========
  52. 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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多