Rosanswers logo


I am having trouble using a custom ROS message type on my Arduino. I believe I have the latest version of ros-fuerte-rosserial

I have written & compiled a custom package called arduino_msgs, which worked since rosmsg show finds it. I have ran rosrun rosserial_client make_library.py to "bind" it to my arduino libraries, and I have received a good ouput.

My arduino node has two subscribers & one publisher. The publisher uses an arduino_msgs message type, and the subscribers are std_msgs. When I run rosrun rosserial_python serial_node.py /dev/ttyACM0, I get the following output (lunarex is the name of my computer..)

    lunarex@LunarEx:~/McGill_LunarEx_2013/Arduino$ rosrun rosserial_python serial_node.py /dev/ttyACM0[INFO] [WallTime: 1366251538.465538] ROS Serial Python Node
[INFO] [WallTime: 1366251538.474754] Connected on /dev/ttyACM0 at 57600 baud
[ERROR] [WallTime: 1366251540.605275] Cannot import package : arduino_msgs
[ERROR] [WallTime: 1366251540.607357] sys.path was ['/opt/ros/fuerte/stacks/rosserial/rosserial_msgs/src', '/opt/ros/fuerte/stacks/rosserial/rosserial_python/src', '/opt/ros/fuerte/stacks/rosserial/rosserial_python/nodes', '/opt/ros/fuerte/lib/python2.7/dist-packages', '/home/lunarex/McGill_LunarEx_2013/Arduino', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
[ERROR] [WallTime: 1366251540.609387] Failed to parse publisher: 'NoneType' object has no attribute 'msg'
[INFO] [WallTime: 1366251540.619060] Setup Subscriber on ang_speed [std_msgs/Float32]
[INFO] [WallTime: 1366251540.630073] Setup Subscriber on lin_speed [std_msgs/Float32]
[ERROR] [WallTime: 1366251540.633170] Tried to publish before configured, topic id 125
[ERROR] [WallTime: 1366251540.640945] Tried to publish before configured, topic id 125
[ERROR] [WallTime: 1366251540.656522] Tried to publish before configured, topic id 125
[ERROR] [WallTime: 1366251540.674111] Tried to publish before configured, topic id 125
[ERROR] [WallTime: 1366251540.685796] Tried to publish before configured, topic id 125
[ERROR] [WallTime: 1366251540.702021] Tried to publish before configured, topic id 125

..ad infinitum

so the bottom line is that my custom package (arduino_msgs) cannot be imported by rosserial, and therefore I cannot publish to a topic with that message type. Everything else works fine, so I can work around it using std_msgs, but if someone could point me to a solution that would be great.

Thanks! Ernest


I have acted upon fergs's three suggestions.

  1. rosmake arduino_msgs produces this correct output

    [ rosmake ] rosmake starting...
    [ rosmake ] Packages requested are: ['arduino_msgs']
    [ rosmake ] Logging to directory /home/lunarex/.ros/rosmake/rosmake_output20130427-200123
    [ rosmake ] Expanded args ['arduino_msgs'] to: ['arduino_msgs']
    [rosmake-0] Starting >>> std_msgs [ make ]
    [rosmake-0] Finished <<< std_msgs No Makefile in package std_msgs
    [rosmake-0] Starting >>> arduino_msgs [ make ]
    [rosmake-0] Finished <<< arduino_msgs [PASS] [ 5.27 seconds ]
    [ rosmake ] Results:
    [ rosmake ] Built 2 packages with 0 failures.
    [ rosmake ] Summary output to directory
    [ rosmake ] /home/lunarex/.ros/rosmake

  2. My CMakeFile.txt includes gen_msgs:

    cmake_minimum_required(VERSION 2.4.6) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

    Set the build type. Options are:

    Coverage : w/ debug symbols, w/o optimization, w/ code-coverage

    Debug : w/ debug symbols, w/o optimization

    Release : w/o debug symbols, w/ optimization

    RelWithDebInfo : w/ debug symbols, w/ optimization

    MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries

    #set(ROS_BUILD_TYPE RelWithDebInfo)


    #set the default path for built executables to the "bin" directory set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) #set the default path for built libraries to the "lib" directory set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

    #uncomment if you have defined messages rosbuild_genmsg() #uncomment if you have defined services #rosbuild_gensrv()

    #common commands for building c++ executables and libraries #rosbuild_add_library(${PROJECT_NAME} src/example.cpp) #target_link_libraries(${PROJECT_NAME} another_library) #rosbuild_add_boost_directories() #rosbuild_link_boost(${PROJECT_NAME} thread) #rosbuild_add_executable(example examples/example.cpp) #target_link_libraries(example ${PROJECT_NAME})

  3. My ROS_PACKAGE_PATH includes the directory where arduino_msgs is declared. That directory is /home/lunarex/McGill_LunarEx_2013/ROS_workspace, and my ROS_PACKAGE_PATH is:


I noticed that that directory is not in sys.path though, so I appended /home/lunarex/McGill_LunarEx_2013/ROS_workspace to it, but I still get the same error when I run serial_node.py..

Any further hints? Thank you very much.

Originally posted by Ernest on ROS Answers with karma: 341 on 2013-04-17

Post score: 0


1 Answer 1


Rosanswers logo

rosmsg show uses the raw .msg file -- not the compiled python version of the message which rosserial is trying to load. Either arduino_msgs is not on your ROS package path, or you likely have not setup your CMakeLists.txt file to generate messages -- or you have not compiled your custom arduino_msgs package.

Originally posted by fergs with karma: 13902 on 2013-04-18

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by Ernest on 2013-04-27:

Thank you for your response (& for rosserial!). I have performed your three suggestions to no avail. I have included more information as an edit to my question.


Your Answer

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