# RPI ROS PCA9685 如果像我一樣看到英文就被降智 推薦這個ROS中文教學 https://www.youtube.com/playlist?list=PL4XGr_39oSTlRckDYw7FbGRyIOfH63Gc5 https://xenby.com/b/221-%E6%95%99%E5%AD%B8-%E4%BD%BF%E7%94%A8-visual-studio-code-%E9%80%8F%E9%81%8E-ssh-%E9%80%B2%E8%A1%8C%E9%81%A0%E7%AB%AF%E7%A8%8B%E5%BC%8F%E9%96%8B%E7%99%BC ## ubuntu安裝(20.04) 照著官方教學弄映像檔跟設置wifi https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#1-overview ## 安裝ROS-Noetic 照官方教學安裝,選base版就好 反正PRI沒螢幕 http://wiki.ros.org/noetic/Installation/Ubuntu ## 安裝一些東西 安裝wriingpi(RPI4) http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/ ``` cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v ``` 安裝i2c-tool ``` sudo apt-get install i2c-tools ``` ## 創建workspace 在根目錄下 ``` //創建一個資料夾 mkdir catkin_ws //在裡面創一個src資料夾 cd catkin_ws mkdir src //編譯工作空間 catkin_make //進入src然後clone pca9685 cd src git clone https://github.com/dheera/ros-pwm-pca9685.git //回到catkin_ws編譯 cd .. catkin_make //設置環境變量 source devel/setup.bash ``` 上面那個似乎不是給RPI的? https://github.com/liamondrop/ros-pca9685-board 這個版本比較好用 ``` //創建一個資料夾 mkdir catkin_ws //在裡面創一個src資料夾 cd catkin_ws mkdir src //編譯工作空間 catkin_make //進入src然後clone pca9685 cd src git clone https://github.com/liamondrop/ros-pca9685-board.git //回到catkin_ws編譯 cd .. catkin_make //設置環境變量 source devel/setup.bash ``` IIC報錯是因為沒開權限 ![](https://i.imgur.com/VSY5RWH.png) ``` sudo chgrp i2c /dev/i2c-1 sudo chmod 666 /dev/i2c-1 ``` ## 自己包進ROS裡面 使用這個庫 https://github.com/Reinbert/pca9685 ROS的IntArray要先指定大小才能給值 pin的編號為300~315 一個pub node一個位址