Skip to content

Commit

Permalink
Updating create_rtt_msgs script to work with catkin (tested with geom…
Browse files Browse the repository at this point in the history
…etry_msgs)
  • Loading branch information
jbohren committed Jul 17, 2013
1 parent 537b766 commit ba94607
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 64 deletions.
2 changes: 1 addition & 1 deletion rtt_rospack/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<run_depend>rtt</run_depend>

<export>

<rtt_plugin_depend>rtt_rostopic</rtt_plugin_depend>
</export>
</package>
10 changes: 8 additions & 2 deletions rtt_rostopic/rtt_msg_pkg_template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
cmake_minimum_required(VERSION 2.8.3)
project(rtt_@pkgname@)

find_package(catkin REQUIRED COMPONENTS rtt_rostopic @pkgname@)
find_package(catkin REQUIRED COMPONENTS
rtt_rostopic
@pkgname@
@catkin_deplist@)

catkin_package(
DEPENDS ocl rtt
CATKIN_DEPENDS rtt_rostopic @pkgname@)
CATKIN_DEPENDS
rtt_rostopic
@pkgname@
@catkin_deplist@)

include_directories(${catkin_INCLUDE_DIRS})
ros_generate_rtt_typekit(@pkgname@)
Expand Down
25 changes: 17 additions & 8 deletions rtt_rostopic/rtt_msg_pkg_template/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<package>
<description brief="rtt_@pkgname@">
<name>rtt_@pkgname@</name>
<version>2.6.0</version>
<description>

Provides an rtt typekit for ROS @pkgname@ messages.

Expand All @@ -15,18 +17,25 @@
typekit.

</description>
<author>create_rtt_msgs Generator</author>
<maintainer email="orocos-dev@lists.mech.kuleuven.be">Orocos Developers</maintainer>
<author>create_rtt_msgs</author>
<license>BSD</license>
<review status="unreviewed" notes=""/>
<url>http://ros.org/wiki/rtt_rostopic</url>
<depend package="rtt_rostopic"/>
<depend package="@pkgname@"/>

<buildtool_depend>catkin</buildtool_depend>

<build_depend>@pkgname@</build_depend>
<build_depend>rtt_rostopic</build_depend>

<run_depend>@pkgname@</run_depend>
<run_depend>rtt_rostopic</run_depend>

@deplist@

<export>
<cpp cflags="-I${prefix}/include"/>
<rtt_plugin_depend>rtt_rostopic</rtt_plugin_depend>
@rtt_deplist@
</export>


</package>


108 changes: 55 additions & 53 deletions rtt_rostopic/scripts/create_rtt_msgs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

function help
{
echo
echo "Creates an Orocos typekit package from a ROS msgs package."
echo " Usage: $(basename $0) [-f] ros_msgs_package_name "
echo
echo "Example:"
echo " $(basename $0) std_msgs "
echo " Creates the rtt_std_msgs package derived from the ROS std_msgs package."
echo
echo
echo "Creates an Orocos typekit package from a ROS msgs package."
echo " Usage: $(basename $0) [-f] ros_msgs_package_name "
echo
echo "Example:"
echo " $(basename $0) std_msgs "
echo " Creates the rtt_std_msgs package derived from the ROS std_msgs package."
echo
}

if [ x$1 = x ]; then
help
exit 1
help
exit 1
fi

