Rosserial arduino CMake unable to link libraries
I've had an extremely difficult time compiling my Arduino code using CMake after changing sensor libraries. The problem seems to be the linking of libraries that reference each other. Specifically I am using the Adafruit library for the INA260 current sensor. This library has a dependency on the Adafruit BusIO library but if I simply included both in the folder, nothing would link. I modified the import statements to change from <> to "" but that didn't help either. I read the Arduino-CMake wiki and added dedicated library entries to the CMakeList file but that also didn't work. I've attached the the CMakeLists file for my project below. The firmware "robot" is my main file and the others are libraries I tried to make it work. The most frustrating part is that my previous sensor worked (INA219) and now when I fix one thing, another item breaks in the same way.
link_directories(/usr/share/arduino/libraries) <-- I added this for debugging
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries)
include_directories(${ROS_LIB_DIR})
generate_arduino_library(Adafruit_BusIO
BOARD mega2560
SRCS libraries/Adafruit_BusIO/Adafruit_I2CDevice.cpp libraries/Adafruit_BusIO/Adafruit_SPIDevice.cpp libraries/Adafruit_BusIO/Adafruit_BusIO_Register.cpp
LIBS Wire
)
generate_arduino_library(current_sensor
BOARD mega2560
SRCS libraries/Adafruit_INA260/Adafruit_INA260.cpp
LIBS Adafruit_BusIO
)
generate_arduino_firmware(robot
SRCS robot.cpp ${ROS_LIB_DIR}/time.cpp
BOARD mega2560
PORT /dev/ttyACM0
LIBS current_sensor
)
Here is an example of an import statement I've tried in the library but that didn't work either.
#include "Arduino.h"
#include "../Adafruit_BusIO/Adafruit_I2CDevice.h"
#include "../Adafruit_BusIO/Adafruit_I2CRegister.h"
#include <Wire.h>
Any C++ help to get it sorted would be great!
Asked by Wes G on 2021-05-15 20:59:49 UTC
Comments