目录
一、树莓派安装ubuntu18.04
1 下载ubuntu系统文件
2?将系统文件烧入SD卡
3 强制修改HDMI输出分辨率(此步骤可忽略)
4 设置wifi(此步骤也可忽略,后续连接网线安装桌面)
5 插入内存卡,安装Ubuntu系统
6 命令行配置WIFI
7??安装桌面环境
二、安装clash(科学上网)
三、安装远程桌面
四、安装ROS-melodic
1、安装ros完整版
2、rosdep init解决方案
五、安装MAVROS
1、二进制安装(推荐)
2、源码安装
六、树莓派串口配置
七、安装librealsense
1、二进制安装(简单且时间短,但容易失败)
2、vcpkg安装(失败)
3、源码安装(时间很长)
八、安装VIO?
九、安装realsense_ros(realsense2_camera)
1、二进制安装
2、源码安装
一、树莓派安装ubuntu18.04
1 下载ubuntu系统文件
ubuntu官网为树莓派提供的系统已经升级到ubuntu20 ,所以本文从清华的开源镜像网站下载ubuntu18的系统文件。目前只有server版,需要后面手动安装桌面。树莓派4选择arm64位。 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/releases/bionic/release/ubuntu-18.04.5-preinstalled-server-arm64%2Braspi4.img.xz
也可在该网站:Index of /ubuntu-cdimage/ubuntu/releases/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror下载其他版本系统
2?将系统文件烧入SD卡
windows平台:使用7zip之类的软件将ubuntu系统文件解压为img镜像文件,然后使用win32 disk imager烧入SD卡
3 强制修改HDMI输出分辨率(此步骤可忽略)
?在“usercfg.txt”这个文件中,写入以下内容:
hdmi_force_hotplug=1
config_hdmi_boost=4
hdmi_group=2
hdmi_mode=58
# hdmi_drive=2
hdmi_ignore_edid=0xa5000080
disable_overscan=1
hdmi_force_hotplug:强制使用HDMI输出 config_hdmi_boost:HDMI信号增强。 hdmi_group、hdmi_mode:设定分辨率。因为没有1920 * 1080 60Hz,我就选择了1680 * 1050 60Hz
hdmi_drive:强制音频输出到HDMI口。如果不想将音频通过模拟信号输出,删除这一行。反之去掉上面的注释号 hdmi_ignore_edid:强行按hdmi_group和hdmi_mode规定的分辨率输出。不检测显示器自身的分辨率。 disable_overscan:强行禁止保留黑边功能。
4 设置wifi(此步骤也可忽略,后续连接网线安装桌面)
打开 system-boot 磁盘下根目录的 network-config 文件,写入下面的内容:wifi-name ?对应你要连接的wifi名字,wifi-password ?对应wifi密码。
wifis:
wlan0:
dhcp4: true
dhcp6: true
optional: true
access-points:
"wifi-name":
password: "wifi-password"
5 插入内存卡,安装Ubuntu系统
此步骤一定要注意,确保内存卡插入方向正确且连接良好,通电前确保树莓派除鼠标键盘外没有连接任何设备,尤其是串口,否则容易导致开机乱码,无法进行正常的系统安装。
如果在开机前就连接外设,那么串口外设发送的串口数据会干扰ubuntu开机,因为ubuntu开机时u-boot(类似bootloader)会默认等待串口数据2s再进入autoboot打开系统,这期间一旦有串口数据就会进入u-boot(类似电脑开机按F2会进入BIOS)。这会导致系统无法打开,屏幕一直显示串口设备发来的乱码。
解决办法是取消这个u-boot的2s等待时间,直接进入系统(但这样也会导致以后再也进不了u-boot了)后续更新解决方法……
6 命令行配置WIFI
首先执行以下命令:
sudo vi /etc/netplan/50-cloud-init.yaml
比如手机热点的名称是xiaomi,密码是12345678, 那么配置文件修改成这样:
network:
ethernets:
eth0:
dhcp4: true
optional: true
version: 2
wifis:
wlan0:
dhcp4: true
access-points:
"xiaomi":
password: "12345678"
vim编辑器下,输入字母 “i” 进入编辑模式,方向键控制光标位置,“ctrl+o”保存并退出编辑状态,按“shift+;”然后输入“wq”,回车后即可退出vim编辑器
?修改保存后检查语法幷使配置生效
sudo netplan generate
sudo netplan apply
?等待一会,要是不行的话重启树莓派。
7??安装桌面环境
进入后需要账号和密码:开始都默认是ubuntu 然后你需要修改密码 再然后就可以进入终端界面了
先更新一下源,然后重启
sudo apt-get update
sudo apt-get upgrade
reboot
再次进入系统后,下载桌面环境,时间有点长耐心等待
sudo apt-get install ubuntu-desktop
下完后还没完全成功,我们需要跟着提示输入一下命令
sudo apt-get update --fix-missing
下完后重启,再次输入下载命令
reboot
sudo apt-get install ubuntu-desktop
然后运行桌面环境
startx
二、安装clash(科学上网)
容易被和谐,需要的可以私聊我
三、安装远程桌面
我习惯用nomachine,也可以自行安装VNC
在nomachine官网下载相应的版本安装即可,Ubuntu系统的需要根据系统选,可在windows电脑下载好后拷贝过去,双击即可安装成功。
四、安装ROS-melodic
1、安装ros完整版
参考cn/melodic/Installation/Ubuntu - ROS Wiki步骤进行安装
2、rosdep init解决方案
安装完ROS后,初始化指令sudo rosdep init失败,提示: sudo: rosdep:command not found 按照以下方式解决:
sudo apt install rospack-tools
正常执行 rosdep init 会出现如下错误,原因是该网站被墙
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
该步骤的作用就是创建一个名为 “20-default.list” 的文件,我们可以用浏览器打开这个网站,将网页内容复制下来:
首先创建 “20-default.list” 文件
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
将以下内容复制进20-default.list文件中
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
然后再执行 rosdep update
五、安装MAVROS
参照官网:
MAVROS | PX4 自动驾驶用户指南
mavros/mavros at master · mavlink/mavros · GitHub
1、二进制安装(推荐)
sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
在根目录会出现一个 install_geographiclib_datasets.sh 文件,右键属性,修改可执行权限,然后运行下述指令:
./install_geographiclib_datasets.sh
二进制安装的mavros包位置为:/opt/ros/melodic/share/mavros,后续可能需要修改px4.launch文件内容
2、源码安装
sudo apt-get install python-catkin-tools python-rosinstall-generator -y
# For Noetic use that:
# sudo apt install python3-catkin-tools python3-rosinstall-generator python3-osrf-pycommon -y
# 1. Create the workspace: unneeded if you already has workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src
# 2. Install MAVLink
# we use the Kinetic reference for all ROS distros as it's not distro-specific and up to date
rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall
# 3. Install MAVROS: get source (upstream - released)
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
# alternative: latest source
# rosinstall_generator --upstream-development mavros | tee -a /tmp/mavros.rosinstall
# For fetching all the dependencies into your catkin_ws, just add '--deps' to the above scripts
# ex: rosinstall_generator --upstream mavros --deps | tee -a /tmp/mavros.rosinstall
# 4. Create workspace & deps
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y
# 5. Install GeographicLib datasets:
./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
# 6. Build source
catkin build
# 7. Make sure that you use setup.bash or setup.zsh from workspace.
# Else rosrun can't find nodes from this workspace.
source devel/setup.bash
六、树莓派串口配置
首次运行?roslaunch mavros px4.launch 后,会出现如下问题:
FCU: DeviceError:serial:open: No such file or directory
?首先修改 px4.launch 文件串口号和波特率,我用的串口号为ttyAMA0,波特率为115200
cd /opt/ros/melodic/share/mavros/launch
sudo vim px4.launch
再次运行?roslaunch mavros px4.launch 后,会出现如下问题:
FCU: DeviceError:serial:open: Permission denied
方法1:?
这是需要修改树莓派串口配置文件,参考链接:
pi 3 - How do I make serial work on the Raspberry Pi3 (PiZeroW, Pi4 or later models) - Raspberry Pi Stack Exchange
请仔细遵循这6个步骤
Step 1 - Install Raspbian Jessie onto a SD card and boot the Pi when connected to a network Login via terminal or desktop and shell Configure the system with:
sudo raspi-config
Expand filesystem and enable serial on advanced page, exit and reboot.
Step 2 -this won't necessary if you have jessie new release Update the system with:
sudo apt-get update
sudo apt-get upgrade
Step 3 - Device Tree settings as below:
Add device tree to?/boot/config.txt?to disable the Raspberry Pi 3 bluetooth.
sudo vim /boot/config.txt
Add at the end of the file
*if you want to change the blutooth to miniuart port(bad)
dtoverlay=pi3-miniuart-bt
*if you want to disable the blutooth(good)
dtoverlay=pi3-disable-bt
Exit the editor saving your changes.
Step 4 - reboot the pi
sudo reboot
step 5 -
a)to disable the Serial Console edit the file using
sudo vim /boot/cmdline.txt
remove the word phase "console=serial0,115200 " or "console=ttyAMA0,115200 "
Exit and save your changes
b)to Enable the Serial Console edit the file using
sudo vim /boot/cmdline.txt
Change the file to the following:
dwc_otg.lpm_enable=0 console=tty1 console=serial0(or ttyAMA0),115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Exit and save your changes
Step 6 - reboot the pi
sudo reboot
方法二:
因为我安装的不是Raspian系统,因此无法用raspi-config打开该串口。
ubuntu server raspi系统的/boot/firmware/config.txt里也说明了,enable_uart=1默认启用这个串口,linux里面名字叫 /ttyAMA0,但是默认是当串口控制台使用了(/boot/firmware/nobtcmd.txt里也写了console = /ttyAMA 921600)
而且这个硬件串口也和蓝牙连接在一起。想要用这个串口给另外的外设使用,必须禁用掉串口控制台和蓝牙。
方法:
1、/boot/firmware/nobtcmd.txt里删除console = /ttyAMA 921600从而禁用串口控制台。这个txt文件也可以用读卡器把sd卡插到windows系统里在system-boot里找到。
2、/boot/firmware/config.txt 里设置enable_uart=1(默认就是)。如果=0表示启用minicom串口,而不是这个硬件串口。
3、/boot/firmware/config.txt 里加入一行dtoverlay=disable-bt从而禁用蓝牙。
4、sudo systemctl disable bluetooth…… 禁用掉和蓝牙有关的开机启动项。直到桌面不再显示蓝牙标志,但是还有/ttyAMA0存在。
这样,开机后连接串口外设,使用/ttyAMA0就能正常串口通信了。?
最后要修改串口权限:
sudo chmod a+rw /dev/ttyAMA0
上述步骤是临时打开串口权限,想要永久打开串口权限,参考链接:
ubuntu 永久打开USB串口权限、232串口权限_wongHome的博客-CSDN博客
首先查看用户组
ls -l /dev/ttyA*
终端输出:
crw--w---- 1 root tty 204, 64 Oct 5 07:55 /dev/ttyAMA0
可以看到用户 root ,所属用户组为 tty, 因此一种方法是把我们的当前用户名 加入到这个用户组。
whoami
终端输出:
ubuntu
接着终端输入:
sudo usermod -aG tty ubuntu
最后,logout 再登入系统,登陆名ubuntu就可以使用该串口了?
七、安装librealsense
1、二进制安装(简单且时间短,但容易失败)
参考链接:librealsense/distribution_linux.md at master · IntelRealSense/librealsense · GitHub
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
但是该方法经常在?sudo apt-get install librealsense2-dkms 时出错
2、vcpkg安装(失败)
参考链接:GitHub - IntelRealSense/librealsense: Intel? RealSense? SDK
您可以使用vcpkg依赖项管理器下载并安装librealsense:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install realsense2
3、源码安装(时间很长)
3.1 安装依赖包
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
sudo apt-get install git cmake libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
第二行的是核心依赖,必装。第三行是3D相关的依赖,如果不打算使用realsense-viewer,可以不装。
3.2?下载Realsense SDK
git clone https://github.com/IntelRealSense/librealsense.git
cd ~/librealsense
或者直接去上述地址下载zip包,解压
3.3 编译准备
mkdir build && cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=true -DFORCE_RSUSB_BACKEND=ON -DBUILD_WITH_TM2=false -DIMPORT_DEPTH_CAM_FW=false
3.4?编译
sudo make uninstall && make clean && make && sudo make install
这步大概要1~2小时,反正很慢。。
3.5 设置udev规则
sudo ./scripts/setup_udev_rules.sh
会提示你拔掉摄像头,然后按任意键,主要是为了让realsense-viewer更方便的识别设备
3.6 测试
realsense-viewer
八、安装VIO?
参考链接:GitHub - Auterion/VIO: Interface PX4 with Realsense T265
-
This is a ROS package, it assumes you have either ROS Kinetic (Ubuntu 16.04) or ROS Melodic (Ubuntu 18.04) installed, instructions can be found?here. Please also make sure you install librealsense from?here. -
Install catkin and create your catkin workspace directory. sudo apt install python-catkin-tools
mkdir -p ~/catkin_ws/src -
Clone this repository in your catkin workspace. cd ~/catkin_ws/src
git clone https://github.com/Auterion/VIO.git -
Install MAVROS (version 0.29.0 or above).
Note:?Instructions to install MAVROS from sources can be found?here.
-
Build the package: cd ~/catkin_ws
catkin build px4_realsense_bridge -
Run th ROS node: cd ~/catkin_ws/src
roslaunch px4_realsense_bridge bridge_mavros.launch
九、安装realsense_ros(realsense2_camera)
参考链接:GitHub - IntelRealSense/realsense-ros: Intel(R) RealSense(TM) ROS Wrapper for D400 series, SR300 Camera and T265 Tracking Module
1、二进制安装
realsense2_摄像头是以debian软件包的形式提供的ROS发行版。可以通过键入以下内容来安装,安装的位置在?/opt/ros/melodic/share/realsense2_camera/launch ,后续可能需要修改?rs_camera.launch 文件内容
sudo apt-get install ros-$ROS_DISTRO-realsense2-camera
2、源码安装
- Clone the latest Intel? RealSense? ROS from?here?into 'catkin_ws/src/'
git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
- Make sure all dependent packages are installed. You can check .travis.yml file for reference.
- Specifically, make sure that the ros package?ddynamic_reconfigure?is installed. If?ddynamic_reconfigure?cannot be installed using APT or if you are using?Windows?you may clone it into your workspace 'catkin_ws/src/' from?here
catkin_init_workspace
cd ..
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
To start the camera node in ROS: roslaunch realsense2_camera rs_camera.launch
|