0
$\begingroup$

Rosanswers logo

I am trying to implement a CLI uploader for an Arduino MEGA2560 using rosserial_arduino and CMake, based upon http://wiki.ros.org/rosserial_arduino/Tutorials/CMake under LUbuntu 14.04 with ROS-Indigo on an ODROID (ARM) development board.

The tutorial works fine, as can be seen here:

$ catkin_make helloworld_firmware_hello-upload
Base path: /home/odroid/catkin_ws
Source space: /home/odroid/catkin_ws/src
Build space: /home/odroid/catkin_ws/build
Devel space: /home/odroid/catkin_ws/devel
Install space: /home/odroid/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/odroid/catkin_ws/build"
####
####
#### Running command: "make helloworld_firmware_hello-upload -j8 -l8" in "/home/odroid/catkin_ws/build"
####
[  0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestServiceInfo
[  0%] [  0%] Built target _rosserial_msgs_generate_messages_check_deps_Log
Built target _rosserial_msgs_generate_messages_check_deps_TopicInfo
[  0%] [  0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestMessageInfo
Built target _rosserial_msgs_generate_messages_check_deps_RequestParam
[ 87%] Built target rosserial_msgs_generate_messages_py
[ 87%] Built target rosserial_msgs_genpy
[100%] Built target helloworld_ros_lib
-- Generating hello
-- Configuring done
-- Generating done
-- Build files have been written to: /home/odroid/catkin_ws/build/helloworld/firmware
[100%] Built target helloworld_firmware
make[4]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
[ 90%] Built target mega2560_CORE
[100%] Built target hello

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9801
avrdude: reading input file "/home/odroid/catkin_ws/devel/share/helloworld/hello.hex"
avrdude: input file /home/odroid/catkin_ws/devel/share/helloworld/hello.hex auto detected as Intel Hex
avrdude: writing flash (9854 bytes):

Writing | ################################################## | 100% 1.60s

avrdude: 9854 bytes of flash written
avrdude: reading input file "/home/odroid/catkin_ws/devel/share/helloworld/hello.eep"
avrdude: writing eeprom (0 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 0 bytes of eeprom written

avrdude: safemode: Fuses OK (H:E6, E:D8, L:E6)

avrdude done.  Thank you.

[100%] Built target hello-upload
[100%] Built target helloworld_firmware_hello-upload

However, when I create a new catkin_package for my desired file (which is actually a symbolic link to a ../sketchbook/ Arduino project due to the need for both IDE and non-IDE uploading (some students are competent with CLI, others GUI)), I get the following output (I have removed the Policy CMP0022 warnings from this output):

$ catkin_make mechbot_v3_firmware_code-upload
Base path: /home/odroid/catkin_ws
Source space: /home/odroid/catkin_ws/src
Build space: /home/odroid/catkin_ws/build
Devel space: /home/odroid/catkin_ws/devel
Install space: /home/odroid/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/odroid/catkin_ws/build"
####
####
#### Running command: "make mechbot_v3_firmware_code-upload -j8 -l8" in "/home/odroid/catkin_ws/build"
####
[  0%] [  0%] Built target _rosserial_msgs_generate_messages_check_deps_TopicInfo
Built target _rosserial_msgs_generate_messages_check_deps_Log
[  0%] [  0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestServiceInfo
[  0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestParam
Built target _rosserial_msgs_generate_messages_check_deps_RequestMessageInfo
[ 87%] Built target rosserial_msgs_generate_messages_py
[ 87%] Built target rosserial_msgs_genpy
[100%] Built target mechbot_v3_ros_lib
-- Generating code
-- Configuring done
... lots of Policy CMP0022 warnings removed ...
-- Generating done
-- Build files have been written to: /home/odroid/catkin_ws/build/mechbot_v3/firmware
[100%] Built target mechbot_v3_firmware
Scanning dependencies of target mechbot_v3_firmware_code-upload
make[4]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
[ 71%] Built target mega2560_CORE
[ 78%] Built target mega2560_Wire
[ 82%] Built target mega2560_ITG3200
[ 85%] Built target mega2560_HMC58X3
[ 89%] Built target mega2560_Servo
[ 92%] Built target mega2560_ADXL345
[ 96%] Built target mega2560_LiquidCrystal
[ 96%] Built target mega2560_PinChangeInt
Linking CXX executable /home/odroid/catkin_ws/devel/share/mechbot_v3/code.elf
libmega2560_CORE.a(main.cpp.obj): In function `main':
/usr/share/arduino/hardware/arduino/cores/arduino/main.cpp:11: undefined reference to `setup'
/usr/share/arduino/hardware/arduino/cores/arduino/main.cpp:14: undefined reference to `loop'
collect2: error: ld returned 1 exit status
make[7]: *** [/home/odroid/catkin_ws/devel/share/mechbot_v3/code.elf] Error 1
make[6]: *** [CMakeFiles/code.dir/all] Error 2
make[5]: *** [CMakeFiles/code-upload.dir/rule] Error 2
make[4]: *** [code-upload] Error 2
make[3]: *** [mechbot_v3/CMakeFiles/mechbot_v3_firmware_code-upload] Error 2
make[2]: *** [mechbot_v3/CMakeFiles/mechbot_v3_firmware_code-upload.dir/all] Error 2
make[1]: *** [mechbot_v3/CMakeFiles/mechbot_v3_firmware_code-upload.dir/rule] Error 2
make: *** [mechbot_v3_firmware_code-upload] Error 2
Invoking "make" failed

The file in question compiles and uploads fine through the Arduino IDE, and the two functions are definitely in the .ino file (which is substantially too big to post here):

void setup() {}
void loop() {}

For reference, the CMakeLists.txt file within the project is:

cmake_minimum_required(VERSION 2.8.3)
project(mechbot_v3)

find_package(catkin REQUIRED COMPONENTS rosserial_arduino rosserial_client)

catkin_package()

rosserial_generate_ros_lib(PACKAGE rosserial_arduino SCRIPT make_libraries.py)

rosserial_configure_client(DIRECTORY firmware TOOLCHAIN_FILE ${ROSSERIAL_ARDUINO_TOOLCHAIN})

rosserial_add_client_target(firmware code ALL)
rosserial_add_client_target(firmware code-upload)

The CMakeLists.txt file within the ./firmware/ sub-directory is:

cmake_minimum_required(VERSION 2.8.3)

include_directories(${ROS_LIB_DIR})

generate_arduino_firmware(code SRCS mechbot_v3.ino ${ROS_LIB_DIR}/time.cpp BOARD mega2560 PORT /dev/ttyACM0)
#generate_arduino_firmware(code SRCS mechbot_v3.ino BOARD mega2560 PORT /dev/ttyACM0)

And the library definitions within the .ino file are:

#include <ros.h>
#include "std_msgs/Int32MultiArray.h"
#include "std_msgs/Float32MultiArray.h"
#include "std_msgs/UInt8MultiArray.h"
#include "std_msgs/UInt8.h"
#include "std_msgs/Float32.h"
#include "std_msgs/Int32.h"
#include "std_msgs/String.h"

#include <Arduino.h>
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#include <stdlib.h>
#include <PinChangeInt.h>
#include <ADXL345.h>
#include <HMC58X3.h>
#include <ITG3200.h>

Does anyone have any suggestions as to what the problem may be? First time delving into the non-IDE environment.

EDIT 1: Corrected error in project CMakeLists.txt.


Originally posted by anonymousSnowMan on ROS Answers with karma: 38 on 2014-12-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As suggested on the issue tracker, please try using the generate_arduino_firmware(SKETCH xyz) syntax of arduino-cmake.


Originally posted by mikepurvis with karma: 1153 on 2014-12-18

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by anonymousSnowMan on 2014-12-18:
This corrected the issue. Entry required was:

generate_arduino_firmware(program SKETCH file.ino SRCS ${ROS_LIB_DIR}/time.cpp BOARD mega2560 PORT /dev/ttyACM0)

Why is there a SRCS and a SKETCH entry if they behave the same, as I have shown by simply renaming one to the other?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.