Coder Social home page Coder Social logo

ros-teensy's Introduction

ros_teensy

master

This ROS package ports the rosserial-arduino communication package for the Teensy MCUs. It uses the same ros-lib generated by the rosserial-arduino package for the higher level and compiles the Teensy core Arduino library implementation to provide the interface to serial.write() and serial.print().

Requirements

There are several requirements for this package, first is the arm compiler toolchain from the GNU tools:

sudo apt-get install gcc-arm-none-eabi

Then you will obviously need the Arduino and Teensyduino libraries. You can find the Arduino library on arduino.cc/en/Main/Software where you will find your latest version. Unfortunately Arduino does not provide a static URL with the latest version of the library, so this URL might change with time. At the time this was written, the latest version was 1.6.7 so:

curl -O https://downloads.arduino.cc/arduino-1.6.7-linux64.tar.xz
tar -xvf arduino-1.6.7-linux64.tar.xz

For Teensyduino, the URL is also not static and will change. At this time you can get it with

curl -O https://www.pjrc.com/teensy/td_127/teensyduino.64bit
chmod +x teensyduino.64bit
./teensyduino.64bit

Finally, you will need to set an environment variable to point to the where you installed the libraries. So add a line like the following to your .bashrc file or any other file you source in every terminal

export arduino_location=<the_location>

Usage

To properly use the ros_teensy package, your package containing your MCU code to be compiled should follow this structure:

package
โ”œโ”€โ”€ CMakeLists.txt
โ”œโ”€โ”€ package.xml
โ”œโ”€โ”€ arch1
โ”‚ย ย  โ”œโ”€โ”€ CMakeLists.txt
โ”‚ย ย  โ””โ”€โ”€ main.cpp
โ””โ”€โ”€ arch2
    โ”œโ”€โ”€ CMakeLists.txt
    โ””โ”€โ”€ main.cpp

Note that the toolchain file used to compile the sources will be determined at a folder level, hence the reason for the arch1 and arch2 folders. These two folders could (or not) be compiled using the same cross-compiling toolchain.

To compile using the ros_teensy toolchain you must include the following commands in your different CMakeLists.txt.

At the package level:

cmake_minimum_required(VERSION 2.8)
project(<package_name>)

find_package(catkin REQUIRED COMPONENTS
    ros_teensy
    rosserial_client
    rosserial_arduino
)

rosserial_generate_ros_lib(
    PACKAGE rosserial_arduino
    SCRIPT make_libraries.py
)

rosserial_configure_client(
    DIRECTORY architecture1
    TOOLCHAIN_FILE ${ROS_TEENSY_TOOLCHAIN}
)

rosserial_configure_client(
    DIRECTORY architecture2
    TOOLCHAIN_FILE ${ROS_TEENSY_TOOLCHAIN}
)

rosserial_add_client_target(architecture1 target1_Firmware ALL)
rosserial_add_client_target(architecture2 target2_Firmware ALL)

Then inside each architecture folder, the CMakeLists.txt should contain the following:

include_directories(${ROS_LIB_DIR})

FILE(GLOB_RECURSE ros_src
    "${ROS_LIB_DIR}/*.cpp"
    "${ROS_LIB_DIR}/*.h")
add_library(ros_lib ${ros_src})

add_teensy_executable(target1 main.cpp)
target_link_libraries(target1 ros_lib)

You will need to explicitly build and link to the ros_lib target for each different architecture. Additionally, each target needs to be linked to those libraries as well.

Note that it is the same principle for any other external libraries.

Additionnally, if your MCU code uses some of the Arduino/Teensy external libraries such as Servo, SPI, PID, etc. You will need to add them to the compilation process by adding this line before you create the executable.

include_directories(${ROS_LIB_DIR})

import_arduino_library(Servo)
...
add_teensy_executable(...)

We use the import_arduino_library() command regardless of if the library is an Arduino or a Teensyduino library.

After the build completes, three files should be created for each Teensy target you added: target.elf, target.elf.eep and target.elf.hex. They should be located in the build folder of the catkin workspace: catkin_ws/src/<package_name>/architecture/bin. Out of those files, the *.hex file is the one that will get flashed to the micro-controller using your favorite utility.

ros-teensy's People

Contributors

anassinator avatar sevenbitbyte avatar abraha2d avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.