Robotics StackExchange | Archived questions

Using Arduino libraries with rosserial_arduino

I'm trying to create a ROS package for a node that will run on an Arduino, and interface some sensors with corresponding Arduino libraries. One of the sensors is a BNO055, and I'm trying to use the AdafruitBNO055 (and AdafruitSensor) library.

What I'm doing now, which seems to work (as in it builds), is to paste the contents of each library right into the firmware folder, so that the package contents look like this:

├── CMakeLists.txt
├── firmware
│   ├── Adafruit_BNO055.cpp
│   ├── Adafruit_BNO055.h
│   ├── Adafruit_Sensor.h
│   ├── CMakeLists.txt
│   ├── sensor_node.cpp
│   └── utility
│       ├── imumaths.h
│       ├── matrix.h
│       ├── quaternion.h
│       └── vector.h
└── package.xml

The utility folder is part of one of the libraries. This is clearly very messy, as libraries are not separated in any way from the code under development, and they cannot even be organized in subfolders without requiring #include "subfolder/LibraryFile.h in sensor_node.cpp.

How can I put the libraries somewhere else, yet still have them recognized by sensor_node.cpp?

I've tried to do this:

├── CMakeLists.txt
├── firmware
│   ├── CMakeLists.txt
│   └── sensor_node.cpp
├── libraries
│   ├── Adafruit_BNO055
│   │   ├── Adafruit_BNO055.h
│   │   ├── Adafruit_BNO055.cpp
│   │   └── utility
│   │       ├── imumaths.h
│   │       ├── matrix.h
│   │       ├── quaternion.h
│   │       └── vector.h
│   └── Adafruit_Sensor
│       └── Adafruit_Sensor.h
└── package.xml

Which is a much nicer structure, but I cannot figure out the necessary CMakeLists settings to make it work.

Any takers?

Asked by Fyhn on 2017-02-11 13:06:01 UTC

Comments

Did u ever find the solution for this?

Asked by RandyD on 2017-06-16 12:49:54 UTC

Unfortunately no, and we ended up avoiding using Arduino altogether.

Asked by Fyhn on 2017-06-22 11:52:18 UTC

Answers