Ubuntu18.04 ROS melodic 版本的rivz教程

 


我们学习rivz时需要一个大神写好的第三方包,这样我们才可以学习具体的命令以及方法。博主在从网上找rivz的教程时发现大部分都比较老了,不支持ROS的最新版本,所以提供的rivz第三方包安装会出现许多坑。博主经过几次踩坑后把经验分享出来。


学习rivz,首先需要安装arbotix。

1,进入源码目录

$  cd catkin_ws/src/

2,源码从git克隆到当前目录
$ git clone https://github.com/vanadiumlabs/arbotix_ros.git

3,切换到make路径

$ cd catkin_ws

4,make

$ catkin_make

uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws$ catkin_make
Base path: /home/uu/catkin_ws
Source space: /home/uu/catkin_ws/src
Build space: /home/uu/catkin_ws/build
Devel space: /home/uu/catkin_ws/devel
Install space: /home/uu/catkin_ws/install
####
#### Running command: "cmake /home/uu/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/uu/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/uu/catkin_ws/install -G Unix Makefiles" in "/home/uu/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/uu/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/uu/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/uu/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.15", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/uu/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.15") 
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.14
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 7 packages in topological order:
-- ~~  - arbotix (metapackage)
-- ~~  - arbotix_controllers
-- ~~  - arbotix_firmware
-- ~~  - arbotix_python
-- ~~  - arbotix_sensors
-- ~~  - arbotix_msgs
-- ~~  - beginner_tutorials
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin metapackage: 'arbotix'
-- ==> add_subdirectory(arbotix_ros/arbotix)
-- +++ processing catkin package: 'arbotix_controllers'
-- ==> add_subdirectory(arbotix_ros/arbotix_controllers)
-- +++ processing catkin package: 'arbotix_firmware'
-- ==> add_subdirectory(arbotix_ros/arbotix_firmware)
-- +++ processing catkin package: 'arbotix_python'
-- ==> add_subdirectory(arbotix_ros/arbotix_python)
-- +++ processing catkin package: 'arbotix_sensors'
-- ==> add_subdirectory(arbotix_ros/arbotix_sensors)
-- +++ processing catkin package: 'arbotix_msgs'
-- ==> add_subdirectory(arbotix_ros/arbotix_msgs)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- arbotix_msgs: 2 messages, 4 services
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/uu/catkin_ws/build
####
#### Running command: "make -j2 -l2" in "/home/uu/catkin_ws/build"
####
Scanning dependencies of target _arbotix_msgs_generate_messages_check_deps_SetupChannel
Scanning dependencies of target _arbotix_msgs_generate_messages_check_deps_Relax
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_SetupChannel
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Relax
Scanning dependencies of target std_msgs_generate_messages_eus
Scanning dependencies of target _arbotix_msgs_generate_messages_check_deps_Analog
[  0%] Built target std_msgs_generate_messages_eus
Scanning dependencies of target _arbotix_msgs_generate_messages_check_deps_Digital
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Analog
Scanning dependencies of target _arbotix_msgs_generate_messages_check_deps_Enable
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Digital
Scanning dependencies of target _arbotix_msgs_generate_messages_check_deps_SetSpeed
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Enable
Scanning dependencies of target std_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_SetSpeed
Scanning dependencies of target std_msgs_generate_messages_py
Scanning dependencies of target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_py
Scanning dependencies of target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_cpp
Scanning dependencies of target arbotix_msgs_generate_messages_eus
[  2%] Generating EusLisp code from arbotix_msgs/Digital.msg
[  8%] Built target hello
[ 11%] Generating EusLisp code from arbotix_msgs/Analog.msg
[ 14%] Generating EusLisp code from arbotix_msgs/Relax.srv
Scanning dependencies of target arbotix_msgs_generate_messages_nodejs
[ 17%] Generating Javascript code from arbotix_msgs/Digital.msg
[ 20%] Generating Javascript code from arbotix_msgs/Analog.msg
[ 22%] Generating EusLisp code from arbotix_msgs/SetSpeed.srv
[ 25%] Generating Javascript code from arbotix_msgs/Relax.srv
[ 28%] Generating EusLisp code from arbotix_msgs/SetupChannel.srv
[ 31%] Generating Javascript code from arbotix_msgs/SetSpeed.srv
[ 37%] Generating Javascript code from arbotix_msgs/SetupChannel.srv
[ 37%] Generating EusLisp code from arbotix_msgs/Enable.srv
[ 40%] Generating Javascript code from arbotix_msgs/Enable.srv
[ 42%] Generating EusLisp manifest code for arbotix_msgs
[ 42%] Built target arbotix_msgs_generate_messages_nodejs
Scanning dependencies of target arbotix_msgs_generate_messages_lisp
[ 45%] Generating Lisp code from arbotix_msgs/Digital.msg
[ 48%] Generating Lisp code from arbotix_msgs/Analog.msg
[ 51%] Generating Lisp code from arbotix_msgs/Relax.srv
[ 54%] Generating Lisp code from arbotix_msgs/SetSpeed.srv
[ 57%] Generating Lisp code from arbotix_msgs/SetupChannel.srv
[ 60%] Generating Lisp code from arbotix_msgs/Enable.srv
[ 60%] Built target arbotix_msgs_generate_messages_lisp
Scanning dependencies of target arbotix_msgs_generate_messages_py
[ 62%] Generating Python from MSG arbotix_msgs/Digital
[ 65%] Generating Python from MSG arbotix_msgs/Analog
[ 65%] Built target arbotix_msgs_generate_messages_eus
Scanning dependencies of target arbotix_msgs_generate_messages_cpp
[ 68%] Generating C++ code from arbotix_msgs/Digital.msg
[ 71%] Generating Python code from SRV arbotix_msgs/Relax
[ 74%] Generating Python code from SRV arbotix_msgs/SetSpeed
[ 77%] Generating C++ code from arbotix_msgs/Analog.msg
[ 80%] Generating Python code from SRV arbotix_msgs/SetupChannel
[ 82%] Generating C++ code from arbotix_msgs/Relax.srv
[ 85%] Generating Python code from SRV arbotix_msgs/Enable
[ 88%] Generating C++ code from arbotix_msgs/SetSpeed.srv
[ 91%] Generating Python msg __init__.py for arbotix_msgs
[ 94%] Generating Python srv __init__.py for arbotix_msgs
[ 97%] Generating C++ code from arbotix_msgs/SetupChannel.srv
[ 97%] Built target arbotix_msgs_generate_messages_py
[100%] Generating C++ code from arbotix_msgs/Enable.srv
[100%] Built target arbotix_msgs_generate_messages_cpp
Scanning dependencies of target arbotix_msgs_generate_messages
[100%] Built target arbotix_msgs_generate_messages
uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws$ 

