修改国内源
修改apt
sudo cp /etc/apt/source.list /etc/apt/source.list.old
sudo gedit /etc/apt/source.list
输入如下进行保存
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
修改pip
sudo gedit ~/.pip/pip.config
输入如下代码:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
安装ROS
配置源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
配置Key
sudo apt install curl # 安装curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
更新apt
sudo apt update
安装ROS
sudo apt install ros-melodic-desktop-full
默认终端加载ROS环境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装ROS包依赖
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential python-rosdep
初始化rosdep
sudo rosdep init
rosdep update
sudo rosdep init如果报错,可以用手机的热点连接然后重新试一下。再不行可以参考网上的更多解决办法。
ROS测试
启动roscore
开启新的终端,然后运行:
roscore
启动乌龟ui
rosrun turtlesim turtlesim_node
启动乌龟键盘控制器
rosrun turtlesim turtle_teleop_key
安装Gazebo
卸载安装ros时候安装的gazebo
sudo apt-get remove gazebo*
sudo apt-get remove libgazebo*
sudo apt-get remove ros-melodic-gazebo*
设置计算机以接受来自package.osrfoundation.org的软件
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
检查是否成功:
cat /etc/apt/sources.list.d/gazebo-stable.list
安装密钥
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
更新apt
sudo apt-get update
安装gazebo
sudo apt-get install gazebo9=9.1*
安装ros的gazebo插件
sudo apt install ros-melodic-gazebo9-*
sudo apt install ros-melodic-gazebo-*
安装gazebo依赖
sudo apt upgrade libignition-math2
解决gazebo显示问题
echo "export SVGA_VGPU10=0">>~./bashrc
测试gazebo的安装
启动两个新的终端:
roscore
rosrun gazebo_ros gazebo
成功运行
安装mavros
更新软件系统
sudo apt-get update
sudo apt-get upgrade
安装mavros的相关依赖
sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras
下载安装install_geographiclib_datasets
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo chmod a+x ./install_geographiclib_datasets.sh
sudo bash ./install_geographiclib_datasets.sh
安装PX4
下载PX4源码
git clone -b v1.12.3 https://github.com/PX4/PX4-Autopilot.git --recursive
mv PX4-Autopilot PX4_Firmware
安装依赖
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
PX4编译
cd PX4-Autopilot
make px4_sitl_default gazebo
成功之后将打开gazebo。
配置环境
gedit ~/.bashrc
加入如下内容:
source ~/PX4_Firmware/Tools/setup_gazebo.bash ~/PX4_Firmware/ ~/PX4_Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware/Tools/sitl_gazebo
当前终端运行一下如下代码,加载配置的环境:
source ~/.bashrc
安装地面站QGC
安装依赖
sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
sudo apt install libqt5gui5 -y
sudo apt install libfuse2 -y
下载QGC
wget https://d176tv9ibo4jno.cloudfront.net/latest/QGroundControl.AppImage
运行QGC
chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage