樹莓派3B+安裝raspbian ros opencv筆記
安裝opencv
啟動BOOT相關知識
安裝ros kinetic
ros wiki上只有raspbian jessie的,stretch按jessie的步驟安裝
新增 ros repositories報錯 no dirmngr,安裝dirmngr
sudo apt install software-properties-common dirmngr然後繼續
wstool init src kinetic-robot-wet.rosinstall報錯
執行wstool update -j4 -t src再init
rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:jessie
jessie改為對應版本stretch
在編譯時卡死,應該是預設swap空間設定過低,拓展swap空間:
第一步:選擇在/opt/image中新增2G的swap交換檔案
cd /opt
sudo mkdir image
sudo touch swap
第二步:新增交換檔案並設定其大小為2G,使用如下命令
sudo dd if=/dev/zero of=/opt/image/swap bs=1024 count=1024000
等待...
第三步:建立(設定)交換空間,使用命令mkswap
sudo mkswap /opt/image/swap
Setting up swapspace version 1, size = 2 GiB (2097147904 bytes)
第四步:檢查現有的交換空間大小,使用命令free
free -m
或者檢查meminfo檔案
grep SwapTotal /proc/meminfo
第五步:啟動新增加的2G的交換空間,使用命令swapon
sudo swapon /opt/image/swap
第六步:確認新增加的2G交換空間已經生效,使用命令free -m
或者檢查meminfo檔案
grep SwapTotal /proc/meminfo
第七步:修改/etc/fstab檔案,使得新加的2G交換空間在系統重新啟動後自動生效
sudo vim /etc/fstab
在檔案最後加入:
/opt/image/swap /swap swap defaults 0 0
編譯過程中,仍然可能遇到大檔案時卡死或cmake報segment fault等情況,重啟重新編譯可以通過
安裝VNC
x11vnc,可訪問真實桌面x11,但是仍然不能顯示raspistill的影象?
使用樹莓派攝像頭
樹莓派csi攝像頭硬體安裝:
進入樹莓派設定sudo raspi-config開啟camera,enable後需要重啟reboot
此時還沒有/dev/video0.
raspicam有三個工具raspivid raspistill raspistillyuv,vid捕捉視訊,yuv是still的raw版
raspistill是樹莓派提供的捕獲影象工具.raspistill --help
raspistill 常用引數:
-v:除錯資訊檢視。
-w:影象寬度
-h:影象高度
-rot:影象旋轉角度,只支援 0、90、180、270 度
-o:影象輸出地址,例如image.jpg,如果檔名為“-”,將輸出傳送至標準輸出裝置
-t:獲取影象前等待時間,預設為5000,即5秒
-tl:多久執行一次影象抓取。
各種引數使用:
找不到/dev/video0裝置
樹莓派中的camera module是放在/boot/目錄下以韌體的形式載入的,不是一個標準的v4l2的攝像頭ko驅動,所以載入起來之後會找不到/dev/video0的裝置節點,這是因為這個驅動是在底層的,v4l2這個驅動框架還沒有載入,
所以要在配置檔案,也就是 /etc/下面的modules-load.d / rpi-camera.conf (如果沒有則新建檔案,這個檔名可能不是叫modules-load.d/rpi-camera.conf,也有可能直接就是/etc/modules,)
開啟檔案在裡面新增一行
bcm2835-v4l2
這句話意思是在系統啟動之後會載入這個檔案中模組名,這個模組會在樹莓派系統的/lib/modules/xxx/xxx/xxx下面,
新增之後重啟系統,就會在/dev/下面發現video0裝置節點了。
修改時間
設定時區
sudo raspi-config
然後localisation ... time zone...找到not above ...設定GMT +8 時區.這裡有BUG,設定GMT-8時區實際才是+8時區
時間不準.安裝ntp.同步時間
sudo apt-get install ntp
sudo ntpd -s -d
date檢視時間和時區設定是否正確
sudo
date
--s=
"2014-08-31 14:42:00"強制設定
時間
sudo vim /etc/ntp.conf 在#server ntp.your.provider.example下新增時間同步伺服器:
server ntp.fudan.edu.cn iburst perfer
server time.asia.apple.com iburst
server asia.pool.ntp.org iburst
server ntp.nict.jp iburst
server time.nist.gov iburst
修改國內更新源
源的檔案
軟體更新源 /etc/apt/sources.list
系統更新源 /etc/apt/sources.list.d/raspi.list
原來的源裡已經有aliyun 清華等 ...
sources.list 新增 deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free$
raspi.list 新增 deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
然後在 apt update. apt upgrade更新軟體
無法輸入#等
因為預設為英式鍵盤,應改為美式鍵盤,安裝小企鵝輸入法
sudo apt-get install fcitx
reboot
找到preferences-fcitx configuration,修改uk鍵盤為us鍵盤
修改使用者名稱密碼
sudo passwd
輸入root密碼
sudo passwd pi
安裝raspbian
ubuntu mate有硬體或者軟體驅動不行的問題,下載raspbian.img,win32 disk imager直接刻錄在sd卡上即可進入系統
安裝ubuntu mate 16.04
1.格式化SD卡
2.下載ubuntu mate 16.04
3.使用win32 disk imager燒錄系統
將下載的系統檔案解壓得到.img檔案,需將該檔案放在英文目錄下,點Write按鈕進行燒錄
4.sd卡插入樹莓派啟動,彩虹屏無法進入系統.原因是官方ubuntu mate的映象是使用樹莓派2的uboot,不能在樹莓派3B+上執行.
5.解決方法:sd卡插入讀卡器,進入pi_boot盤,此處存放ubuntu引導檔案,另外不能讀的盤是ubuntu系統檔案
1、下載最新的樹莓派官方Boot
2、更改pi_boot中的config檔案
kernel = vmlinuz
initramfs initrd.img followkernel
#device_tree_address = 0x0200000
3、替換pi_boot中的Boot檔案 bootcode.bin fixup.dat start.elf
boot問題:
6.正常安裝,安裝完畢後配置網路