搭建ROS

仅作笔记整理搬运使用,没有任何程序原创部分,主要给自己提个醒,避免重复搜索工作
不会编程,只能拼凑

一、ubuntu安装ros环境

ubuntu18.04对应的ROS是Melodic

参考网址:https://blog.csdn.net/qq_41450811/article/details/99079041#commentBox

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

sudo apt-get update
sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-rqt*

然后执行

sudo rosdep init

出现一些错误
比如pkg_resources.DistributionNotFound: The ‘rosdep==0.20.0’ distribution was not found and is required by the application
此时,按照https://blog.csdn.net/moX980/article/details/110316752
进行python默认版本的更换

还会碰到ERROR: cannot download default sources list from: https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list Website may be down.这个错误
按照https://blog.csdn.net/Numberors/article/details/105614301
修改IP地址

然后执行

rosdep update

出现错误
ERROR: Not all sources were able to be updated. [[[ ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]: Failed to download target platform data for gbpdistro: <urlopen error [Errno 104] Connection reset by peer> ]]]
但是已经出现updated cache in /home/shs/.ros/rosdep/sources.cache,证明已经完成,不用管后面的错误

然后执行

roscore 

出现Command 'roscore' not found,证明安装ros包时未安装全,执行以下命令

sudo apt install ros-melodic-desktop-full

再执行roscore出现

started roslaunch server http://shs-C246-WU4:45065/
ros_comm version 1.14.10


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.10

NODES

auto-starting new master
process[master]: started with pid [23614]
ROS_MASTER_URI=http://shs-C246-WU4:11311/

setting /run_id to 475cfb06-4fd2-11eb-a8bf-200db010322d
process[rosout-1]: started with pid [23625]
started core service [/rosout]

安装完成

参考:https://blog.csdn.net/mychaoles/article/details/108485496

ROS的卸载
卸载使用如下命令:

sudo apt-get remove ros-*

ubunut16.04安装ROS Kinetic

https://blog.csdn.net/weixin_43159148/article/details/83375218

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

小海龟测试
1.
roscore
2.
rosrun turtlesim turtlesim_node
3.
rosrun turtlesim turtle_teleop_key

出错无脑换网,联通yyds!

二、创建工作区

DOPE官网:https://github.com/NVlabs/Deep_Object_Pose
创建catkin工作区:http://wiki.ros.org/catkin/Tutorials/create_a_workspace

执行

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make

No module named catkin_pkg.package

 catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2

在make的时候出现错误,参照该博主解决方案https://blog.csdn.net/qq_44324181/article/details/109961907
https://blog.csdn.net/qq_44324181/article/details/109961127
https://www.jianshu.com/p/9c8237bb3598
出现ImportError: "from catkin_pkg.package import parse_package" failed: No module named catkin_pkg.package时执行:

pip install --user catkin_pkg
pip install --user rosdep rosinstall_generator wstool rosinstall six vcstools
pip install --user pydot

然后配置环境变量

sudo gedit ~/.bashrc
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages
source ~/.bashrc

再make时又出现AttributeError: module 'enum' has no attribute 'IntFlag'的错误,

【【【【【【【【【【【【【【【【【【【【【【【【【【【【【【【

python
import enum
enum.__file__

结果显示

'/usr/lib/python2.7/dist-packages/enum/__init__.py'

找到原文件,并删掉py和pyc两个文件

sudo rm -f /usr/lib/python2.7/dist-packages/enum/__init__.py
sudo rm -f /usr/lib/python2.7/dist-packages/enum/__init__.pyc

】】】】】】】】】】】】】】】】】】】】】】】】】】】】】】】(确实对这个错误有用,但是删除权限文件我在之后遇到了一些问题)

所以执行

unset PYTHONPATH

也可以解决ttributeError: module 'enum' has no attribute 'IntFlag的问题

然后执行

catkin_make

则可以成功。

然后设置环境变量:

sudo apt install net-tools
gedit ~/.bashrc
# Set ROS melodic
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash
 
# Set ROS Network
#######使用    ifconfig     查看你的电脑ip地址
export ROS_HOSTNAME=192.168.89.135
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311
 
# Set ROS alias command 快捷指令
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'

注意自己电脑IP 地址的替换。

小海龟测试,分别在三个终端输入:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

可以看到一个小海龟能够跟着你的键盘上下左右移动。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值