diff --git a/clients/AMENT_IGNORE b/clients/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ros_comm/AMENT_IGNORE b/ros_comm/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/AMENT_IGNORE b/test/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/AMENT_IGNORE b/tools/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/message_filters/CMakeLists.txt b/utilities/message_filters/CMakeLists.txt index 5694ac57e9..e89f352d55 100644 --- a/utilities/message_filters/CMakeLists.txt +++ b/utilities/message_filters/CMakeLists.txt @@ -1,90 +1,36 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.5) project(message_filters) if(NOT WIN32) set_directory_properties(PROPERTIES COMPILE_OPTIONS "-Wall;-Wextra") endif() -find_package(catkin REQUIRED COMPONENTS roscpp rosconsole) -catkin_package( - INCLUDE_DIRS include - LIBRARIES message_filters - CATKIN_DEPENDS roscpp rosconsole -) -catkin_python_setup() +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) -find_package(Boost REQUIRED COMPONENTS signals thread) +set(Boost_USE_STATIC_LIBS ON) +find_package(Boost REQUIRED) -include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) -link_directories(${catkin_LIBRARY_DIRS}) +include_directories(include + ${rclcpp_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) add_library(${PROJECT_NAME} src/connection.cpp) -target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} + ${rclcpp_LIBRARIES} +) + +ament_export_include_directories(include) +ament_export_libraries(${PROJECT_NAME}) +ament_package() install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) install(DIRECTORY include/${PROJECT_NAME}/ - DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h") -if(CATKIN_ENABLE_TESTING) - # Ugly workaround for check_test_ran macro issue - #add_subdirectory(test) - find_package(catkin COMPONENTS rostest rosunit) - - include_directories(${GTEST_INCLUDE_DIRS}) - - # ********** Tests ********** - catkin_add_gtest(${PROJECT_NAME}-msg_cache_unittest test/msg_cache_unittest.cpp) - if(TARGET ${PROJECT_NAME}-msg_cache_unittest) - target_link_libraries(${PROJECT_NAME}-msg_cache_unittest message_filters ${GTEST_LIBRARIES}) - endif() - - catkin_add_gtest(${PROJECT_NAME}-time_synchronizer_unittest test/time_synchronizer_unittest.cpp) - if(TARGET ${PROJECT_NAME}-time_synchronizer_unittest) - target_link_libraries(${PROJECT_NAME}-time_synchronizer_unittest message_filters ${GTEST_LIBRARIES}) - endif() - - catkin_add_gtest(${PROJECT_NAME}-test_synchronizer test/test_synchronizer.cpp) - if(TARGET ${PROJECT_NAME}-test_synchronizer) - target_link_libraries(${PROJECT_NAME}-test_synchronizer message_filters ${GTEST_LIBRARIES}) - endif() - - catkin_add_gtest(${PROJECT_NAME}-test_exact_time_policy test/test_exact_time_policy.cpp) - if(TARGET ${PROJECT_NAME}-test_exact_time_policy) - target_link_libraries(${PROJECT_NAME}-test_exact_time_policy message_filters ${GTEST_LIBRARIES}) - endif() - - catkin_add_gtest(${PROJECT_NAME}-test_approximate_time_policy test/test_approximate_time_policy.cpp) - if(TARGET ${PROJECT_NAME}-test_approximate_time_policy) - target_link_libraries(${PROJECT_NAME}-test_approximate_time_policy message_filters ${GTEST_LIBRARIES}) - endif() - - catkin_add_gtest(${PROJECT_NAME}-test_simple test/test_simple.cpp) - if(TARGET ${PROJECT_NAME}-test_simple) - target_link_libraries(${PROJECT_NAME}-test_simple message_filters ${GTEST_LIBRARIES}) - endif() - - catkin_add_gtest(${PROJECT_NAME}-test_chain test/test_chain.cpp) - if(TARGET ${PROJECT_NAME}-test_chain) - target_link_libraries(${PROJECT_NAME}-test_chain message_filters ${GTEST_LIBRARIES}) - endif() - - # Needs to be a rostest because it spins up a node, which blocks until it hears from the master (unfortunately) - add_rostest_gtest(${PROJECT_NAME}-time_sequencer_unittest test/time_sequencer_unittest.xml test/time_sequencer_unittest.cpp) - if(TARGET ${PROJECT_NAME}-time_sequencer_unittest) - target_link_libraries(${PROJECT_NAME}-time_sequencer_unittest message_filters) - endif() - - add_rostest_gtest(${PROJECT_NAME}-test_subscriber test/test_subscriber.xml test/test_subscriber.cpp) - if(TARGET ${PROJECT_NAME}-test_subscriber) - target_link_libraries(${PROJECT_NAME}-test_subscriber message_filters) - endif() - - # Unit test of the approximate synchronizer - catkin_add_nosetests(test/test_approxsync.py) - catkin_add_nosetests(test/test_message_filters_cache.py) -endif() diff --git a/utilities/message_filters/include/message_filters/connection.h b/utilities/message_filters/include/message_filters/connection.h index 8b840f5241..3929d48a8e 100644 --- a/utilities/message_filters/include/message_filters/connection.h +++ b/utilities/message_filters/include/message_filters/connection.h @@ -48,8 +48,8 @@ namespace message_filters class MESSAGE_FILTERS_DECL Connection { public: - typedef boost::function VoidDisconnectFunction; - typedef boost::function WithConnectionDisconnectFunction; + typedef std::function VoidDisconnectFunction; + typedef std::function WithConnectionDisconnectFunction; Connection() {} Connection(const VoidDisconnectFunction& func); Connection(const WithConnectionDisconnectFunction& func, boost::signals2::connection conn); diff --git a/utilities/message_filters/include/message_filters/macros.h b/utilities/message_filters/include/message_filters/macros.h index 6853a2b042..25b9cbd01d 100644 --- a/utilities/message_filters/include/message_filters/macros.h +++ b/utilities/message_filters/include/message_filters/macros.h @@ -25,11 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MESSAGE_FILTERS_MACROS_H_ +#ifndef MESSAGE_FILTERS_MACROS_H_ #define MESSAGE_FILTERS_MACROS_H_ -#include // for the DECL's - // Import/export for windows dll's and visibility for gcc shared libraries. #ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries diff --git a/utilities/message_filters/include/message_filters/signal1.h b/utilities/message_filters/include/message_filters/signal1.h index 75c3fe9f56..ad38edb771 100644 --- a/utilities/message_filters/include/message_filters/signal1.h +++ b/utilities/message_filters/include/message_filters/signal1.h @@ -1,36 +1,36 @@ /********************************************************************* -* Software License Agreement (BSD License) -* -* Copyright (c) 2010, Willow Garage, Inc. -* 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 Willow Garage 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. -*********************************************************************/ + * Software License Agreement (BSD License) + * + * Copyright (c) 2010, Willow Garage, Inc. + * 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 Willow Garage 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. + *********************************************************************/ #ifndef MESSAGE_FILTERS_SIGNAL1_H #define MESSAGE_FILTERS_SIGNAL1_H @@ -38,92 +38,90 @@ #include #include "connection.h" + #include -#include #include #include namespace message_filters { -template -class CallbackHelper1 -{ -public: - virtual ~CallbackHelper1() {} - - virtual void call(const ros::MessageEvent& event, bool nonconst_need_copy) = 0; + template + class CallbackHelper1 + { + public: + virtual ~CallbackHelper1() {} - typedef boost::shared_ptr > Ptr; -}; + virtual void call(const ros::MessageEvent& event, bool nonconst_need_copy) = 0; -template -class CallbackHelper1T : public CallbackHelper1 -{ -public: - typedef ros::ParameterAdapter

Adapter; - typedef boost::function Callback; - typedef typename Adapter::Event Event; + typedef std::shared_ptr > Ptr; + }; - CallbackHelper1T(const Callback& cb) - : callback_(cb) + template + class CallbackHelper1T : public CallbackHelper1 { - } + public: + typedef std::function& msg)> Callback; - virtual void call(const ros::MessageEvent& event, bool nonconst_force_copy) - { - Event my_event(event, nonconst_force_copy || event.nonConstWillCopy()); - callback_(Adapter::getParameter(my_event)); - } + CallbackHelper1T(const Callback& cb) + : callback_(cb) + { + } -private: - Callback callback_; -}; + virtual void call(const ros::MessageEvent& event, bool nonconst_force_copy) + { + // TODO: validate + callback_(event.getMessage()); + } -template -class Signal1 -{ - typedef boost::shared_ptr > CallbackHelper1Ptr; - typedef std::vector V_CallbackHelper1; + private: + Callback callback_; + }; -public: - template - CallbackHelper1Ptr addCallback(const boost::function& callback) + template + class Signal1 { - CallbackHelper1T* helper = new CallbackHelper1T(callback); + typedef std::shared_ptr > CallbackHelper1Ptr; + typedef std::vector V_CallbackHelper1; + + public: + template + CallbackHelper1Ptr addCallback(const std::function& callback) + { + CallbackHelper1T* helper = new CallbackHelper1T(callback); - boost::mutex::scoped_lock lock(mutex_); - callbacks_.push_back(CallbackHelper1Ptr(helper)); - return callbacks_.back(); - } + boost::mutex::scoped_lock lock(mutex_); + callbacks_.push_back(CallbackHelper1Ptr(helper)); + return callbacks_.back(); + } - void removeCallback(const CallbackHelper1Ptr& helper) - { - boost::mutex::scoped_lock lock(mutex_); - typename V_CallbackHelper1::iterator it = std::find(callbacks_.begin(), callbacks_.end(), helper); - if (it != callbacks_.end()) + void removeCallback(const CallbackHelper1Ptr& helper) { - callbacks_.erase(it); + boost::mutex::scoped_lock lock(mutex_); + typename V_CallbackHelper1::iterator it = std::find(callbacks_.begin(), callbacks_.end(), helper); + if (it != callbacks_.end()) + { + callbacks_.erase(it); + } } - } - void call(const ros::MessageEvent& event) - { - boost::mutex::scoped_lock lock(mutex_); - bool nonconst_force_copy = callbacks_.size() > 1; - typename V_CallbackHelper1::iterator it = callbacks_.begin(); - typename V_CallbackHelper1::iterator end = callbacks_.end(); - for (; it != end; ++it) + void call(const ros::MessageEvent& event) { - const CallbackHelper1Ptr& helper = *it; - helper->call(event, nonconst_force_copy); + boost::mutex::scoped_lock lock(mutex_); + bool nonconst_force_copy = callbacks_.size() > 1; + typename V_CallbackHelper1::iterator it = callbacks_.begin(); + typename V_CallbackHelper1::iterator end = callbacks_.end(); + for (; it != end; ++it) + { + const CallbackHelper1Ptr& helper = *it; + helper->call(event, nonconst_force_copy); + } } - } -private: - boost::mutex mutex_; - V_CallbackHelper1 callbacks_; -}; + private: + boost::mutex mutex_; + V_CallbackHelper1 callbacks_; + }; } // message_filters diff --git a/utilities/message_filters/include/message_filters/simple_filter.h b/utilities/message_filters/include/message_filters/simple_filter.h index 2201211fa8..b963809e20 100644 --- a/utilities/message_filters/include/message_filters/simple_filter.h +++ b/utilities/message_filters/include/message_filters/simple_filter.h @@ -1,36 +1,36 @@ /********************************************************************* -* Software License Agreement (BSD License) -* -* Copyright (c) 2008, Willow Garage, Inc. -* 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 Willow Garage 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. -*********************************************************************/ + * Software License Agreement (BSD License) + * + * Copyright (c) 2008, Willow Garage, Inc. + * 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 Willow Garage 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. + *********************************************************************/ #ifndef MESSAGE_FILTERS_SIMPLE_FILTER_H #define MESSAGE_FILTERS_SIMPLE_FILTER_H @@ -40,7 +40,6 @@ #include "connection.h" #include "signal1.h" #include -#include #include @@ -60,10 +59,10 @@ template class SimpleFilter : public boost::noncopyable { public: - typedef boost::shared_ptr MConstPtr; - typedef boost::function Callback; + typedef std::shared_ptr MConstPtr; + typedef std::function Callback; typedef ros::MessageEvent EventType; - typedef boost::function EventCallback; + typedef std::function EventCallback; /** * \brief Register a callback to be called when this filter has passed @@ -73,7 +72,7 @@ class SimpleFilter : public boost::noncopyable Connection registerCallback(const C& callback) { typename CallbackHelper1::Ptr helper = signal_.addCallback(Callback(callback)); - return Connection(boost::bind(&Signal::removeCallback, &signal_, helper)); + return Connection(std::bind(&Signal::removeCallback, &signal_, helper)); } /** @@ -81,9 +80,9 @@ class SimpleFilter : public boost::noncopyable * \param callback The callback to call */ template - Connection registerCallback(const boost::function& callback) + Connection registerCallback(const std::function& callback) { - return Connection(boost::bind(&Signal::removeCallback, &signal_, signal_.addCallback(callback))); + return Connection(std::bind(&Signal::removeCallback, &signal_, signal_.addCallback(callback))); } /** @@ -93,8 +92,8 @@ class SimpleFilter : public boost::noncopyable template Connection registerCallback(void(*callback)(P)) { - typename CallbackHelper1::Ptr helper = signal_.template addCallback

(boost::bind(callback, _1)); - return Connection(boost::bind(&Signal::removeCallback, &signal_, helper)); + typename CallbackHelper1::Ptr helper = signal_.template addCallback

(std::bind(callback, std::placeholders::_1)); + return Connection(std::bind(&Signal::removeCallback, &signal_, helper)); } /** @@ -104,8 +103,8 @@ class SimpleFilter : public boost::noncopyable template Connection registerCallback(void(T::*callback)(P), T* t) { - typename CallbackHelper1::Ptr helper = signal_.template addCallback

(boost::bind(callback, t, _1)); - return Connection(boost::bind(&Signal::removeCallback, &signal_, helper)); + typename CallbackHelper1::Ptr helper = signal_.template addCallback

(std::bind(callback, t, std::placeholders::_1)); + return Connection(std::bind(&Signal::removeCallback, &signal_, helper)); } /** diff --git a/utilities/message_filters/include/message_filters/subscriber.h b/utilities/message_filters/include/message_filters/subscriber.h index b69a3dace8..ab6e0abb5b 100644 --- a/utilities/message_filters/include/message_filters/subscriber.h +++ b/utilities/message_filters/include/message_filters/subscriber.h @@ -1,41 +1,44 @@ /********************************************************************* -* Software License Agreement (BSD License) -* -* Copyright (c) 2009, Willow Garage, Inc. -* 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 Willow Garage 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. -*********************************************************************/ + * Software License Agreement (BSD License) + * + * Copyright (c) 2009, Willow Garage, Inc. + * 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 Willow Garage 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. + *********************************************************************/ #ifndef MESSAGE_FILTERS_SUBSCRIBER_H #define MESSAGE_FILTERS_SUBSCRIBER_H -#include +#include + +#include +#include #include @@ -45,171 +48,176 @@ namespace message_filters { -class SubscriberBase -{ -public: - virtual ~SubscriberBase() {} - /** - * \brief Subscribe to a topic. - * - * If this Subscriber is already subscribed to a topic, this function will first unsubscribe. - * - * \param nh The ros::NodeHandle to use to subscribe. - * \param topic The topic to subscribe to. - * \param queue_size The subscription queue size - * \param transport_hints The transport hints to pass along - * \param callback_queue The callback queue to pass along - */ - virtual void subscribe(ros::NodeHandle& nh, const std::string& topic, uint32_t queue_size, const ros::TransportHints& transport_hints = ros::TransportHints(), ros::CallbackQueueInterface* callback_queue = 0) = 0; - /** - * \brief Re-subscribe to a topic. Only works if this subscriber has previously been subscribed to a topic. - */ - virtual void subscribe() = 0; - /** - * \brief Force immediate unsubscription of this subscriber from its topic - */ - virtual void unsubscribe() = 0; -}; -typedef boost::shared_ptr SubscriberBasePtr; - -/** - * \brief ROS subscription filter. - * - * This class acts as a highest-level filter, simply passing messages from a ROS subscription through to the - * filters which have connected to it. - * - * When this object is destroyed it will unsubscribe from the ROS subscription. - * - * The Subscriber object is templated on the type of message being subscribed to. - * - * \section connections CONNECTIONS - * - * Subscriber has no input connection. - * - * The output connection for the Subscriber object is the same signature as for roscpp subscription callbacks, ie. -\verbatim -void callback(const boost::shared_ptr&); -\endverbatim - */ -template -class Subscriber : public SubscriberBase, public SimpleFilter -{ -public: - typedef boost::shared_ptr MConstPtr; - typedef ros::MessageEvent EventType; + class SubscriberBase + { + public: + virtual ~SubscriberBase() {} + /** + * \brief Subscribe to a topic. + * + * If this Subscriber is already subscribed to a topic, this function will first unsubscribe. + * + * \param nh The ros::NodeHandle to use to subscribe. + * \param topic The topic to subscribe to. + * \param queue_size The subscription queue size + * \param transport_hints The transport hints to pass along + * \param callback_queue The callback queue to pass along + */ + virtual void subscribe(rclcpp::Node::SharedPtr& nh, const std::string& topic, uint32_t queue_size) = 0; + /** + * \brief Re-subscribe to a topic. Only works if this subscriber has previously been subscribed to a topic. + */ + virtual void subscribe() = 0; + /** + * \brief Force immediate unsubscription of this subscriber from its topic + */ + virtual void unsubscribe() = 0; + }; + typedef std::shared_ptr SubscriberBasePtr; /** - * \brief Constructor + * \brief ROS subscription filter. * - * See the ros::NodeHandle::subscribe() variants for more information on the parameters + * This class acts as a highest-level filter, simply passing messages from a ROS subscription through to the + * filters which have connected to it. * - * \param nh The ros::NodeHandle to use to subscribe. - * \param topic The topic to subscribe to. - * \param queue_size The subscription queue size - * \param transport_hints The transport hints to pass along - * \param callback_queue The callback queue to pass along - */ - Subscriber(ros::NodeHandle& nh, const std::string& topic, uint32_t queue_size, const ros::TransportHints& transport_hints = ros::TransportHints(), ros::CallbackQueueInterface* callback_queue = 0) - { - subscribe(nh, topic, queue_size, transport_hints, callback_queue); - } - - /** - * \brief Empty constructor, use subscribe() to subscribe to a topic - */ - Subscriber() - { - } - - ~Subscriber() - { - unsubscribe(); - } - - /** - * \brief Subscribe to a topic. + * When this object is destroyed it will unsubscribe from the ROS subscription. + * + * The Subscriber object is templated on the type of message being subscribed to. + * + * \section connections CONNECTIONS * - * If this Subscriber is already subscribed to a topic, this function will first unsubscribe. + * Subscriber has no input connection. * - * \param nh The ros::NodeHandle to use to subscribe. - * \param topic The topic to subscribe to. - * \param queue_size The subscription queue size - * \param transport_hints The transport hints to pass along - * \param callback_queue The callback queue to pass along + * The output connection for the Subscriber object is the same signature as for roscpp subscription callbacks, ie. + \verbatim + void callback(const boost::shared_ptr&); + \endverbatim */ - void subscribe(ros::NodeHandle& nh, const std::string& topic, uint32_t queue_size, const ros::TransportHints& transport_hints = ros::TransportHints(), ros::CallbackQueueInterface* callback_queue = 0) + template + class Subscriber : public SubscriberBase, public SimpleFilter { - unsubscribe(); + public: + typedef boost::shared_ptr BoostMConstPtr; + typedef std::shared_ptr MConstPtr; + typedef ros::MessageEvent EventType; + + /** + * \brief Constructor + * + * See the ros::NodeHandle::subscribe() variants for more information on the parameters + * + * \param nh The ros::NodeHandle to use to subscribe. + * \param topic The topic to subscribe to. + * \param queue_size The subscription queue size + * \param transport_hints The transport hints to pass along + * \param callback_queue The callback queue to pass along + */ + Subscriber(rclcpp::Node::SharedPtr& nh, const std::string& topic, uint32_t queue_size) + { + subscribe(nh, topic, queue_size); + } - if (!topic.empty()) + /** + * \brief Empty constructor, use subscribe() to subscribe to a topic + */ + Subscriber() { - ops_.template initByFullCallbackType(topic, queue_size, boost::bind(&Subscriber::cb, this, _1)); - ops_.callback_queue = callback_queue; - ops_.transport_hints = transport_hints; - sub_ = nh.subscribe(ops_); - nh_ = nh; } - } - /** - * \brief Re-subscribe to a topic. Only works if this subscriber has previously been subscribed to a topic. - */ - void subscribe() - { - unsubscribe(); + ~Subscriber() + { + unsubscribe(); + } - if (!ops_.topic.empty()) + /** + * \brief Subscribe to a topic. + * + * If this Subscriber is already subscribed to a topic, this function will first unsubscribe. + * + * \param nh The ros::NodeHandle to use to subscribe. + * \param topic The topic to subscribe to. + * \param queue_size The subscription queue size + * \param transport_hints The transport hints to pass along + * \param callback_queue The callback queue to pass along + */ + void subscribe(rclcpp::Node::SharedPtr& nh, const std::string& topic, uint32_t queue_size) { - sub_ = nh_.subscribe(ops_); + unsubscribe(); + + if (!topic.empty()) + { + topic_ = topic; + // TODO: why is this multi-line version needed? + auto stdFxn = std::bind(&Subscriber::cb, this, std::placeholders::_1); + std::function)> stdFxnPtr = stdFxn; + sub_ = nh->create_subscription(topic_, stdFxnPtr, rmw_qos_profile_default); + nh_ = nh; + } } - } - /** - * \brief Force immediate unsubscription of this subscriber from its topic - */ - void unsubscribe() - { - sub_.shutdown(); - } + /** + * \brief Re-subscribe to a topic. Only works if this subscriber has previously been subscribed to a topic. + */ + void subscribe() + { + unsubscribe(); + + if (!topic_.empty()) + { + // TODO: why is this multi-line version needed? + auto stdFxn = std::bind(&Subscriber::cb, this, std::placeholders::_1); + std::function)> stdFxnPtr = stdFxn; + sub_ = nh_->create_subscription(topic_, stdFxnPtr, rmw_qos_profile_default); + } + } - std::string getTopic() const - { - return ops_.topic; - } + /** + * \brief Force immediate unsubscription of this subscriber from its topic + */ + void unsubscribe() + { + // TODO: No idea how to do this in ROS2??? + } - /** - * \brief Returns the internal ros::Subscriber object - */ - const ros::Subscriber& getSubscriber() const { return sub_; } + std::string getTopic() const + { + return sub_->get_topic_name(); + } - /** - * \brief Does nothing. Provided so that Subscriber may be used in a message_filters::Chain - */ - template - void connectInput(F& f) - { - (void)f; - } + /** + * \brief Returns the internal ros::Subscriber object + */ + const std::shared_ptr> getSubscriber() const { return sub_; } - /** - * \brief Does nothing. Provided so that Subscriber may be used in a message_filters::Chain - */ - void add(const EventType& e) - { - (void)e; - } + /** + * \brief Does nothing. Provided so that Subscriber may be used in a message_filters::Chain + */ + template + void connectInput(F& f) + { + (void)f; + } + + /** + * \brief Does nothing. Provided so that Subscriber may be used in a message_filters::Chain + */ + void add(const EventType& e) + { + (void)e; + } -private: + private: - void cb(const EventType& e) - { - this->signalMessage(e); - } + void cb(const MConstPtr& e) + { + this->signalMessage(e); + } - ros::Subscriber sub_; - ros::SubscribeOptions ops_; - ros::NodeHandle nh_; -}; + std::string topic_; + std::shared_ptr> sub_; + rclcpp::Node::SharedPtr nh_; + }; } diff --git a/utilities/message_filters/package.xml b/utilities/message_filters/package.xml index 4f362ccfe6..06ca7369c2 100644 --- a/utilities/message_filters/package.xml +++ b/utilities/message_filters/package.xml @@ -1,4 +1,5 @@ - + + message_filters 1.13.5 @@ -12,18 +13,12 @@ Josh Faust Vijay Pradeep - catkin + ament_cmake - boost - rosconsole - roscpp - rostest - rosunit - - rosconsole - roscpp + rclcpp + rclcpp - + ament_cmake diff --git a/utilities/roslz4/AMENT_IGNORE b/utilities/roslz4/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/roswtf/AMENT_IGNORE b/utilities/roswtf/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/xmlrpcpp/AMENT_IGNORE b/utilities/xmlrpcpp/AMENT_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/xmlrpcpp/CMakeLists.txt b/utilities/xmlrpcpp/CMakeLists.txt index f06350019d..776aee0180 100644 --- a/utilities/xmlrpcpp/CMakeLists.txt +++ b/utilities/xmlrpcpp/CMakeLists.txt @@ -1,26 +1,24 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.5) project(xmlrpcpp) if(NOT WIN32) set_directory_properties(PROPERTIES COMPILE_OPTIONS "-Wall;-Wextra") endif() -find_package(catkin REQUIRED COMPONENTS cpp_common) +find_package(ament_cmake REQUIRED) # The CFG_EXTRAS is only for compatibility, to be removed in Lunar. -catkin_package( - INCLUDE_DIRS include - LIBRARIES xmlrpcpp - CATKIN_DEPENDS cpp_common - CFG_EXTRAS xmlrpcpp-extras.cmake -) +#catkin_package( +# INCLUDE_DIRS include +# LIBRARIES xmlrpcpp +# CATKIN_DEPENDS cpp_common +# CFG_EXTRAS xmlrpcpp-extras.cmake +#) include_directories( include libb64/include - ${catkin_INCLUDE_DIRS} ) -link_directories(${catkin_LIBRARY_DIRS}) if(WIN32) add_definitions(-D_WINDOWS) @@ -44,15 +42,16 @@ if(WIN32) target_link_libraries(xmlrpcpp ws2_32) endif() +ament_export_include_directories(include) +ament_export_libraries(xmlrpcpp) +ament_package() + install(DIRECTORY include/${PROJECT_NAME} - DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION} + DESTINATION include FILES_MATCHING PATTERN "*.h") install(TARGETS xmlrpcpp - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) -if (CATKIN_ENABLE_TESTING) - add_subdirectory(test) -endif() diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h index 8af174aead..27c42af0c0 100644 --- a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h +++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h @@ -40,7 +40,7 @@ #ifndef XMLRPCPP_DECL_H_INCLUDED #define XMLRPCPP_DECL_H_INCLUDED -#include +//#include #ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries #ifdef xmlrpcpp_EXPORTS // we are building a shared lib/dll diff --git a/utilities/xmlrpcpp/package.xml b/utilities/xmlrpcpp/package.xml index 85190bf30b..52e705111e 100644 --- a/utilities/xmlrpcpp/package.xml +++ b/utilities/xmlrpcpp/package.xml @@ -1,4 +1,5 @@ - + + xmlrpcpp 1.13.5 @@ -16,15 +17,16 @@ Morgan Quigley Austin Hendrix - catkin + ament_cmake + boost - + ament_cmake diff --git a/utilities/xmlrpcpp/src/XmlRpcDispatch.cpp b/utilities/xmlrpcpp/src/XmlRpcDispatch.cpp index a910ae8b15..705ee4ce87 100644 --- a/utilities/xmlrpcpp/src/XmlRpcDispatch.cpp +++ b/utilities/xmlrpcpp/src/XmlRpcDispatch.cpp @@ -6,9 +6,9 @@ #include #include #include -#include #if defined(_WINDOWS) +# include # include static inline int poll( struct pollfd *pfd, int nfds, int timeout) { @@ -22,6 +22,8 @@ static inline int poll( struct pollfd *pfd, int nfds, int timeout) # endif #else # include +# include + #endif // _WINDOWS @@ -98,9 +100,12 @@ XmlRpcDispatch::work(double timeout) while (_sources.size() > 0) { // Construct the sets of descriptors we are interested in - const unsigned source_cnt = _sources.size(); - pollfd fds[source_cnt]; - XmlRpcSource * sources[source_cnt]; + //const unsigned source_cnt = _sources.size(); + //pollfd fds[source_cnt]; + //XmlRpcSource * sources[source_cnt]; + unsigned source_cnt = _sources.size(); + std::vector fds(source_cnt); + std::vector sources(source_cnt); SourceList::iterator it; std::size_t i = 0; @@ -115,7 +120,7 @@ XmlRpcDispatch::work(double timeout) } // Check for events - int nEvents = poll(fds, source_cnt, (timeout_ms < 0) ? -1 : timeout_ms); + int nEvents = poll(fds.data(), source_cnt, (timeout_ms < 0) ? -1 : timeout_ms); if (nEvents < 0) { diff --git a/utilities/xmlrpcpp/src/XmlRpcSocket.cpp b/utilities/xmlrpcpp/src/XmlRpcSocket.cpp index 8c5fce05df..443d298262 100644 --- a/utilities/xmlrpcpp/src/XmlRpcSocket.cpp +++ b/utilities/xmlrpcpp/src/XmlRpcSocket.cpp @@ -209,9 +209,12 @@ XmlRpcSocket::connect(int fd, const std::string& host, int port) hints.ai_family = AF_UNSPEC; int getaddr_err = getaddrinfo(host.c_str(), NULL, &hints, &addr); if (0 != getaddr_err) { +#ifdef EAI_SYSTEM if(getaddr_err == EAI_SYSTEM) { XmlRpcUtil::error("Couldn't find an %s address for [%s]: %s\n", s_use_ipv6_ ? "AF_INET6" : "AF_INET", host.c_str(), XmlRpcSocket::getErrorMsg().c_str()); - } else { + } else +#endif + { XmlRpcUtil::error("Couldn't find an %s address for [%s]: %s\n", s_use_ipv6_ ? "AF_INET6" : "AF_INET", host.c_str(), gai_strerror(getaddr_err)); } return false;