sudo apt-get install python-rosdep python-wstool
sudo rosdep init
rosdep update
注意:再执行 sudo rosdep init 命令时,我的电脑出现了以下的错误:
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
解决方法:
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
整个安装过程一个需要编译三个文件,为了管理,建立了一个Turtlebot的文件夹再将接下来的三个空间放在该文件录下的.在Turtlebot目录下分别再建rocon,kobuki,turtlebo.文件夹。具体步骤如下所示:
(1)下载和编译源码,建立rocon目录,下载和编译,rocon都有对应的kinetic版本
mkdir rocon
cd rocon
wstool init -j5 src https://raw.github.com/robotics-in-concert/rocon/release/kinetic/rocon.rosinstall
source /opt/ros/kinetic/setup.bash
rosdep install --from-paths src -i -y
catkin_make
注意:在执行wstool init -j5 src https://raw.github.com/robotics-in-concert/rocon/release/kinetic/rocon.rosinstall命令时,报了以下的错误:
[ 1%] Generating C++ code from concert_workflow_engine_msgs/Workflow.msg
Traceback (most recent call last):
File "/opt/ros/kinetic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 41, in
import genmsg.template_tools
File "/opt/ros/kinetic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 39, in
import em
ImportError: No module named 'em'
总的来说就是没有em这个模块
解决方法:
python -m pip install empy
(2)建立koubuki文件夹,下载和编译.
kobuki使用kinetic的版本下载会失败,先用indigo版本生成下载的rosinstall文件,再修改对应包为kinetic版本,命令如下.
mkdir kobuki
cd kobuki
wget https://raw.github.com/yujinrobot/yujin_tools/master/rosinstalls/indigo/kobuki.rosinstall
gedit kobuki.rosinstall #将内容修改为下面kobuki.rosinstall文件的内容
wstool init src -j5 kobuki.rosinstall
source /opt/ros/kinetic/setup.bash
rosdep install --from-paths src -i -y
catkin_make
kobuki.rosinstall文件内容如下:
- git: {local-name: yocs_msgs, version: release/0.6-kinetic, uri: 'https://github.com/yujinrobot/yocs_msgs.git'}
- git: {local-name: yujin_ocs, version: kinetic, uri: 'https://github.com/yujinrobot/yujin_ocs.git'}
- git: {local-name: kobuki_msgs, version: kinetic, uri: 'https://github.com/yujinrobot/kobuki_msgs.git'}
- git: {local-name: kobuki_core, version: kinetic, uri: 'https://github.com/yujinrobot/kobuki_core.git'}
- git: {local-name: kobuki, version: kinetic, uri: 'https://github.com/yujinrobot/kobuki.git'}
- git: {local-name: kobuki_desktop, version: kinetic, uri: 'https://github.com/yujinrobot/kobuki_desktop.git'}
注意:再执行 wstool init src -j5 kobuki.rosinstall 命令时报了以下的错误:
安装kobuki报错:error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: 过早的文件结束符(EOF)
fatal: index-pack failed
解决方法:
git config --global http.postBuffer 524288000
先执行上面的命令,然后再删掉kobuki文件夹中的src文件 重新再执行上一次失败的命令wstool init src -j5 kobuki.rosinstall
(3)建立turtlebot目录,下载和编译.
turtlebot使用kinetic的版本下载会失败,先用indigo版本生成下载的rosinstall文件,再修改对应包为kinetic版本,没有kinetic版本的保持为indigo版本,命令如下:
mkdir turtlebot
cd turtlebot
wget https://raw.github.com/yujinrobot/yujin_tools/master/rosinstalls/indigo/turtlebot.rosinstall
gedit turtlebot.rosinstall #将文件修改为下面turtlebot.rosinstall文件的内容
wstool init src -j5 turtlebot.rosinstall
source /opt/ros/kinetic/setup.bash
rosdep install --from-paths src -i -y
catkin_make
turtlebot.rosinstall文件内容:
- git: {local-name: turtlebot_msgs, version: indigo, uri: 'https://github.com/turtlebot/turtlebot_msgs.git'}
- git: {local-name: turtlebot_create, version: indigo, uri: 'https://github.com/turtlebot/turtlebot_create.git'}
- git: {local-name: turtlebot, version: kinetic, uri: 'https://github.com/turtlebot/turtlebot.git'}
- git: {local-name: turtlebot_apps, version: indigo, uri: 'https://github.com/turtlebot/turtlebot_apps.git'}
- git: {local-name: turtlebot_interactions, version: indigo, uri: 'https://github.com/turtlebot/turtlebot_interactions.git'}
- git: {local-name: turtlebot_simulator, version: indigo, uri: 'https://github.com/turtlebot/turtlebot_simulator.git'}
- git: {local-name: turtlebot_create_desktop, version: kinetic, uri: 'https://github.com/turtlebot/turtlebot_create_desktop.git'}
注意:在这个过程中又遇到了kobuki一样的错误,也是采用一样的解决方法解决的.最后三个文件都成功编译之后就进行一些简单的配置.
(1)添加环境变量:
source ~/turtlebot_ws/devel/setup.bash
(2)安装kinetic驱动:
sudo apt-get install ros-kinetic-openni-* ros-kinetic-openni2-* ros-kinetic-freenect-*
(3)安装openni:
sudo apt-get install ros-kinetic-openni-* ros-kinetic-openni2-*
rospack profile
到此为止,如果没有报错或者报的错都成功解决,那么安装便是成功了.接下来进行相应的测试和使用.
将turtlebot的usb数据线接入电脑,再通电,执行以下命令:
(1)新开终端,输入:
roscore
(2)检测设备接入:
ls /dev/kobuki
此时会对应输出设备信息 /dev/kobuki
如果没有信息,则添加别名:
rosrun kobuki_ftdi create_udev_rules
重新插入usb线,再查看设备接入情况.
(3)启动turtlebot:
roslaunch turtlebot_bringup minimal.launch
注意:如果报错: ModuleNotFoundError: No module named 're' 这个类型的错误
大概是因为你系统中装了两个版本的python冲突所引起的(我之前装了annaconda,齐总的python3.5和系统的2.7版本冲突.)
解决方法:
暂时将.bashrc文件中annaconda的内容先注释掉,用的时候再取消注释即可
sudo gedit ~/.bashrc
//然后Ctrl+F搜索anaconda的内容,一般也就集中在一起,然后注释掉。更新一下
source ~/.bashrc
(4)启动键盘控制:
roslaunch turtlebot_teleop keyboard_teleop.launch
前进,后退左转右转分别对应i k l j 四个键.
(5)通过话题发布命令控制turtlebot移动:
rostopic pub -r 10 /cmd_vel_mux/input/navi geometry_msgs/Twist '{linear: {x: 0.1, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
linear:{}线速度,一般修改x
angular:{}角速度,修改z
到此为止.turtlebot的安装及简单测试就到此为止,后续可以通过编写其他节点计算出角速度和线速度,再发布给turtlebot,使其有目的的移动.
参考文献:
https://blog.csdn.net/weixin_43540678/article/details/84033325
https://blog.csdn.net/wawayu_0/article/details/79460043
https://blog.csdn.net/dzhongjie/article/details/81152983
https://www.ncnynl.com/archives/201609/792.html