Instead of locating all the files for the Arduino/Teensy within the pheeno_ros
package, I have created a separate repository containing all the Arduino code. This repository is strongly suggested to be used with PlatformIO; however, it can be used with original Arduino client.
To install, just clone this directory into your home (~/
) directory. This code works on both ROS Indigo and ROS Kinetic.
$ git clone https://github.com/acslaboratory/pheeno_arduino.git
For ROS to work with arduino (and other) microcontrollers, libraries were created to interface a computer with a microcontroller thorugh serial connection. These libraries must be installed to use the pheeno_arduino
files. To install these libraries, ROS Indigo or Kinetic must be installed and their respective ROS repositories accessable. Then install the relavent packages depending on your ROS version:
ROS Indigo
$ sudo apt-get install \
ros-indigo-rosserial ros-indigo-rosserial-client \
ros-indigo-rosserial-python ros-indigo-rosserial-arduino
ROS Kinetic
$ sudo apt-get install \
ros-kinetic-rosserial ros-kinetic-rosserial-client \
ros-kinetic-rosserial-python ros-kinetic-rosserial-arduino
Once installed, source the ROS setup.bash
file to access the newly installed packages.
$ source /opt/ros/indigo/setup.bash # For ROS Indigo
$ source /opt/ros/kinetic/setup.bash # For ROS Kinetic
Finally, cd
into the lib/
folder of this respository, and run the following command to generate the ros_lib
files required for using ROS with a microcontroller.
$ cd lib/
$ rosrun rosserial_arduino make_libraries.py .
Once the ros_lib
files are generated, use the file_setup.py
file that copies the lib/
folder into all PlatformIO project directory in the folder OR to a specific PlatformIO project directory. For example, in the first case the code would be:
$ python file_setup.py --all
or
$ python file_setup.py -a
To copy the files to a specific folder (the ros
directory would be used as an example), you would do this:
$ python file_setup.py --file ros
or
$ python file_setup.py -f ros
Begin by changing directory (cd
) into the code you want to upload into the microcontroller and initialize PlatformIO. The example will use the ros
project folder.
$ cd ros/
$ platformio init --board teensy31
NOTE: The --board
option can be changed to the one that you are using. It should be noted, however, that the Pheeno uses a Teensy 3.2 whose PlatformIO option is specified by --board teensy31
.
Finally, run (compile) and upload the code:
$ platformio run --target upload