Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate standalone nodelet executable with oneline cmake macro #47

Open
wants to merge 3 commits into
base: indigo-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nodelet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ catkin_package(
LIBRARIES nodeletlib ${UUID_LIBRARIES}
CATKIN_DEPENDS bondcpp message_runtime pluginlib rosconsole roscpp std_msgs
DEPENDS Boost
CFG_EXTRAS nodelet-extras.cmake
)

include_directories(include ${catkin_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS})
Expand All @@ -47,3 +48,7 @@ install(TARGETS nodeletlib
install(TARGETS nodelet
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY cmake
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
)
52 changes: 52 additions & 0 deletions nodelet/cmake/nodelet-extras.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
######################################################################
# Software License Agreement (BSD License)
#
# Copyright (c) 2016, Kentaro Wada.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Kentaro Wada nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
######################################################################

macro(nodelet_add_executable node_name nodelet_name)
# Get path to nodelet ROS package
if(nodelet_SOURCE_DIR)
set(_nodelet_SOURCE_DIR ${nodelet_SOURCE_DIR})
elseif(nodelet_SOURCE_PREFIX)
set(_nodelet_SOURCE_DIR ${nodelet_SOURCE_PREFIX})
else(nodelet_SOURCE_PREFIX)
set(_nodelet_SOURCE_DIR ${nodelet_PREFIX}/share/nodelet)
endif()
# Generate standalone nodelet executable
set(NODE_NAME ${node_name})
set(NODELET_NAME ${nodelet_name})
configure_file(${_nodelet_SOURCE_DIR}/cmake/standalone_nodelet_exe.in ${node_name} @ONLY)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/${node_name}
DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION})
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${node_name}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
endmacro()
38 changes: 38 additions & 0 deletions nodelet/cmake/standalone_nodelet_exe.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
######################################################################
# Software License Agreement (BSD License)
#
# Copyright (c) 2016, Kentaro Wada.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Kentaro Wada nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
######################################################################

# Default node name is "@NODE_NAME@",
# but it is reconfigured by argument afterward.
rosrun nodelet nodelet standalone @NODELET_NAME@ __name:=@NODE_NAME@ "$@"
4 changes: 4 additions & 0 deletions test_nodelet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if(CATKIN_ENABLE_TESTING)
${catkin_LIBRARIES}
)

# Test nodelet executable
nodelet_add_executable(plus test_nodelet/Plus)
add_rostest(test_nodelet_executable.launch)

add_rostest(test_local.launch)
add_rostest(test_loader.launch)

Expand Down
25 changes: 25 additions & 0 deletions test_nodelet/test_nodelet_executable.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<launch>
<node name="Plus"
pkg="test_nodelet" type="plus">
<param name="value" type="double" value="2.1"/>
</node>

<node name="plus_remap"
pkg="test_nodelet" type="plus">
<param name="value" type="double" value="2.1"/>
<remap from="~out" to="remapped_output"/>
</node>

<node name="Plus2"
pkg="test_nodelet" type="plus">
<rosparam file="$(find test_nodelet)/plus_default.yaml"/>
</node>

<node name="Plus3" pkg="test_nodelet" type="plus">
<param name="value" type="double" value="2.5"/>
<remap from="~in" to="Plus2/out"/>
</node>

<test test-name="plus_local"
pkg="test_nodelet" type="plus_local.py" />
</launch>