ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Undefined reference to 'setup' and 'loop' using CMake for custom project

asked 2014-12-17 20:09:19 -0500

anonymousSnowMan gravatar image

updated 2022-01-22 16:16:29 -0500

Evgeny gravatar image

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... 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 ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-12-18 08:02:56 -0500

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

edit flag offensive delete link more

Comments

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?

anonymousSnowMan gravatar image anonymousSnowMan  ( 2014-12-18 16:57:47 -0500 )edit
0

answered 2014-12-17 20:24:11 -0500

anonymousSnowMan gravatar image

updated 2014-12-18 02:43:31 -0500

So it appears that rosserial_arduino/CMake can't work with .ino files, unless there is something specifically wrong with my .ino file. Copying and renaming the .ino file to a .cpp file fixed all of the issues, and the code uploaded correctly. Bug?

EDIT 1: A symbolic link (ln -s) from the ../sketchbook/<project>/<project>.ino file to the ../firmware/<project>.cpp file also fixes the issue, meaning I can still have the students update the code in one location for both the CLI and GUI.

EDIT 2: Obviously an update was required to the ./firmware/CMakeLists.txt to target the new .cpp file, after the .cpp symbolic link was created.

edit flag offensive delete link more

Comments

Is this really solved then, or just worked around? Perhaps report this as an issue on the rosserialissue tracker?

gvdhoorn gravatar image gvdhoorn  ( 2014-12-18 01:38:03 -0500 )edit

You are correct, gvdhoorn; this is a workaround and not a fix. I will submit the bug report to the issue tracker as per your suggestion.

anonymousSnowMan gravatar image anonymousSnowMan  ( 2014-12-18 02:42:32 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-12-17 20:09:19 -0500

Seen: 750 times

Last updated: Dec 18 '14