查看主机ip
hostname -I
查看ssh服务是否启动
sudo ps -e | grep ssh
查看系统版本,使用代码
root@ubuntu:~# lsb_release -a

输出示例

Distributor ID: UbuntuDescription:Ubuntu 22.04.2 LTSRelease:22.04Codename: jammy
查看系统架构,使用代码

(x86 架构与 ARM 架构的 CPU 架构不同,如果回显为 aarch64表示为 ARM 架构,如果回显为 x86_64 表示为x86架构)

root@ubuntu:~# uname -a

输出示例

Linux k8s-master 5.15.0-1027-raspi #29-Ubuntu SMP PREEMPT Mon Apr 3 10:12:21 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

或则使用如下代码查看系统架构

root@ubuntu:~# uname -m

输出示例

aarch64
Ubuntu 拷贝文件后文件带锁

在 Ubuntu 中,如果你使用 sudo 命令拷贝文件到一个需要 root 权限的目录,这个文件就会被标记为锁定状态(locked),只有root 用户或者具有相应权限的用户才能修改或删除它。如果你想要修改这个文件,可以使用 chown 命令将文件的所有权转移给自己,然后再进行修改。具体步骤如下: 1.打开终端,使用以下命令将文件的所有权转移给自己:

sudo chown your_username:your_username file path

其中,”your username”为你的用户名,”file_path”为文件的路径。

参考:Ubuntu 拷贝文件后文件带锁 – CSDN文库

查看python所在的路径
which python

/usr/bin/目录下通过ls -l查看软链接的情况

系统换源

参考:Ubuntu更换软件源(20.04LTS版本)【ARM架构以及X86架构的Ubuntu】_ubunutu(arm)20.04更换软件源 csdn-CSDN博客

1.1备份原来的源

sudo cp /etc/apt/sources.list /etc/apt/sources_init.list

1.2更换源

清华大学的镜像源地址:清华大学开源软件镜像站 | Tsinghua Open Source Mirror

选择对应的Ubuntu版本复制里面的内容。复制到刚刚的 /etc/apt/sources.list文件中。 注意:Ubuntu必须要对应版本!!!!否则镜像源无效。然后执行(这里以ARM架构为例)

# 先更新sudo apt-get update sudo apt-get upgrade# 安装nano编辑器sudo apt-get install nano 

打开镜像源文件

sudo nano /etc/apt/sources.list

将下边的清华源复制进去,然后ctrl+o保存,回车,ctrl+X退出编辑。

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse​deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse# deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse

1.3更新

sudo apt-get update sudo apt-get upgrade

配置D415驱动

2.1下载RealSense SDK

sudo apt-get install gitgit clone https://github.com/IntelRealSense/librealsense

2.2编译

cd librealsense/​mkdir build && cd build​sudo apt-get install libxrandr-devsudo apt-get install libxinerama-devsudo apt-get install libsdl2-devsudo apt-get install python3-devsudo apt install -y build-essentialsudo apt-get install libssl-dev​cmake ../ -DFORCE_RSUSB_BACKEND=true -DBUILD_PYTHON_BINDINGS=true -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=true​sudo apt-get install libusb-1.0-0-dev​sudo make uninstall && make clean && make && sudo make install#此处编译大约花费时间1.5h

2.3设置udev规则

cd librealsensesudo ./scripts/setup_udev_rules.sh

2.4测试

在命令行中输入如下指令能看到界面就证明成功了

realsense-viewer

安装pyrealsense2

pyrealsense2库不适用于arm架构树莓派,所以pip install pyrealsense2无法安装。目前还没有arm架构下的pyralsense2的PyPi包,因此在jetson使用pip安装的话,无法找到满足的版本。在python3下import pyrealsense2显示ImportError: No module named pyrealsense2

参考:【亲测有效】树莓派4B安装realsense(Intel深度摄像头)_树莓派realsense-CSDN博客

在Jetson Nano上编译 pyrealsense2库包,并在Intel的tof相机上进行测试_no internet connection, disabling import_depth_cam-CSDN博客