这样就解决了arbotix的安装问题

 

5,同样操作,接下来我们需要安装用来测试与学习的rivz第三方包 rbx_vol_1

先下载rbx_vol_1
下载完成也需要catkin_make 这一步与上面是一样的方法。

$  cd ~/catkin_ws/src/

git clone https://github.com/pirobot/rbx1

/////////////////////////////////////////

uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws/src$ git clone https://github.com/pirobot/rbx1
Cloning into 'rbx1'...
remote: Counting objects: 1447, done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

//////////////////////////////////报错了几次才成功,N年前的资源就是不好

uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws/src$ git clone https://github.com/pirobot/rbx1/
Cloning into 'rbx1'...
remote: Counting objects: 1447, done.
remote: Total 1447 (delta 0), reused 0 (delta 0), pack-reused 1447
Receiving objects: 100% (1447/1447), 7.39 MiB | 14.00 KiB/s, done.
Resolving deltas: 100% (918/918), done.
uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws/src$

 

$  cd ..

catkin_make

uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws/src$ cd ..
uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws$ catkin_make
Base path: /home/uu/catkin_ws
Source space: /home/uu/catkin_ws/src
Build space: /home/uu/catkin_ws/build
Devel space: /home/uu/catkin_ws/devel
Install space: /home/uu/catkin_ws/install
####
#### Running command: "cmake /home/uu/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/uu/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/uu/catkin_ws/install -G Unix Makefiles" in "/home/uu/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/uu/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/uu/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/uu/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.15", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/uu/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.15") 
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.14
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 15 packages in topological order:
-- ~~  - arbotix (metapackage)
-- ~~  - arbotix_controllers
-- ~~  - arbotix_firmware
-- ~~  - arbotix_python
-- ~~  - arbotix_sensors
-- ~~  - rbx1 (metapackage)
-- ~~  - arbotix_msgs
-- ~~  - beginner_tutorials
-- ~~  - rbx1_speech
-- ~~  - rbx1_bringup
-- ~~  - rbx1_dynamixels
-- ~~  - rbx1_vision
-- ~~  - rbx1_apps
-- ~~  - rbx1_nav
-- ~~  - rbx1_description
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin metapackage: 'arbotix'
-- ==> add_subdirectory(arbotix_ros/arbotix)
-- +++ processing catkin package: 'arbotix_controllers'
-- ==> add_subdirectory(arbotix_ros/arbotix_controllers)
-- +++ processing catkin package: 'arbotix_firmware'
-- ==> add_subdirectory(arbotix_ros/arbotix_firmware)
-- +++ processing catkin package: 'arbotix_python'
-- ==> add_subdirectory(arbotix_ros/arbotix_python)
-- +++ processing catkin package: 'arbotix_sensors'
-- ==> add_subdirectory(arbotix_ros/arbotix_sensors)
-- +++ processing catkin metapackage: 'rbx1'
-- ==> add_subdirectory(rbx1/rbx1)
-- +++ processing catkin package: 'arbotix_msgs'
-- ==> add_subdirectory(arbotix_ros/arbotix_msgs)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- arbotix_msgs: 2 messages, 4 services
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- +++ processing catkin package: 'rbx1_speech'
-- ==> add_subdirectory(rbx1/rbx1_speech)
-- +++ processing catkin package: 'rbx1_bringup'
-- ==> add_subdirectory(rbx1/rbx1_bringup)
-- +++ processing catkin package: 'rbx1_dynamixels'
-- ==> add_subdirectory(rbx1/rbx1_dynamixels)
-- +++ processing catkin package: 'rbx1_vision'
-- ==> add_subdirectory(rbx1/rbx1_vision)
-- +++ processing catkin package: 'rbx1_apps'
-- ==> add_subdirectory(rbx1/rbx1_apps)
-- +++ processing catkin package: 'rbx1_nav'
-- ==> add_subdirectory(rbx1/rbx1_nav)
-- +++ processing catkin package: 'rbx1_description'
-- ==> add_subdirectory(rbx1/rbx1_description)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/uu/catkin_ws/build
####
#### Running command: "make -j2 -l2" in "/home/uu/catkin_ws/build"
####
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Relax
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_SetupChannel
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Analog
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Digital
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_Enable
[  0%] Built target _arbotix_msgs_generate_messages_check_deps_SetSpeed
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target std_msgs_generate_messages_cpp
Scanning dependencies of target rbx1_nav_gencfg
[  5%] Built target hello
[  8%] Generating dynamic reconfigure files from cfg/CalibrateAngular.cfg: /home/uu/catkin_ws/devel/include/rbx1_nav/CalibrateAngularConfig.h /home/uu/catkin_ws/devel/lib/python2.7/dist-packages/rbx1_nav/cfg/CalibrateAngularConfig.py
[ 27%] Built target arbotix_msgs_generate_messages_eus
[ 29%] Generating dynamic reconfigure files from cfg/CalibrateLinear.cfg: /home/uu/catkin_ws/devel/include/rbx1_nav/CalibrateLinearConfig.h /home/uu/catkin_ws/devel/lib/python2.7/dist-packages/rbx1_nav/cfg/CalibrateLinearConfig.py
Generating reconfiguration files for CalibrateLinear in rbx1_nav
Generating reconfiguration files for CalibrateAngular in rbx1_nav
Wrote header file in /home/uu/catkin_ws/devel/include/rbx1_nav/CalibrateLinearConfig.h
Wrote header file in /home/uu/catkin_ws/devel/include/rbx1_nav/CalibrateAngularConfig.h
[ 45%] Built target arbotix_msgs_generate_messages_nodejs
[ 62%] Built target arbotix_msgs_generate_messages_lisp
[ 62%] Built target rbx1_nav_gencfg
[ 83%] Built target arbotix_msgs_generate_messages_py
[100%] Built target arbotix_msgs_generate_messages_cpp
[100%] Built target arbotix_msgs_generate_messages
uu@uu-HP-EliteBook-6930P-Notebook-PC:~/catkin_ws$ 

