Turtlebot3-waffle-pi入门教程#noetic版#-树莓派摄像头安装
Turtlebot3-waffle-pi入门教程#noetic版#-树莓派摄像头安装
说明:
本教程主要介绍如何树莓派4上安装树莓派摄像头的驱动
测试环境: 树莓派4B 2G + Ubuntu MATE 20.04 + ROS Noetic Ninjemys + 树莓派V2摄像头
相关设备
- TB3套件:采购地址
前提说明
默认情况下,树莓派4上安装的Ubuntu mate 20.04是没有带有rpi-clone、rpi-imager 和 raspi-config等工具,需要额外安装
对于在创客智造上购买的Noetic版系统的tb3是已经配置好系统,不需要根据此教程重复安装,只需要按照文章最后的测试部分来测试摄像头即可
安装raspi-config配置工具
- 接上摄像头
注意排线的接线方向
- [TurtleBot] 下载raspi-config的deb包,官方链接
$ wget http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_20201108_all.deb
- [TurtleBot] 安装相关依赖包
$ sudo apt install lua5.1 libatopology2 libfftw3-single3 libsamplerate0 alsa-utils
- [TurtleBot] 安装deb包
$ sudo dpkg -i raspi-config_20201108_all.deb
- [TurtleBot] 挂载
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 781M 0 781M 0% /dev
tmpfs 185M 4.4M 181M 3% /run
/dev/mmcblk0p2 15G 12G 2.6G 82% /
tmpfs 925M 0 925M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 925M 0 925M 0% /sys/fs/cgroup
/dev/mmcblk0p1 255M 118M 138M 46% /boot/firmware
tmpfs 185M 16K 185M 1% /run/user/1000
$ mount /dev/mmcblk0p1 /boot
- [TurtleBot] 添加用户到群组
$ sudo usermod -aG video ubuntu
- [TurtleBot] 打开raspi-config配置
$ sudo raspi-config
- 选择
3 Interfacing Options
- 选择
P1 Camera
Enable camera interface
- [TurtleBot] 安装V4l2工具包
$ sudo apt-get install v4l-utils
$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12
/dev/media1
bcm2835-isp (platform:bcm2835-isp):
/dev/video13
/dev/video14
/dev/video15
/dev/video16
/dev/media0
mmal service 16.1 (platform:bcm2835-v4l2):
/dev/video0
重启树莓派
[TurtleBot] 检测是否接上摄像头
$ vcgencmd get_camera
supported=1 detected=1
- [TurtleBot] 设置完之后测试以下是否能正常使用,输入以下以下命令,正常情况下树莓派系统的桌面上会生成一张摄像头捕捉到的图像
$ raspistill -v -o $HOME/Desktop/test.jpg
安装raspicam_node包
- [TurtleBot] 添加库
$ sudo vim /etc/ros/rosdep/sources.list.d/30-ubiquity.list
## 使用vim新建list文件,现在以下内容后保存退出
yaml https://raw.githubusercontent.com/UbiquityRobotics/rosdep/master/raspberry-pi.yaml
- [TurtleBot] 更新相关依赖
$ rosdep update
- [TurtleBot] 创建工作空间,拉取raspicam_node源码
$ mkdir -p ~/raspicam_ws/src
$ cd ~/raspicam_ws/src/
$ git clone https://github.com/UbiquityRobotics/raspicam_node.git
- [TurtleBot] 配置和构建依赖项
$ cd ~/raspicam_ws
$ wstool init src
$ rosinstall_generator compressed_image_transport --rosdistro noetic --deps --wet-only --tar > compressed_image_transport-wet.rosinstall
$ rosinstall_generator camera_info_manager --rosdistro noetic --deps --wet-only --tar > camera_info_manager-wet.rosinstall
$ rosinstall_generator dynamic_reconfigure --rosdistro noetic --deps --wet-only --tar > dynamic_reconfigure-wet.rosinstall
$ rosinstall_generator diagnostics --rosdistro noetic --deps --wet-only --tar > diagnostics-wet.rosinstall
$ wstool merge -t src compressed_image_transport-wet.rosinstall
$ wstool merge -t src camera_info_manager-wet.rosinstall
$ wstool merge -t src dynamic_reconfigure-wet.rosinstall
$ wstool merge -t src diagnostics-wet.rosinstall
- [TurtleBot] 更新依赖
$ rosdep install --from-paths src --ignore-src --rosdistro=noetic -y
- [TurtleBot] 编译
$ cd ~/raspicam_ws && catkin_make
- [TurtleBot] 添加环境设置
$ echo "source ~/raspicam_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
测试
- [TurtleBot] 启动摄像头
$ roslaunch raspicam_node camerav2_1280x960.launch
... logging to /home/ubuntu/.ros/log/b003402e-3b91-11ec-8eca-592b4088b58b/roslaunch-TB3BG-R12V300-3658.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://localhost:33303/
SUMMARY
========
PARAMETERS
* /raspicam_node/camera_frame_id: raspicam
* /raspicam_node/camera_id: 0
* /raspicam_node/camera_info_url: package://raspica...
* /raspicam_node/camera_name: camerav2_1280x960
* /raspicam_node/enable_imv: False
* /raspicam_node/enable_raw: False
* /raspicam_node/framerate: 30
* /raspicam_node/height: 960
* /raspicam_node/private_topics: True
* /raspicam_node/width: 1280
* /rosdistro: noetic
* /rosversion: 1.15.13
NODES
/
raspicam_node (raspicam_node/raspicam_node)
auto-starting new master
process[master]: started with pid [3668]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to b003402e-3b91-11ec-8eca-592b4088b58b
process[rosout-1]: started with pid [3678]
started core service [/rosout]
process[raspicam_node-2]: started with pid [3681]
[ INFO] [1635825760.335948612]: splitter component done
[ INFO] [1635825760.505614804]: camera calibration URL: package://raspicam_node/camera_info/camerav2_1280x960.yaml
[ INFO] [1635825761.409805572]: Camera successfully calibrated from default file
[ INFO] [1635825761.410114440]: using default calibration URL
[ INFO] [1635825761.410347919]: camera calibration URL: file:///home/ubuntu/.ros/camera_info/camerav2_1280x960.yaml
[ INFO] [1635825761.410724082]: Unable to open camera calibration file [/home/ubuntu/.ros/camera_info/camerav2_1280x960.yaml]
[ WARN] [1635825761.410919728]: Camera calibration file /home/ubuntu/.ros/camera_info/camerav2_1280x960.yaml not found.
[ INFO] [1635825761.411116226]: No device specifc calibration found
[ INFO] [1635825761.544231332]: Starting video capture (1280, 960, 80, 30)
[ INFO] [1635825761.545560949]: Video capture started
- [TurtleBot] 打开rqt工具,选择对应话题
$ rqt_image_view
参考资料
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号