ROS Raspberry Pi Demo
From wikidb
Contents
References
- Raspberry Pi 3 Ubuntu Mate Xenial 16.04 with ROS Kinetic image
- ROS motor controller node for Adafruit motor HAT IE 2348
- Adafruit motor HAT specs
- Adafruit motor HAT documentation
- Adafruit configuring I2C on Raspberry Pi
- ROS Tutorials
Motor Hat Node Installation
These steps have been completed for the catkin_ws dir. I'm starting from scratch for completeness and I don't want to mess up my working catkin_ws
Create the Workspace
cd mkdir -p catkin_demo/src cd catkin_demo/ ls catkin_make ls cd src
Download the motor hat SW
git clone https://github.com/matpalm/ros-motorhat-node
Rename the directory
It is less confusing if the motor hat directory matches the project name. The project name is in CMakeLists.txt.
ls more ros-motorhat-node/CMakeLists.txt mv ros-motorhat-node/ motor_hat
Build the motor hat node
cd .. catkin_make ls devel/lib/motor_hat/
Setup the .bashrc file
Add the following to your ~/.bashrc
source /home/ubuntu/catkin_demo/devel/setup.bash
Configure I2C
I2C is not enabled by default.
sudo i2cdetect -y 1 Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
Edit the boot config file
cd /boot diff config.txt config.txt.org 1073,1075c1073 < dtparam=i2c1=on < dtparam=i2c_arm=on < --- > #dtparam=i2c_arm=off
Remove I2C from the black list.
cd /etc/modprobe.d diff blacklist.conf blacklist.conf.org 29c29 < # blacklist i2c_i801 --- > blacklist i2c_i801
Add a couple of modules to the start up list
cd /etc diff modules modules.org 6,7d5 < i2c-bcm2708 < i2c-dev
xx
sudo apt-get install -y python-smbus sudo apt-get install -y i2c-tools didn't install anything
Test I2C. We found port 60 and 70.
sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: 70 -- -- -- -- -- -- --
Execution
Demo the ROS installation.
terminal 1
roscore
terminal 2
cd catkin_ws/ source devel/setup.bash rosrun motor_hat motor_hat_node
terminal 3
rosnode list rostopic list rostopic echo cmd
terminal 4
cd catkin_ws/ source devel/setup.bash rosrun motor_hat stop.py rosrun motor_hat on.py
TBD - QUESTION - Why isn't the message often not received by the motor_hat_node?
Code Inspection
The next line can be added to ~/.bashrc.
source ~/catkin_ws/devel/setup.bash roscd hat_node pwd cd src ls
Look at the code
emacs on.py& emacs motor_hat_node_cpp&
If emacs isn't installed use nano.
nano on.py