6,再打开一个终端运行roscore

$ roscore

编译结束后我们就可以使用
$ roslaunch rbx1_bringup fake_pi_robot.launch

报错:

  File "/home/uu/catkin_ws/src/arbotix_ros/arbotix_python/bin/arbotix_driver", line 33, in 
    from arbotix_msgs.msg import *
ImportError: No module named arbotix_msgs.msg
[arbotix-2] process has died [pid 10508, exit code 1, cmd /home/uu/catkin_ws/src/arbotix_ros/arbotix_python/bin/arbotix_driver __name:=arbotix __log:=/home/uu/.ros/log/d9a20154-8f19-11e8-ba88-00216a949182/arbotix-2.log].
log file: /home/uu/.ros/log/d9a20154-8f19-11e8-ba88-00216a949182/arbotix-2*.log

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

报错:

IOError: [Errno 13] Permission denied: '/home/uu/.ros/rosdep/sources.cache/index'
[arbotix-2] process has died [pid 10665, exit code 1, cmd /home/uu/catkin_ws/src/arbotix_ros/arbotix_python/bin/arbotix_driver __name:=arbotix __log:=/home/uu/.ros/log/312402ba-8f1a-11e8-ba88-00216a949182/arbotix-2.log].
log file: /home/uu/.ros/log/312402ba-8f1a-11e8-ba88-00216a949182/arbotix-2*.log

$ sudo rm -fr /home/uu/.ros/rosdep/sources.cache

$ rosdep update

命令运行模拟机器人了

仍然失败。。。。。。。。。。。。。。。。。。。后续补充吧

然后运行

$ rosrun rviz rviz -d 'rospack find rbx1_nav' /sim.rviz

rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz
  • 1

即可看到小车仿真
这里写图片描述

你可能感兴趣的:(ROBOT)