ROS的全称是The Robot Operating System,是一种开源的机器人系统,由于其功能是独立的而模块化,支持多语言编程(message通信机制),其应用范围已经不仅在机器人领域了,伴随这着Ros的发展,已逐步应用于自动驾驶等领域。
比如我的是ubuntu,点击后面的问号选择版本。
ubuntu下使用命令查看自己的ubuntu版本:
lsb_release -a
或
cat /etc/issue
选择适合自己系统版本的镜像源,下面出现的代码就是要替换的源地址
打开配置文件:
sudo gedit /etc/apt/sources.list
在前面新增或替换为以下地址:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
ROS安装必须先配置公钥,需要通过系统的安全认证,所以第一步就是配置公钥
$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo sh -c '. /etc/lsb-release && echo "d{2d3b390d-f615-41d0-a830-7bbdcedbd397}eb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-get update
sudo apt-get upgrade
设置编码:
sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
Ubuntu | Ros1 | Ros2 |
---|---|---|
16.04 LTS | Kinetic LTS | Ardent |
18.04 LTS | Melodic LTS | Dashing LTS |
20.04 LTS | Noetic LTS | Foxy LTS |
22.04 LTS | Noetic Ninjemys | Humble Hawksbill |
注意:目前Ros1对22.04的支持
安装桌面完整版ros:
sudo aptitude install ros-noetic-desktop-full
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果需要下载安装一些Ros包:
sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool -y
如果要通过xml启动Ros节点:
sudo apt install python3-roslaunch -y
如果现在进行4.2的测试,可能遇到以下问题:
Resource not found: roslaunch
The traceback for the exception was written to the log file
重启使之前安装配置的生效
Ros启动命令:
roscore
打印以下格式信息说明成功启动:
root@DESKTOP-7PBML8U:/home/ssr# roscore
... logging to /root/.ros/log/ad1b121e-a611-11ee-89e9-57487a114ada/roslaunch-DESKTOP-7PBML8U-822.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://DESKTOP-7PBML8U:37425/
ros_comm version 1.16.0
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.16.0
NODES
auto-starting new master
process[master]: started with pid [832]
ROS_MASTER_URI=http://DESKTOP-7PBML8U:11311/
setting /run_id to ad1b121e-a611-11ee-89e9-57487a114ada
process[rosout-1]: started with pid [842]
started core service [/rosout]
再开一个控制台窗口,输入小海龟启动命令:
rosrun turtlesim turtlesim_node
则会出现一个小海龟
然后再开一个窗口,启动小海龟控制节点:
rosrun turtlesim turtle_teleop_key
然后按↑↓←→,小海龟就会按指定方向移动了