updated to current catkin

This commit is contained in:
Dirk Thomas 2012-08-22 17:47:43 +00:00
parent 31633d0d36
commit 2b5cd81739
19 changed files with 115 additions and 145 deletions

View File

@ -9,8 +9,9 @@ catkin_stack()
# add_gtest(), which is called from within lower-level CMakeLists.txts.
catkin_python_setup()
catkin_add_env_hooks(10.ros SHELLS bat sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)
foreach(subdir
env-hooks
tools/rosunit
core/roslib
tools/rosbash
@ -21,7 +22,7 @@ endforeach()
# nosetests are declared here to make them visible to the build system
# (e.g., for Jenkins to invoke) but keep them from polluting the pristine
# Python packages.
find_package(ROS COMPONENTS rosunit)
find_package(catkin COMPONENTS rosunit)
add_nosetests(core/roslib/test)
add_nosetests(tools/rosmake/test)
add_nosetests(tools/rosunit/test)

View File

@ -4,25 +4,25 @@ cmake_minimum_required(VERSION 2.4.6)
#
# Catkin-compat thunks
#
cmake_policy(SET CMP0011 OLD)
#cmake_policy(SET CMP0011 OLD)
macro(rosbuild_catkinize)
endmacro()
# Policy settings to prevent warnings on 2.6 but ensure proper operation on
# 2.4.
if(COMMAND cmake_policy)
#if(COMMAND cmake_policy)
# Logical target names must be globally unique.
cmake_policy(SET CMP0002 OLD)
# cmake_policy(SET CMP0002 OLD)
# Libraries linked via full path no longer produce linker search paths.
cmake_policy(SET CMP0003 OLD)
# cmake_policy(SET CMP0003 OLD)
# Preprocessor definition values are now escaped automatically.
cmake_policy(SET CMP0005 OLD)
if(POLICY CMP0011)
# cmake_policy(SET CMP0005 OLD)
# if(POLICY CMP0011)
# Included scripts do automatic cmake_policy PUSH and POP.
cmake_policy(SET CMP0011 OLD)
endif(POLICY CMP0011)
endif(COMMAND cmake_policy)
# cmake_policy(SET CMP0011 OLD)
# endif(POLICY CMP0011)
#endif(COMMAND cmake_policy)
set(CMAKE_OSX_ARCHITECTURES "x86_64")

View File

@ -1,8 +1,7 @@
project(roslib)
find_package(catkin REQUIRED)
find_package(ROS REQUIRED COMPONENTS rospack rosunit)
find_package(catkin REQUIRED COMPONENTS rospack rosunit)
include_directories(include ${Boost_INCLUDE_DIRS} ${ROS_INCLUDE_DIRS})
include_directories(include ${Boost_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
# Avoid a boost warning that pops up when using msvc compiler
if(MSVC)
@ -10,7 +9,7 @@ if(MSVC)
endif()
add_library(roslib src/package.cpp)
target_link_libraries(roslib ${Boost_LIBRARIES} ${ROS_LIBRARIES})
target_link_libraries(roslib ${Boost_LIBRARIES} ${catkin_LIBRARIES})
if(NOT (APPLE OR WIN32 OR MINGW))
target_link_libraries(roslib rt)
@ -38,7 +37,11 @@ catkin_project(roslib
#integration tests
add_gtest(${PROJECT_NAME}-utest test/utest.cpp)
target_link_libraries(${PROJECT_NAME}-utest roslib ${Boost_LIBRARIES} ${ROS_LIBRARIES})
if(TARGET ${PROJECT_NAME}-utest)
target_link_libraries(${PROJECT_NAME}-utest roslib ${Boost_LIBRARIES} ${catkin_LIBRARIES})
endif()
add_gtest(${PROJECT_NAME}-test_package test/package.cpp)
target_link_libraries(${PROJECT_NAME}-test_package roslib ${ROS_LIBRARIES})
if(TARGET ${PROJECT_NAME}-test_package)
target_link_libraries(${PROJECT_NAME}-test_package roslib ${catkin_LIBRARIES})
endif()

View File

@ -46,6 +46,7 @@ import string
from subprocess import Popen, PIPE
from catkin.find_in_workspaces import find_in_workspaces as catkin_find
import rospkg
import roslib.manifest
@ -384,7 +385,7 @@ def list_pkgs_by_path(path, packages=None, cache=None, env=None):
return packages
def find_node(pkg, node_type, rospack=None, catkin_packages_cache=None):
def find_node(pkg, node_type, rospack=None):
"""
Warning: unstable API due to catkin.
@ -397,40 +398,12 @@ def find_node(pkg, node_type, rospack=None, catkin_packages_cache=None):
if rospack is None:
rospack = rospkg.RosPack()
return find_resource(pkg, node_type, filter_fn=_executable_filter,
rospack=rospack, catkin_packages_cache=catkin_packages_cache)
return find_resource(pkg, node_type, filter_fn=_executable_filter, rospack=rospack)
def _executable_filter(test_path):
s = os.stat(test_path)
return (s.st_mode & (stat.S_IRUSR | stat.S_IXUSR) == (stat.S_IRUSR | stat.S_IXUSR))
# TODO: this routine really belongs in catkin
def _load_catkin_packages_cache(catkin_packages_cache, env=None):
"""
env[CATKIN_BINARY_DIR] *must* be set
:param env: OS environment (defaults to os.environ if None/not set)
:param catkin_packages_cache: dictionary to read cache into.
Contents of dictionary will be replaced if cache is read. ``dict``
:raises: :exc:`KeyError` if env[CATKIN_BINARY_DIR] is not set
"""
if env is None:
env=os.environ
prefix = env[CATKIN_BINARY_DIR]
cache_file = os.path.join(prefix, 'etc', 'packages.list')
if os.path.isfile(cache_file):
catkin_packages_cache.clear()
with open(cache_file, 'r') as f:
for l in f.readlines():
l = l.strip()
# Example:
# rosconsole ros_comm/tools/rosconsole\n
if not l:
continue
idx = l.find(' ')
catkin_packages_cache[l[:idx]] = os.path.join(prefix, l[idx+1:])
def _find_resource(d, resource_name, filter_fn=None):
"""
subroutine of find_resource
@ -485,7 +458,7 @@ def _find_resource(d, resource_name, filter_fn=None):
# TODO: this routine really belongs in rospkg, but the catkin-isms really, really don't
# belong in rospkg. With more thought, they can probably be abstracted out so as
# to no longer be catkin-specific.
def find_resource(pkg, resource_name, filter_fn=None, rospack=None, catkin_packages_cache=None):
def find_resource(pkg, resource_name, filter_fn=None, rospack=None):
"""
Warning: unstable API due to catkin.
@ -499,7 +472,6 @@ def find_resource(pkg, resource_name, filter_fn=None, rospack=None, catkin_packa
:param filter: function that takes in a path argument and
returns True if the it matches the desired resource, ``fn(str)``
:param rospack: `rospkg.RosPack` instance to use
:param catkin_packages_cache: dictionary for caching catkin packages.list
:returns: lists of matching paths for resource within a given scope, ``[str]``
:raises: :exc:`rospkg.ResourceNotFound` If package does not exist
"""
@ -515,21 +487,19 @@ def find_resource(pkg, resource_name, filter_fn=None, rospack=None, catkin_packa
if rospack is None:
rospack = rospkg.RosPack()
if catkin_packages_cache is None:
catkin_packages_cache = {}
# lookup package as it *must* exist
pkg_path = rospack.get_path(pkg)
# load catkin packages list, if necessary
if CATKIN_BINARY_DIR in os.environ and not catkin_packages_cache:
_load_catkin_packages_cache(catkin_packages_cache)
# if found in binary dir, start with that. in any case, use matches
# from ros_package_path
matches = []
if pkg in catkin_packages_cache:
matches.extend(_find_resource(catkin_packages_cache[pkg], resource_name, filter_fn=filter_fn))
for search_in in ['libexec', 'share']:
try:
search_path = catkin_find(pkg, search_in=[search_in])
matches.extend(_find_resource(search_path, resource_name, filter_fn=filter_fn))
except RuntimeError:
pass
matches.extend(_find_resource(pkg_path, resource_name, filter_fn=filter_fn))
# Uniquify the results, in case we found the same file twice
return list(set(matches))

View File

@ -60,7 +60,7 @@ ROS_NAMESPACE ="ROS_NAMESPACE"
## directory in which log files are written
ROS_LOG_DIR ="ROS_LOG_DIR"
## directory in which test result files are written
ROS_TEST_RESULTS_DIR = "ROS_TEST_RESULTS_DIR"
CATKIN_TEST_RESULTS_DIR = "CATKIN_TEST_RESULTS_DIR"
class ROSEnvException(Exception):
"""Base class of roslib.rosenv errors."""
@ -189,9 +189,9 @@ def get_log_dir(env=None):
def get_test_results_dir(env=None):
"""
Get directory to use for writing test result files. There are multiple
possible locations for this. The ROS_TEST_RESULTS_DIR environment variable
has priority. If that is set, ROS_TEST_RESULTS_DIR is returned.
If ROS_TEST_RESULTS_DIR is not set, then ROS_HOME/test_results is used. If
possible locations for this. The CATKIN_TEST_RESULTS_DIR environment variable
has priority. If that is set, CATKIN_TEST_RESULTS_DIR is returned.
If CATKIN_TEST_RESULTS_DIR is not set, then ROS_HOME/test_results is used. If
ROS_HOME is not set, $HOME/.ros/test_results is used.
@param env: environment dictionary (defaults to os.environ)
@ -202,8 +202,8 @@ def get_test_results_dir(env=None):
if env is None:
env = os.environ
if ROS_TEST_RESULTS_DIR in env:
return env[ROS_TEST_RESULTS_DIR]
if CATKIN_TEST_RESULTS_DIR in env:
return env[CATKIN_TEST_RESULTS_DIR]
else:
return os.path.join(get_ros_home(env), 'test_results')

View File

@ -1,15 +0,0 @@
#
# Installed ROS env file
# This file was automatically generated.
#
# Scrub old ROS bin dirs, to avoid accidentally finding the wrong executables
PATH=`python -c "import os; print(os.pathsep.join([x for x in \"$PATH\".split(os.pathsep) if not any([d for d in ['cturtle', 'diamondback', 'electric', 'unstable'] if d in x])]))"`
export ROS_ROOT=@CMAKE_INSTALL_PREFIX@/share/ros
export ROS_PACKAGE_PATH=@CMAKE_INSTALL_PREFIX@/share:@CMAKE_INSTALL_PREFIX@/stacks
if [ ! "$ROS_MASTER_URI" ] ; then
export ROS_MASTER_URI=http://localhost:11311
fi
export ROS_ETC_DIR=@CMAKE_INSTALL_PREFIX@/etc/ros
export ROS_DISTRO=fuerte

20
env-hooks/10.ros.bat.in Normal file
View File

@ -0,0 +1,20 @@
REM generated from ros/env-hooks/10.ros.bat.in
REM scrub old ROS bin dirs, to avoid accidentally finding the wrong executables
PATH=`python -c "import os; print(os.pathsep.join([x for x in \"$PATH\".split(os.pathsep) if not any([d for d in ['cturtle', 'diamondback', 'electric', 'fuerte'] if d in x])]))"`
export ROS_DISTRO=groovy
if "%ROS_MASTER_URI%" EQ "" (
export ROS_MASTER_URI=http://localhost:11311
)
if @ENV_BUILDSPACE@ (
export ROS_PACKAGE_PATH=@CMAKE_SOURCE_DIR@
export ROS_ROOT=@CMAKE_CURRENT_SOURCE_DIR@
export ROS_ETC_DIR=@catkin_BUILD_PREFIX@/etc/ros
)
if @ENV_INSTALLSPACE@ (
export ROS_PACKAGE_PATH=@CMAKE_INSTALL_PREFIX@/share:@CMAKE_INSTALL_PREFIX@/stacks
export ROS_ROOT=@CMAKE_INSTALL_PREFIX@/share/ros
export ROS_ETC_DIR=@CMAKE_INSTALL_PREFIX@/etc/ros
)

View File

@ -1,16 +0,0 @@
#
# Buildspace ROS env file.
# This file was automatically generated.
#
# Scrub old ROS bin dirs, to avoid accidentally finding the wrong executables
PATH=`python -c "import os; print(os.pathsep.join([x for x in \"$PATH\".split(os.pathsep) if not any([d for d in ['cturtle', 'diamondback', 'electric', 'unstable'] if d in x])]))"`
#No ROS_ROOT in buildspace, ROS_ROOT is only for legacy (dry) builds
export ROS_TEST_RESULTS_DIR=@CMAKE_BINARY_DIR@/test_results
export ROS_PACKAGE_PATH=@CMAKE_SOURCE_DIR@
export ROS_DISTRO=fuerte
export PATH=@CMAKE_SOURCE_DIR@/ros/bin:$PATH
if [ ! "$ROS_MASTER_URI" ] ; then
export ROS_MASTER_URI=http://localhost:11311
fi

20
env-hooks/10.ros.sh.in Normal file
View File

@ -0,0 +1,20 @@
# generated from ros/env-hooks/10.ros.sh.in
# scrub old ROS bin dirs, to avoid accidentally finding the wrong executables
PATH=`python -c "import os; print(os.pathsep.join([x for x in \"$PATH\".split(os.pathsep) if not any([d for d in ['cturtle', 'diamondback', 'electric', 'fuerte'] if d in x])]))"`
export ROS_DISTRO=groovy
if [ ! "$ROS_MASTER_URI" ] ; then
export ROS_MASTER_URI=http://localhost:11311
fi
if @ENV_BUILDSPACE@; then
export ROS_PACKAGE_PATH=@CMAKE_SOURCE_DIR@
export ROS_ROOT=@CMAKE_CURRENT_SOURCE_DIR@
export ROS_ETC_DIR=@catkin_BUILD_PREFIX@/etc/ros
fi
if @ENV_INSTALLSPACE@; then
export ROS_PACKAGE_PATH=@CMAKE_INSTALL_PREFIX@/share:@CMAKE_INSTALL_PREFIX@/stacks
export ROS_ROOT=@CMAKE_INSTALL_PREFIX@/share/ros
export ROS_ETC_DIR=@CMAKE_INSTALL_PREFIX@/etc/ros
fi

View File

@ -1,3 +0,0 @@
catkin_add_env_hooks(10.ros
SHELLS all
)

View File

@ -1,2 +1,6 @@
if @ENV_BUILDSPACE@; then
. @CMAKE_CURRENT_SOURCE_DIR@/rosbash
fi
if @ENV_INSTALLSPACE@; then
. @CMAKE_INSTALL_PREFIX@/share/rosbash/rosbash
fi

View File

@ -1,2 +0,0 @@
. @CMAKE_CURRENT_SOURCE_DIR@/rosbash

View File

@ -1,2 +0,0 @@
. @CMAKE_CURRENT_SOURCE_DIR@/roszsh

View File

@ -0,0 +1,6 @@
if @ENV_BUILDSPACE@; then
. @CMAKE_CURRENT_SOURCE_DIR@/rostcsh
fi
if @ENV_INSTALLSPACE@; then
. @CMAKE_INSTALL_PREFIX@/share/rosbash/rostcsh
fi

View File

@ -1,2 +1,6 @@
if @ENV_BUILDSPACE@; then
. @CMAKE_CURRENT_SOURCE_DIR@/roszsh
fi
if @ENV_INSTALLSPACE@; then
. @CMAKE_INSTALL_PREFIX@/share/rosbash/roszsh
fi

View File

@ -8,9 +8,7 @@ install(PROGRAMS scripts/rosrun
message(STATUS " Making toplevel forward script for bash script rosrun")
set(BASH_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/rosrun)
configure_file(${catkin_EXTRAS_DIR}/templates/script.bash.in
${CMAKE_BINARY_DIR}/bin/rosrun
${catkin_BUILD_PREFIX}/bin/rosrun
@ONLY)
catkin_add_env_hooks(15.rosbash
SHELLS bash zsh
)
catkin_add_env_hooks(15.rosbash SHELLS bash tcsh zsh)

View File

@ -219,22 +219,16 @@ function rosls {
# sets arg as return value
function _roscmd {
local pkgdir exepath opt catkin_source_dir catkin_binary_dir opts
if [[ -n $CATKIN_SOURCE_DIR ]]; then
catkin_source_dir=`ROS_ROOT=$CATKIN_SOURCE_DIR ROS_PACKAGE_PATH= _ros_package_find $1`
fi
if [[ -n $CATKIN_BINARY_DIR && -f $CATKIN_BINARY_DIR/etc/packages.list ]]; then
cbd=`grep $1 $CATKIN_BINARY_DIR/etc/packages.list | cut -d " " -f 2`
if [[ -n $cbd ]]; then
catkin_binary_dir=$CATKIN_BINARY_DIR/$cbd
fi
local pkgdir exepath opt catkin_project_libexec_dir opts
if [[ -n $CATKIN_WORKSPACES ]]; then
catkin_project_libexec_dir=`catkin-find $1 --libexec 2> /dev/null`
fi
pkgdir=`_ros_package_find $1`
if [[ -z $catkin_source_dir && -z $catkin_binary_dir && -z $pkgdir ]]; then
if [[ -z $catkin_project_libexec_dir && -z $pkgdir ]]; then
echo "Couldn't find package [$1]"
return 1
fi
exepath=(`find -L $catkin_source_dir $catkin_binary_dir $pkgdir -name $2 -type f ! -regex .*/[.].* ! -regex .*$pkgdir\/build\/.* | uniq`)
exepath=(`find -L $catkin_project_libexec_dir $pkgdir -name $2 -type f ! -regex .*/[.].* ! -regex .*$pkgdir\/build\/.* | uniq`)
if [[ ${#exepath[@]} == 0 ]] ; then
echo "That file does not exist in that package."
return 1
@ -423,18 +417,12 @@ function _roscomplete_search_dir {
COMPREPLY=($(compgen -W "${opts}" -- ${arg}))
unset IFS
elif [[ $COMP_CWORD == 2 ]]; then
if [[ -n "$CATKIN_SOURCE_DIR" ]]; then
catkin_source_dir=`ROS_ROOT=$CATKIN_SOURCE_DIR ROS_PACKAGE_PATH= _ros_package_find ${COMP_WORDS[1]}`
fi
if [[ -n $CATKIN_BINARY_DIR && -f $CATKIN_BINARY_DIR/etc/packages.list ]]; then
cbd=`grep ${COMP_WORDS[1]} $CATKIN_BINARY_DIR/etc/packages.list | cut -d " " -f 2`
if [[ -n $cbd ]]; then
catkin_binary_dir=$CATKIN_BINARY_DIR/$cbd
fi
if [[ -n $CATKIN_WORKSPACES ]]; then
catkin_project_libexec_dir=`catkin-find ${COMP_WORDS[1]} --libexec 2> /dev/null`
fi
pkgdir=`_ros_package_find ${COMP_WORDS[1]}`
if [[ -n "$catkin_source_dir" || -n "$catkin_binary_dir" || -n "$pkgdir" ]]; then
opts=`_rosfind -L $catkin_source_dir $catkin_binary_dir $pkgdir ${1} ! -regex ".*/[.].*" ! -regex ".*$pkgdir\/build\/.*" -print0 | tr '\000' '\n' | sed -e "s/.*\/\(.*\)/\1/g"`
if [[ -n "$catkin_project_libexec_dir_dir" || -n "$pkgdir" ]]; then
opts=`_rosfind -L $catkin_project_libexec_dir $pkgdir ${1} ! -regex ".*/[.].*" ! -regex ".*$pkgdir\/build\/.*" -print0 | tr '\000' '\n' | sed -e "s/.*\/\(.*\)/\1/g"`
else
opts=""
fi

View File

@ -21,24 +21,18 @@ case $2 in
esac
# basename also makes .//foo into foo
basename=`basename $2`
if [[ -n $CATKIN_SOURCE_DIR ]]; then
catkin_source_dir=`ROS_ROOT=$CATKIN_SOURCE_DIR ROS_PACKAGE_PATH= rospack find $1`
fi
if [[ -n $CATKIN_BINARY_DIR && -f $CATKIN_BINARY_DIR/etc/packages.list ]]; then
cbd=`grep $1 $CATKIN_BINARY_DIR/etc/packages.list | cut -d " " -f 2`
if [[ -n $cbd ]]; then
catkin_binary_dir=$CATKIN_BINARY_DIR/$cbd
fi
if [[ -n $CATKIN_WORKSPACES ]]; then
catkin_project_libexec_dir=`catkin-find $1 --libexec 2> /dev/null`
fi
pkgdir=`rospack find $1`
if [[ -z $catkin_source_dir && -z $catkin_binary_dir && -z $pkgdir ]]; then
if [[ -z $catkin_project_libexec_dir && -z $pkgdir ]]; then
exit 2
fi
if [[ ! $2 == */* ]]; then
# The -perm /mode usage is not available in find on the Mac
#exepathlist=(`find $pkgdir -name $2 -type f -perm /u+x,g+x,o+x`)
# -L: #3475
exepathlist=(`find -L $catkin_source_dir $catkin_binary_dir $pkgdir -name $2 -type f -perm +111 ! -regex ".*$pkgdir\/build\/.*" | uniq`)
exepathlist=(`find -L $catkin_project_libexec_dir $pkgdir -name $2 -type f -perm +111 ! -regex ".*$pkgdir\/build\/.*" | uniq`)
if [[ ${#exepathlist[@]} == 0 ]] ; then
echo "[rosrun] Couldn't find executable named $2 below $pkgdir"
nonexepathlist=(`find -H $pkgdir -name $2`)

View File

@ -1,5 +1,5 @@
macro(rosunit_initialize_tests)
if(rosunit_SOURCE_DIR)
if (@PKG_BUILDSPACE@)
find_program_required(ROSUNIT_EXE rosunit
PATHS @PROJECT_SOURCE_DIR@/scripts
NO_DEFAULT_PATH)