树莓派raspberryPI 4b raspios-buster-arm64.img 系统下编译构建ros melodic环境

一、准备姿势

1.尝试不同版本系统下进行ros构建,选择合适的版本,地址:

https://downloads.raspberrypi.org/
2021-05-07-raspios-buster-arm64.img
最新版本bullseye ros暂无支持, 树莓派4b 8GB运行内存版本

常见错误:

1)python环境下只能用python3 以上

2)需要单独安装以下软件

sudo pip install python3-rospkg python3-psutil libboost-thread-dev python3-defusedxml python3-yaml libboost-all-dev python3-opencv python3-numpy python3-pyqt5.qtopengl python3-netifaces python3-mock python3-pyqt5.qtwebkit python3-empy python3-matplotlib python3-paramiko python3-rospkg-modules python3-pyqt5 python3-pyqt5.qtsvg python3-sip-dev libogre-1.9-dev libbz2-dev python3-opengl python3-pydot python3-pygraphviz python3-sip-dev python3-pil python3-pycryptodome python3-gnupg python3-catkin-pkg-modules python3-rosdep-modules python3-coverage python3-cairo python3-catkin-pkg python3-nose

3)各个支持镜像源内无bullseye版本,源站可参考

http://wiki.ros.org/ROS/Installation/UbuntuMirrors

如:http://packages.ros.org.ros.informatik.uni-freiburg.de/ros/ubuntu/dists/

树莓派raspberryPI 4b raspios-buster-arm64.img 系统下编译构建ros melodic环境_第1张图片
current date : 2022-07-25

并无bullseye,最近仅支持buster版本

4)python 版本对不上,目前支持的并不太行

./src/catkin/bin/catkin_make_isolated --install --install-space
/home/pi/ros_env
-DCMAKE_BUILD_TYPE=Release
-DSETUPTOOLS_DEB_LAYOUT=OFF
-DSETUPTOOLS_ARG_EXTRA=“”
-DPYTHON_INCLUDE_DIR=/usr/include/python3.9
-DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.9.so
-DPYTHONPATH=/usr/lib/python3/dist-packages
-DPYTHON_EXECUTABLE=/usr/bin/python3

export PYTHONPATH=/usr/lib/python3/dist-packages

  1. 最终合适版本:2021-05-07-raspios-buster-arm64 地址:

https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2021-05-28/2021-05-07-raspios-buster-arm64.zip

选用16GB TF卡烧录系统镜像

二、动起来

1.windows cmd:

打开TF卡,文件boot 目录下建立文件

G:>type nul>ssh
G:>>>userconf set /p=“pi: 6 6 6KORC/Q.jy9sfO4dY$Ng2/O021CmodjQ99aPm.kpG4s1ClxvfQN0UylymYN/AYGySUBV6mnPlLDD24YrckXldGR9ZWO3NvOazzNLhBe1”

G:>>>wpa_supplicant.conf set /p="country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
"

注意指令前的”G:>“ 系统自带字符

然后用notepad打开wpa_supplicant.conf 查看下文件,注意换行符

然后将TF卡插到树莓派上,开机启动。

后执行

G:>arp -a

接口: 192.168.193.137 — 0x13
Internet 地址 物理地址 类型
192.168.193.1 d4-ee-07-62-f5-76 动态
192.168.193.239 e4-5f-01-c2-98-51 动态
192.168.193.255 ff-ff-ff-ff-ff-ff 静态

192.168.193.239 树莓派 地址

2.#rplidar_ros

1)登陆ssh

windows pwoershell:

PS D:\ros> ssh [email protected]

密码:raspberry

进入树莓派系统

在这里插入图片描述

2)正式动作

$ cat /etc/debian_version
10.9
$ uname -a
Linux raspberrypi 5.10.17-v8+ #1414 SMP PREEMPT Fri Apr 30 13:23:25 BST 2021 aarch64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster

