1-环境搭建及海龟示例demo

安装 ROS 环境

需要注意切换到国内的镜像源,进行安装

修改国内源

1. 备份

备份/etc/apt/sources.list,命令如下:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2. 修改Ubuntu的源列表

修改 /etc/apt/sources.list 文件下的列表,特别需要说明的是这些列表和当前的Ubuntu系统的版本有关,不同版本使用不同的配置。例如

官方中国 Ubuntu 18.04 更新源

deb http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

3. 最后执行更新源命令

sudo apt-get update
sudo apt-get upgrade

安装 ROS-melodic

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 update
sudo apt install ros-melodic-desktop-full rospack-tools

sudo rosdep init

rosdep update

echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc

source ~/.zshrc

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
如果是Python3 需要安装一些依赖
sudo apt-get install -y python3-pip
sudo pip3 install rospkg netifaces defusedxml

安装完成后进行测试

终端中输入命令 roscore

小海龟示例

第一个终端输入 roscore

第二个终端输入 rosrun turtlesim turtlesim_node

rostopic pub -r 10 xxxx/cmd_vel geometry_msgs/Twist (table)

第三个终端输入 rosrun turtlesim turtle_teleop_key

ROS 可视化工具

rqt_graph
上一篇:[原创]银河麒麟操作系统安装PageOffice国产版步骤


下一篇:apt-mirror制作apt源