cwd="$(pwd)"
Expand All @@ -23,61 +23,63 @@ abspath=$(dirname "$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")")
# Parse arguments
force=
for arg in $*; do
case "$arg" in
-f)
force=-p
;;
-h|--help)
help
exit 1
;;
*)
if [ -n "$pkgname" ]; then
echo "ERROR: '$arg': please provide only one ros package name."
exit 1;
fi
if [ -z "$(rospack find $arg)" ]; then
echo "ERROR: could not find ros package '$arg'"
exit 1;
fi
if [[ $arg =~ rtt_.* ]]; then
echo "ERROR: You're giving a package name that starts with 'rtt_'. Use the ROS/non-RTT package name instead."
exit 1;
fi
pkgname="$arg"
;;
esac
case "$arg" in
-f)
force=-p
;;
-h|--help)
help
exit 1
;;
*)
if [ -n "$pkgname" ]; then
echo "ERROR: '$arg': please provide only one ros package name."
exit 1;
fi
if [ -z "$(rospack find $arg)" ]; then
echo "ERROR: could not find ros package '$arg'"
exit 1;
fi
if [[ $arg =~ rtt_.* ]]; then
echo "ERROR: You're giving a package name that starts with 'rtt_'. Use the ROS/non-RTT package name instead."
exit 1;
fi
pkgname="$arg"
;;
esac
done


# Locate the template directory.
templatedir="$(rospack find rtt_rostopic)/scripts/rtt_msgs"
templatedir="$(rospack find rtt_rostopic)/rtt_msg_pkg_template"

# final check:
if [ ! -d "$templatedir" ]; then
echo "Could not find templates at $templatedir !"
exit 1
echo "Could not find templates at $templatedir !"
exit 1
else
echo "Using templates at $templatedir..."
echo "Using templates at $templatedir..."
fi

for dep in $(rospack depends $pkgname | grep "_msgs$"); do
if [ -z "$(rospack find -q rtt_$dep)" ]; then
echo "WARNING: The package 'rtt_$dep' does not exist yet, however, 'rtt_$pkgname' will depend on it !"
echo " Use '$(basename $0) $dep' to create this missing package..."
fi
deplist="$deplist <build_depend>rtt_$dep</build_depend>\n <run_depend>rtt_$dep</run_depend>"
if [ -z "$(rospack find -q rtt_$dep)" ]; then
echo "WARNING: The package 'rtt_$dep' does not exist yet, however, 'rtt_$pkgname' will depend on it !"
echo " Use '$(basename $0) $dep' to create this missing package..."
fi
deplist="$deplist <build_depend>rtt_$dep</build_depend>\n <run_depend>rtt_$dep</run_depend>"
rtt_deplist="$rtt_deplist <rtt_plugin_depend>rtt_$dep</rtt_plugin_depend>"
catkin_deplist="$catkin_deplist rtt_$dep"
done

mkdir $force rtt_$pkgname || { echo "Package already exists, use -f to force creation." ; exit 1; }
# process template files:
files="$(find $templatedir -maxdepth 1 -type f)"
allcappkgname=$(echo $pkgname | tr [:lower:] [:upper:])
cappkgname=$(echo $allcappkgname | cut -c1)$(echo $pkgname | cut -c2-)
for i in $files; do
tgtname=$(echo $(basename "$i") | sed -e "s/pkgname/$pkgname/g;s/Pkgname/$cappkgname/g;")
cat "$i" | sed -e "s/@PKGNAME@/$allcappkgname/g;s/@pkgname@/$pkgname/g;s/@Pkgname@/$cappkgname/g;s|@deplist@|$deplist|g" > rtt_$pkgname/$tgtname
done
mkdir $force rtt_$pkgname || { echo "Package already exists, use -f to force creation." ; exit 1; }

# process template files:
files="$(find $templatedir -maxdepth 1 -type f)"
allcappkgname=$(echo $pkgname | tr [:lower:] [:upper:])
cappkgname=$(echo $allcappkgname | cut -c1)$(echo $pkgname | cut -c2-)
for i in $files; do
tgtname=$(echo $(basename "$i") | sed -e "s/pkgname/$pkgname/g;s/Pkgname/$cappkgname/g;")
cat "$i" | sed -e "s/@PKGNAME@/$allcappkgname/g;s/@pkgname@/$pkgname/g;s/@Pkgname@/$cappkgname/g;s|@deplist@|$deplist|g;s|@rtt_deplist@|$rtt_deplist|g;s|@catkin_deplist@|$catkin_deplist|g" > rtt_$pkgname/$tgtname
done

echo "Successfully created rtt_$pkgname."

0 comments on commit ba94607

Please sign in to comment.