{https://mirror.tuna.tsinghua.edu.cn/help/raspbian/}
$ sudo nano /etc/apt/sources.list

aarch64 用户:编辑 /etc/apt/sources.list 文件,用以下内容取代:
默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
$ sudo vi /etc/apt/sources.list.d/raspi.list

对于两个架构,编辑 /etc/apt/sources.list.d/raspi.list 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main
$ sudo sh -c ‘echo “deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ lsb_release -cs main” > /etc/apt/sources.list.d/ros-latest.list’

{backup source: sudo sh -c ‘echo “deb http://mirrors.sjtug.sjtu.edu.cn/ros/ubuntu/ $(lsb_release -cs) 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 upgrade

$ sudo apt install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake

Setting up python-rosdistro-modules (0.9.0-1) …
Setting up python-launchpadlib (1.10.6-2) …
Setting up python3-wstool (0.1.17-1) …
Setting up python3-rosinstall-generator (0.1.22-1) …
Setting up python-rosdep-modules (0.22.1-1) …
Setting up python-rosdep (0.22.1-1) …
Setting up python3-rosinstall (0.7.8-2) …
Processing triggers for man-db (2.8.5-2) …
Processing triggers for libc-bin (2.28-10+rpt2+rpi1+deb10u1) …
$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

rosdep update

$ rosdep update

{手动安装,自动升级未必可行,出现各种错误!_!}
$ cd ~/home/pi/

$ git clone https://gitee.com/zhao-xuzuo/rosdistro
$ sudo vi /home/pi/rosdistro/rosdep/sources.list.d/20-default.list

{ # os-specific listings first yaml file:///home/pi/rosdistro/rosdep/osx-homebrew.yaml osx # generic yaml file:///home/pi/rosdistro/rosdep/base.yaml yaml file:///home/pi/rosdistro/rosdep/python.yaml yaml file:///home/pi/rosdistro/rosdep/ruby.yaml gbpdistro file:///home/pi/rosdistro/releases/fuerte.yaml fuerte # newer distributions (Groovy, Hydro, …) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead }
$ sudo vi /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

{DEFAULT_SOURCES_LIST_URL = ‘file:///home/pi/rosdistro/rosdep/sources.list.d/20-default.list’}
$ sudo vi /usr/lib/python2.7/dist-packages/rosdistro/{}init{}.py

{DEFAULT_INDEX_URL = ‘file:///home/pi/rosdistro/index-v4.yaml’}
$ sudo vi /usr/lib/python2.7/dist-packages/rosdep2/rep3.py

{REP3_TARGETS_URL = ‘file:///home/pi/rosdistro/releases/targets.yaml’}
$ 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 file:///home/pi/rosdistro/index-v4.yaml
Skip end-of-life distro “ardent”
Skip end-of-life distro “bouncy”
Skip end-of-life distro “crystal”
Add distro “dashing”
Skip end-of-life distro “eloquent”
Add distro “foxy”
Skip end-of-life distro “groovy”
Skip end-of-life distro “hydro”
Skip end-of-life distro “indigo”
Skip end-of-life distro “jade”
Add distro “kinetic”
Skip end-of-life distro “lunar”
Add distro “melodic”
Add distro “noetic”
Add distro “rolling”
updated cache in /home/pi/.ros/rosdep/sources.cache

$ rosinstall_generator desktop --rosdistro melodic --deps --wet-only --tar > melodic-desktop-wet.rosinstall
$ wstool init src melodic-desktop-wet.rosinstall (wstool update -j4 -t src ,after trigger error interrupt, and you can copy any ros_ws into src to save your money , ha no your time…)
$ mkdir -p ~/ros_catkin_ws
$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro melodic -r --os=debian:buster

{it will continue a long time to install depens package}
$ ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /home/pi/ros_env

{below is backup to solve problem… , Do not excute… ./src/catkin/bin/catkin_make_isolated --install --install-space \ /home/pi/ros_env \ -DCMAKE_BUILD_TYPE=Release \ -DSETUPTOOLS_DEB_LAYOUT=OFF \ -DSETUPTOOLS_ARG_EXTRA=“” \ -DPYTHON_INCLUDE_DIR=/usr/include/python3.9 \ -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.9.so \ -DPYTHONPATH=/usr/lib/python3/dist-packages \ -DPYTHON_EXECUTABLE=/usr/bin/python3 export PYTHONPATH=/usr/lib/python3/dist-packages }
it will be turn into log…


running install
running install_lib
creating /home/pi/ros_env/lib/python2.7/dist-packages/xacro
copying /home/pi/ros_catkin_ws/build_isolated/xacro/lib.linux-aarch64-2.7/xacro/{}init{}.py -> /home/pi/ros_env/lib/python2.7/dist-packages/xacro
copying /home/pi/ros_catkin_ws/build_isolated/xacro/lib.linux-aarch64-2.7/xacro/xmlutils.py -> /home/pi/ros_env/lib/python2.7/dist-packages/xacro
copying /home/pi/ros_catkin_ws/build_isolated/xacro/lib.linux-aarch64-2.7/xacro/color.py -> /home/pi/ros_env/lib/python2.7/dist-packages/xacro
copying /home/pi/ros_catkin_ws/build_isolated/xacro/lib.linux-aarch64-2.7/xacro/cli.py -> /home/pi/ros_env/lib/python2.7/dist-packages/xacro
byte-compiling /home/pi/ros_env/lib/python2.7/dist-packages/xacro/{}init{}.py to {}init{}.pyc
byte-compiling /home/pi/ros_env/lib/python2.7/dist-packages/xacro/xmlutils.py to xmlutils.pyc
byte-compiling /home/pi/ros_env/lib/python2.7/dist-packages/xacro/color.py to color.pyc
byte-compiling /home/pi/ros_env/lib/python2.7/dist-packages/xacro/cli.py to cli.pyc
running install_scripts
copying /home/pi/ros_catkin_ws/build_isolated/xacro/scripts-2.7/xacro -> /home/pi/ros_env/bin
changing mode of /home/pi/ros_env/bin/xacro to 755
running install_egg_info
Writing /home/pi/ros_env/lib/python2.7/dist-packages/xacro-1.13.17.egg-info
– Installing: /home/pi/ros_env/lib/xacro/xacro
– Installing: /home/pi/ros_env/share/xacro/xacro.py
<== Finished processing package [187 of 187]: ‘xacro’

$ source /home/pi/ros_env/setup.bash
$ echo “source /home/pi/ros_env/setup.bash” >> ~/.bashrc

{successful… great charming perfect excelente branllian _}

3)Run your VNC to connect raspberrypi ;运行ROS
执行完前面步骤后试运行一下。

    启一个bash终端输入指令

$ roscore

    Ctrl+Alt+T再启一个bash终端输入指令

$ rosrun turtlesim turtlesim_node

    Ctrl+Alt+T再启第三个bash终端输入指令

$ rosrun turtlesim turtle_teleop_key

最终效果:

出现吧,玄武之灵 →→→→→→→→→→→→→→→→→→→→→→→→→→→→:******aowoo~

树莓派raspberryPI 4b raspios-buster-arm64.img 系统下编译构建ros melodic环境_第2张图片

4)备份TF卡。。。。。
backup image
$ sudo dd if=/dev/mmcblk0 | gzip>/media/pi/usb-storage/rpi-ros-mmc-bak.img.gz &
$ sudo watch -n 2 pkill -USR1 -n -x dd
$ sudo gzip -dc /media/pi/usb-storage/rpi-ros-mmc-bak.img.gz | sudo dd of=/dev/mmcblk0

你可能感兴趣的:(ros,linux,嵌入式硬件)