Search code examples
rosrecipebitbakegumstixyocto

Getting my own ROS package on Gumstix overo (Bitbake yocto project)


I'm trying to get my own ROS package to work on a Gumstix Overo. The final goal of the project would be to get an image from the Caspa (camera) and stream it with ROS. To do so, I had the most success with the Yocto project: Pocky, which uses the BitBake cross-compile tool chain. To do so, I followed the instructions from the README.md in this GitHub repo: https://github.com/gumstix/Gumstix-YoctoProject-Repo

FYI, the instructions for the actual flashing and installing are clearer on the official Gumstix web site.

I was successful at compiling the BitBake project with all the ROS metadata and extras with the following command:

$ bitbake gumstix-console-image 

(takes quite a while and lots and lots of disk space) and later on, flashing and installing.

And here is my package I tried to compile: https://github.com/elikos/groundStationPublic I tried to keep the folder as plain as possible to limit the potential path issues, so everything is at the base dir... (very ugly, I know)

Here is my CMakelist.txt:

cmake_minimum_required(VERSION 2.8.3)
project(groundStationPublic)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport roscpp rospy std_msgs genmsg)

find_package(OpenCV REQUIRED)

## Declare ROS messages and services
#add_message_files(FILES Num.msg)
#add_service_files(FILES AddTwoInts.srv)

## Generate added messages and services
#generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})

add_executable(talker talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
#add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
#add_dependencies(listener beginner_tutorials_generate_messages_cpp)

add_executable(cornerDetection main.cpp ConerDetection.cpp LineDetection.cpp ImagePublisher.cpp)
target_link_libraries(cornerDetection ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

add_executable(bonPublisher bonPublisher.cpp)
target_link_libraries(bonPublisher ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

And here is my BitBake recipe for the package:

DESCRIPTION = "Elikos groundstation code."
SECTION = "devel"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=d566ef916e9dedc494f5f793a6690ba5"

DEPENDS = "roscpp rospy catkin std-msgs"
RDEPENDS_${PN} = "roscpp rospy std-msgs"

SRC_URI = "git://github.com/elikos/groundStationPublic.git"

SRCREV = "${AUTOREV}"
PV = "1.0.0+gitr${SRCPV}"

S = "${WORKDIR}/git"

inherit catkin

ROS_SPN = "groundStationPublic"

I have located it in ~/yocto/poky/meta-ros/recipes-ros/groundStationPublic

If I execute the command bitbake groundStationPublic, everything compiles fine. No errors. (you may get an error from x264_git, but the correct sourcerev is: SRCREV = "ffc3ad4945da69f3caa2b40e4eed715a9a8d9526")

Finally, my questions are:

  • Where is my package located at in the image?
    • It's not in the /usr/share/ like I would expect it to be...
  • How do I run my package if rosrun can't find it? (probably because its simply not there)
    • I would expect it to be somthing like rosrun groundStationPublic talker

Solution

  • Well, finally found the answer to my own question:

    I had to add my package in the image like so in ~/yocto/poky/meta-gumstix-extras/recipies-images/gumstix/gumstix-consol-image.bb:

    UTILITIES_INSTALL = " \
      [...]
      packagegroup-ros-comm \
      python-wstool \
      python-email \
      python-distutils \
      git \
      git-perltools \
      python-rosinstall \
      rospy-tutorials \
      roscpp-tutorials \
      groundStationPublic \
      [...]
    "
    

    and make sure to have the UTILITIES_INSTALL added to:

    IMAGE_INSTALL += " \
      [...]
      ${UTILITIES_INSTALL} \
      [...]
    "
    

    I also had to change the CMakelist.txt to explicitly tell it where to install the targets, so here is the new CMakelist.txt (note the diff in the last few lines):

    cmake_minimum_required(VERSION 2.8.3)
    project(groundStationPublic)
    
    ## Find catkin and any catkin packages
    find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport roscpp rospy std_msgs genmsg)
    
    find_package(OpenCV REQUIRED)
    
    ## Declare ROS messages and services
    #add_message_files(FILES Num.msg)
    #add_service_files(FILES AddTwoInts.srv)
    
    ## Generate added messages and services
    #generate_messages(DEPENDENCIES std_msgs)
    
    ## Declare a catkin package
    catkin_package()
    
    include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
    
    add_executable(talker src/talker.cpp)
    target_link_libraries(talker ${catkin_LIBRARIES})
    #add_dependencies(talker beginner_tutorials_generate_messages_cpp)
    
    add_executable(listener src/listener.cpp)
    target_link_libraries(listener ${catkin_LIBRARIES})
    #add_dependencies(listener beginner_tutorials_generate_messages_cpp)
    
    add_executable(cornerDetection src/main.cpp src/ConerDetection.cpp src/LineDetection.cpp src/ImagePublisher.cpp)
    target_link_libraries(cornerDetection ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
    
    add_executable(bonPublisher src/bonPublisher.cpp)
    target_link_libraries(bonPublisher ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
    
    add_executable(exempleSubscriber src/exempleSubscriber.cpp)
    target_link_libraries(exempleSubscriber ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
    
    install(TARGETS talker listener cornerDetection bonPublisher exempleSubscriber
        ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
    )
    

    Unfortunatly, I'm currently experiencing problems with opencv that's not able to read the image from the caspa (from /dev/video6)... But that's a whole other problem!