ROS学习笔记基础1(Ubuntu16.04安装ROS和依赖包)

文章目录

    • 1. 选择最佳服务器
    • 2. 根据官方教程安装ros
    • 3. 出错的解决
    • 4. 启动`roscore`
    • 5. 安装`vectormath`
    • 6. 安装`gazebo9`
    • 安装`map-server`
    • 7. 下载配套资料

1. 选择最佳服务器

选择一个最快的服务器

2. 根据官方教程安装ros

ROS wiki

打开终端,输入以下

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 install python-rosinstall python-rosinstall-generator python-wstool build-essential

3. 出错的解决

如果出现安装源问题:

下列软件包有未满足的依赖关系:
ros-kinetic-desktop-full : 依赖: ros-kinetic-desktop 但是它将不会被安装
依赖: ros-kinetic-perception 但是它将不会被安装
依赖: ros-kinetic-simulators 但是它将不会被安装
依赖: ros-kinetic-urdf-tutorial 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系

选择中科大源

首先在设置–更新里选择中科大http://mirrors.ustc.edu.cn的源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

然后运行:

sudo gedit /etc/apt/sources.list

确保里面的内容是如下:

deb http://archive.ubuntu.com/ubuntu xenial main universe restricted multiverse
deb-src http://archive.ubuntu.com/ubuntu xenial main universe restricted multiverse #Added by software-properties
deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted multiverse universe
deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted multiverse universe

然后保存,关闭,继续正常安装

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 install python-rosinstall python-rosinstall-generator python-wstool build-essential

4. 启动roscore

测试是否成功,终端输入:

roscore

5. 安装vectormath

参考安装python科学计算环境安装pip

sudo apt-get install python-pip
sudo apt-get install python-dev

参考pypi.org安装vectormath包

pip install vectormath

注意 :大部分的科学计算包。例如PyGeodesy等,都是通过pip install这个命令去安装的。
如果apt-get install失败了,马上考虑使用pip install命令尝试。

vectormath使用简介

import numpy as np
import vectormath as vmath

# Single Vectors
v = vmath.Vector3(5, 0, 0)
v.normalize()
print(v)                          # >> [1, 0, 0]
print(v.x)                        # >> 1.0

# VectorArrays are much faster than a for loop over Vectors
v_array = vmath.Vector3Array([[4, 0, 0], [0, 2, 0], [0, 0, 3]])
print(v_array.x)                  # >> [4, 0, 0]
print(v_array.length)             # >> [4, 2, 3]
print(v_array.normalize())        # >> [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
# Vectors can be accessed individually or in slices
print(type(v_array[1:]))          # >> vectormath.Vector3Array
print(type(v_array[2]))           # >> vectormath.Vector3

# All these classes are just numpy arrays
print(isinstance(v, np.ndarray))  # >> True
print(type(v_array[1:, 1:]))      # >> numpy.ndarray

6. 安装gazebo9

确认版本

gazebo -v

安装最新版本的gezebo 9

curl -sSL http://get.gazebosim.org | sh
gazebo9

最后确认以一下版本号

lk@Mibook:~$ gazebo -v
Gazebo multi-robot simulator, version 9.9.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

安装map-server

apt-get install ros-kinetic-map-server

7. 下载配套资料

首先生成密钥,把id_rsa.pub添加到公钥

ssh-keygen -t rsa -C "[email protected]"
gedit id_rsa.pub 

然后git clone

git clone [email protected]:xiaokai1996/ROS-Academy-for-Beginners.git

参考资料

https://github.com/xiaokai1996/ROS-Academy-for-Beginners

https://sychaichangkun.gitbooks.io/ros-tutorial-icourse163/content/

你可能感兴趣的:(ROS)