1 最快搭建搭建Ubuntu16_04系统安装ros Kinect 树莓派3B桌面pc 更新apt源码以及ros的安装
目录
1 最快搭建搭建Ubuntu16_04系统安装ros Kinect
4 ros小车与stm32通信:电机驱动调试平台pid调试开发ros底盘里程计
1 安装Ubuntu 16.04
桌面PC 和树莓派都是在ubuntu 16.04的版本上安装的(树莓派是ubuntmate 16.04)
首先安装Ubuntu16.04 这里提供两个下载地址
ubuntu 16.04 x86版本
链接:https://pan.baidu.com/s/1AUEn6o5ontvFl7IzVW3qWA
提取码:46oi
64位版本
链接:https://pan.baidu.com/s/18TcXo-GVodZWC5PsUsUmCA
提取码:qn7a
安装指导,网上基本都有,需要花费一定时间进行安装,安装完后,回来继续安装ros.
2 安装ros
安装之前请先浏览一遍ros官网的教程
http://wiki.ros.org/kinetic/Installation/Ubuntu
特别注意的是 设置keys的时候务必去官网查看最新的
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
之前42c开头的已经失效。好多教程仍旧沿用。
其次,一定要刷新sourlist 的源。
cd /etc/apt
以root身份打开 sudo mv sources.list sources.list.bak ,
将 http://ports.ubuntu.com/ 全部替换为 http://mirrors.ustc.edu.cn/ubuntu-ports/ ,这是中科大的
执行 sudo apt-get update 和 sudo apt-get upgrade 测试
查看是否提供arm支持的方法
打开一个镜像站点,然后以此打开 /dists/xenial/main/ ,看这个目录下面有没有 binary-arm 这样的字眼,如果有,就是提供arm支持的
上面部分来自https://blog.csdn.net/wr132/article/details/56700479
下面贴出具体的代码:
## Note, this file is written by cloud-init on first boot of an instance ## modifications made here will not survive a re-bundle. ## if you wish to make changes you can: ## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg ## or do the same in user-data ## b.) add sources in /etc/apt/sources.list.d ## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial main restricted deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates main restricted deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial universe deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial multiverse deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security main restricted deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security main restricted deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security universe deb http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu xenial partner # deb-src http://archive.canonical.com/ubuntu xenial partner
实际更新效果要比官方的快很多,效果如下
ads@ads-desktop:/etc/apt$ sudo apt-get update Get:1 http://mirrors.ustc.edu.cn/ubuntu-ports xenial InRelease [247 kB] Get:2 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates InRelease [109 kB] Get:3 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports InRelease [107 kB] Get:4 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security InRelease [109 kB] Get:5 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/main Sources [868 kB] Get:6 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/restricted Sources [4,808 B] Get:7 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/universe Sources [7,728 kB] Hit:8 http://packages.ros.org/ros/ubuntu xenial InRelease Get:9 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/multiverse Sources [179 kB] Get:10 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/main armhf Packages [1,145 kB] Get:11 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/main Translation-en [568 kB] Get:12 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/main Translation-en_GB [426 kB] Get:13 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/restricted armhf Packages [5,072 B] Get:14 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/restricted Translation-en [2,908 B] Get:15 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/restricted Translation-en_GB [2,556 B] Get:16 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/universe armhf Packages [7,301 kB] Get:17 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/universe Translation-en [4,354 kB] Get:18 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/universe Translation-en_GB [3,040 kB] Get:19 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/multiverse armhf Packages [123 kB] Get:20 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/multiverse Translation-en [106 kB] Get:21 http://mirrors.ustc.edu.cn/ubuntu-ports xenial/multiverse Translation-en_GB [88.1 kB] Get:22 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/main Sources [343 kB] Get:23 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/restricted Sources [2,536 B] Get:24 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/universe Sources [264 kB] Get:25 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/multiverse Sources [8,748 B] Get:26 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/main armhf Packages [796 kB] Get:27 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/main Translation-en [413 kB] Get:28 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/restricted armhf Packages [4,976 B] Get:29 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/restricted Translation-en [2,272 B] Get:30 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/universe armhf Packages [687 kB] Get:31 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/universe Translation-en [324 kB] Get:32 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/multiverse armhf Packages [12.2 kB] Get:33 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-updates/multiverse Translation-en [8,468 B] Get:34 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports/main Sources [4,848 B] Get:35 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports/universe Sources [7,120 B] Get:36 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports/main armhf Packages [7,284 B] Get:37 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports/main Translation-en [4,456 B] Get:38 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports/universe armhf Packages [7,740 B] Get:39 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-backports/universe Translation-en [4,328 B] Get:40 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/main Sources [157 kB] Get:41 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/restricted Sources [2,116 B] Get:42 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/universe Sources [114 kB] Get:43 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/multiverse Sources [3,408 B] Get:44 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/main armhf Packages [541 kB] Get:45 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/main Translation-en [302 kB] Get:46 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/restricted armhf Packages [4,964 B] Get:47 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/restricted Translation-en [2,152 B] Get:48 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/universe armhf Packages [405 kB] Get:49 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/universe Translation-en [191 kB] Get:50 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/multiverse armhf Packages [3,012 B] Get:51 http://mirrors.ustc.edu.cn/ubuntu-ports xenial-security/multiverse Translation-en [2,708 B] Fetched 31.1 MB in 1min 20s (386 kB/s) Reading package lists... Done ads@ads-desktop:/etc/apt$ cd - /home/ads/rplidar_ws ads@ads-desktop:~/rplidar_ws$ cd ~/Work/rikirobot_setup/User/ ads@ads-desktop:~/Work/rikirobot_setup/User$ ls 558-orbbec-usb.rules 58-riki.rules installRikirobot.sh installROS16.04.sh install_rosnavgation.sh install_ros.sh rikihost_network.sh ros_packages_install.sh ads@ads-desktop:~/Work/rikirobot_setup/User$ ./install_ros.sh Reading package lists... Done
出现以上的说明source 刷新成功。
然后安装 桌面完全版ros kinetic
sudo apt-get install ros-kinetic-desktop-full等待这个安装完成。
3 小乌龟例程
可以参考站内这篇文章
http://www.xiaovdiy.cn/?post=416
4 安装必须的包
在实际ros的开发中会有很多依赖包需要安装。
可以写成 install_ros_package.sh 如下
#sudo apt-get update ver=$(rosversion -d) sudo apt-get install -y libv4l-dev sudo apt-get install -y build-essential sudo apt-get install -y chrony sudo apt-get install -y libbullet-dev sudo apt-get install -y libudev-dev sudo apt-get install -y libusb-dev sudo apt-get install -y mini-httpd sudo apt-get install -y ros-$ver\-roslint sudo apt-get install -y ros-$ver\-rosserial sudo apt-get install -y ros-$ver\-imu-filter-madgwick sudo apt-get install -y ros-$ver\-gmapping sudo apt-get install -y ros-$ver\-navigation sudo apt-get install -y ros-$ver\-map-server sudo apt-get install -y ros-$ver\-rgbd-launch sudo apt-get install -y ros-$ver\-costmap-2d sudo apt-get install -y ros-$ver\-camera-info-manager sudo apt-get install -y ros-$ver\-image-transport sudo apt-get install -y ros-$ver\-teleop-twist-keyboard sudo apt-get install -y ros-$ver\-robot-upstart sudo apt-get install -y ros-$ver\-slam-karto sudo apt-get install -y ros-$ver\-geographic-msgs sudo apt-get install -y ros-$ver\-rosbridge-suite sudo apt-get install -y ros-$ver\-robot-pose-publisher sudo apt-get install -y ros-$ver\-tf2-web-republisher sudo apt-get install -y ros-$ver\-web-video-server mkdir ~/catkin_ws/src -p cd ~/catkin_ws/src mkdir depth_camera lidar teleop git clone https://github.com/ykevin/rikirobot_project.git cd rikirobot_project git submodule init git submodule update cd ~/catkin_ws/src echo "add camera ros packages!!" git clone https://github.com/ktossell/camera_umd.git echo "reinstall geometry2 sloved imu error" git clone https://github.com/ros/geometry2.git cd depth_camera echo "add Astra xtion live" echo "Astra xtion driver please: https://orbbec3d.com/develop/" git clone https://github.com/orbbec/ros_astra_launch.git git clone https://github.com/orbbec/ros_astra_camera.git git clone https://github.com/xaxxontech/depthimage_to_laserscan.git cd ~/catkin_ws/src echo "add opencv demo" git clone https://github.com/ykevin/opencv_apps.git echo "slove rosserial indigo version" #git clone https://github.com/ros-drivers/rosserial.git echo "add ps3" #sudo apt-get install -y libusb-dev libspnav-dev libbluetooth-dev libcwiid-dev #sudo pip install pybluez #git clone https://github.com/ros-drivers/joystick_drivers.git echo "add Twist multiplexer" #git clone https://github.com/ros-teleop/twist_mux.git cd teleop echo "add Generic Keyboard Teleop" git clone https://github.com/ykevin/teleop_twist_keyboard.git cd ~/catkin_ws/src cd lidar echo "add hector slam" git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam.git echo "add rplidar ros packages" git clone -b slam https://github.com/robopeak/rplidar_ros.git echo "add EAI X4 lidar ros packages" git clone -b 1.2.3 https://github.com/EAIBOT/ydlidar.git cd ~/catkin_ws/src echo "add robot_localization" git clone https://github.com/cra-ros-pkg/robot_localization.git echo "add imu filter" git clone https://github.com/ykevin/imu_filter_madgwick.git cd ~/catkin_ws/ catkin_make -j1 echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc source ~/.bashrc sudo usermod -aG dialout $USER echo "ROS Packages Installed Successfully"
然后在~ 目录下 放上我们的源码包,这个包也是需要编译出来的供我们调用,比如算法都需要自己先编译一遍的。
这里放上链接,可以直接参考 rikirobot 的编译过程。
catkin_ws的链接如下
链接:https://pan.baidu.com/s/1E4Lii7V0lHu6crX6V4IDuQ
提取码:bfay
复制这段内容后打开百度网盘手机App,操作更方便哦
Install 的安装脚本如下:
链接:https://pan.baidu.com/s/1ND4--z83SlXfiSSUGb4emg
提取码:n559
复制这段内容后打开百度网盘手机App,操作更方便哦
编译之前,在树莓派下记得将swap 虚拟内存提上去,否则会经常卡到中断的。
#先关闭swap cd /var sudo swapoff /var/swap #重设swap大小1M*4096=4GB,会花较长时间,请耐心等待 sudo dd if=/dev/zero of=swap bs=1M count=4096 #格式化 sudo mkswap /var/swap #开启swap sudo swapon /var/swap #设置开机启动,在/etc/fstab文件中添加如下代码 /var/swap swap swap defaults 0 0 #查看当前已生效的swap swapon -s #查看当前swap使用情况 free -m