设置源(目前找到的能够正常下载的源)
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://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
如果遇到连接到密钥服务器的问题,可以尝试在前面的命令中替换hkp://pgp.mit.edu:80 或 hkp://keyserver.ubuntu.com:80。
首先,确保Debian软件包目录索引是最新的:
sudo apt-get update
ROS中有许多不同的库和工具。我们提供了四种默认配置来帮助入门,也可以单独安装ROS软件包。
sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-desktop
sudo apt-get install ros-melodic-ros-base
sudo apt-get install ros-melodic-PACKAGE
例如
sudo apt-get install ros-melodic-slam-gmapping
要查找可用包,请使用:
apt-cache search ros-melodic
漫长的等待之后就完成了,但这时还需要一些收尾工作
sudo rosdep init
rosdep update
设置环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
到这里就安装完成了,为了实验,可以输入以下命令,出现以下的内容就成功了
lqf@ubuntu:~$ roscore
... logging to /home/lqf/.ros/log/1d089194-d40f-11e8-a539-000c293f82a0/roslaunch-ubuntu-78385.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://ubuntu:46135/
ros_comm version 1.14.3
SUMMARY
========
PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.3
NODES
auto-starting new master
process[master]: started with pid [78395]
ROS_MASTER_URI=http://ubuntu:11311/
setting /run_id to 1d089194-d40f-11e8-a539-000c293f82a0
process[rosout-1]: started with pid [78406]
started core service [/rosout]
构建软件包的依赖关系
到目前为止,已经安装了运行核心ROS软件包所需的内容。要创建和管理ROS工作区,有各种工具和需求分开分发。例如,rosinstall是一个经常使用的命令行工具,它使您能够使用一个命令轻松下载ROS软件包的许多源代码树。
要安装此工具和其他依赖关系来构建ROS软件包,请运行:
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt-get install ros-melodic-turtlesim
如果报错
Could not get lock /var/cache/apt/archives/lock
则先
sudo rm -rf /var/cache/apt/archives/lock
sudo apt-get update
再继续安装
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
https://blog.csdn.net/zhangrelay/article/details/80241758
https://blog.csdn.net/ZhangRelay/article/details/80104329?utm_source=blogxgwz0