Difference between revisions of "ROS Raspberry Pi Demo"

From wikidb
Jump to: navigation, search
(Configure I2C)
(Configure I2C)
Line 80: Line 80:
 
     < i2c-bcm2708  
 
     < i2c-bcm2708  
 
     < i2c-dev
 
     < i2c-dev
xx
+
 
 +
Install the smbus and I2C tools.
  
 
   sudo apt-get install -y python-smbus
 
   sudo apt-get install -y python-smbus

Revision as of 20:05, 24 February 2017

References

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

Install the smbus and I2C tools.

 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

References