cd ~/librealsense/build​# for python3cmake .. -DBUILD_PYTHON_BINDINGS=bool:true -DPYTHON_EXECUTABLE=$(which python3)​make -j1sudo make install

添加python路径

nano ~/.zshrc 

复制下面语句到~/.zshrc中

export PYTHONPATH=$PYTHONPATH:/usr/local/lib

然后ctrl+o保存,回车,ctrl+X退出编辑,输入如下指令

source ~/.zshrc

到librealsense/build/release目录下看发现有了一些so、so.2.54 和 so.2.54.2 结尾的文件,我们将这些文件全部拷贝至 /usr/lib/python3/dist-packages/ 文件夹下,不是 /usr/lib/python3.7 文件夹下。

librealsense2-gl.sopyrsutils.cpython-310-aarch64-linux-gnu.solibrealsense2-gl.so.2.54pyrsutils.cpython-310-aarch64-linux-gnu.so.2.54librealsense2-gl.so.2.54.2 pyrsutils.cpython-310-aarch64-linux-gnu.so.2.54.2librealsense2.solibrealsense2.so.2.54librealsense2.so.2.54.2pybackend2.cpython-310-aarch64-linux-gnu.sopybackend2.cpython-310-aarch64-linux-gnu.so.2pybackend2.cpython-310-aarch64-linux-gnu.so.2.54.2pyrealsense2.cpython-310-aarch64-linux-gnu.sopyrealsense2.cpython-310-aarch64-linux-gnu.so.2.54pyrealsense2.cpython-310-aarch64-linux-gnu.so.2.54.2

python调用realsense深度相机测试代码

import pyrealsense2 as rsimport numpy as npimport cv2​if __name__ == "__main__": # Configure depth and color streams pipeline = rs.pipeline() config = rs.config() config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30) # Start streaming pipeline.start(config) try: while True: # Wait for a coherent pair of frames: depth and color frames = pipeline.wait_for_frames() depth_frame = frames.get_depth_frame() color_frame = frames.get_color_frame() if not depth_frame or not color_frame: continue # Convert images to numpy arrays​ depth_image = np.asanyarray(depth_frame.get_data())​ color_image = np.asanyarray(color_frame.get_data())​ # Apply colormap on depth image (image must be converted to 8-bit per pixel first) depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET) # Stack both images horizontally images = np.hstack((color_image, depth_colormap)) # Show images cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE) cv2.imshow('RealSense', images) key = cv2.waitKey(1) # Press esc or 'q' to close the image window if key & 0xFF == ord('q') or key == 27: cv2.destroyAllWindows() break finally: # Stop streaming pipeline.stop()

当能够出现画面即说明安装成功

报错1

Pyrealsense2-D435i:frames = pipeline.wait_for_frames() RuntimeError: Frame didn't arrival within 5000 #12462

pyrealsense2库不适用于arm架构树莓派,所以pip install pyrealsense2无法安装。

参考:Pyrealsense2-D435i:frames = pipeline.wait_for_frames() RuntimeError: Frame didn’t arrive within 5000 · Issue #12462 · IntelRealSense/librealsense (github.com)

报错2

Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the

解决方案

sudo apt-get install libssl-dev

报错3

GnuTLS recv error (-110): The TLS connection was non-properly terminated.

参考:解决 git clone 时遇到的一些问题_gnutls recv error (-110): the tls connection was n-CSDN博客

报错4

CMake Error at CMakeLists.txt:5 (project):No CMAKE_CXX_COMPILER could be found.​Tell CMake where to find the compiler by setting either the environmentvariable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full pathto the compiler, or to the compiler name if it is in the PATH.

解决方案

sudo apt install -y build-essential

参考:解决 No CMAKE_CXX_COMPILER could be found问题_cmake error at cmakelists.txt:2 (project): no cmak-CSDN博客

报错5

/home/ubuntu/librealsense/build/third-party/pybind11/include/pybind11/detail/common.h:266:10: fatal error: Python.h: No such file or directory266 | #include 

解决方案

sudo apt-get install python3-dev