Hyper-V安装Ubuntu18.04 LTS+ROS(melodic)
记录在Win10中使用自带的Hyper-V来创建虚拟机,安装ROS
Hyper -V安装Ubuntu18.04 LTS
开启Hyper -V
Win10虽自带了Hyper-V,但默认是关闭的,我们可以通过在"启用或关闭Windows功能"中勾选"Hyper-V"来开启,注意点击确认后需要重启(家庭版参考)。
重启完成之后,点击Windows+S键输入"Hyper-V"进行搜索,会出现"Hyper-V管理器"应用,点击Hyper-V管理器后出现Hyper-V管理器的主界面
创建虚拟机
安装本地镜像
Ubuntu镜像下载,清华大学镜像站地址
Centos镜像,清华大学镜像站地址
最终没有成功
遇到两个问题:
- start pxe over ipv4
- (initramfs)unable to find a medium containing a live file
远端镜像安装
点击左边即可下载安装
成功!
测试发现网络已经配置好,且已经共享了剪切板等。
Ubuntu配置
-
apt换源,桌面菜单–》系统设置–》软件和更新–》下载自–》其他站点,选阿里,中科大,清华等等都可以
sudo apt update
sudo apt upgrade -
pip换源
cd ~/.pip
如果不存在.pip则创建目录
mkdir ~/.pip
cd ~/.pip
touch pip.conf
sudo gedit ~/.pip/pip.conf
在pip.conf中写入如下内容:即可
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn -
常用工具
sudo apt install net-tools
sudo apt install -y terminator vim
sudo apt install -y git wget curl
sudo apt-get install -y build-essential checkinstall
sudo apt-get install -y libffi-dev libssl-dev openssl
sudo apt update
vscode
建议去官网下载
wget https://vscode.cdn.azure.cn/stable/f80445acd5a3dadef24aa209168452a3d97cc326/code_1.64.2-1644445741_amd64.deb
sudo dpkg -i code_1.64.2-1644445741_amd64.deb
安装ROS
官网安装教程
#Setup your sources.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'
#Set up your keys
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
没反应则手动添加
进入上诉网址
拷贝整段至 ros.asc
vim ros.asc
sudo apt-key add ros.asc
sudo apt update
# Installation
sudo apt install ros-melodic-desktop-full
#Dependencies for building packages
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update
rosdep update失败参考
最后效果:
xxx@xxx~/$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/xrl/.ros/rosdep/sources.cache
# Environment setup
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
测试安装
xxx@xxx:~/download$ roscore
... logging to /home/xrl/.ros/log/9d662dee-a227-11ec-8771-00155d921506/roslaunch-xrl-Virtual-Machine-24031.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://xrl-Virtual-Machine:36525/
ros_comm version 1.14.12
SUMMARY
========
PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.12
NODES
auto-starting new master
process[master]: started with pid [24042]
ROS_MASTER_URI=http://xrl-Virtual-Machine:11311/
setting /run_id to 9d662dee-a227-11ec-8771-00155d921506
process[rosout-1]: started with pid [24053]
started core service [/rosout]
rviz