Skip to content

Commit

Permalink
Add SteadyTimer (#1014)
Browse files Browse the repository at this point in the history
* add SteadyTimer

based on SteadyTime (which uses the CLOCK_MONOTONIC).
This timer is not influenced by time jumps of the system time,
so ideal for things like periodic checks of timeout/heartbeat, etc...

* fix timer_manager to really use a steady clock when needed

This is a bit of a hack, since up to boost version 1.61 the time of the steady clock is always converted to system clock,
which is then used for the wait... which obviously doesn't help if we explicitly want the steady clock.

So as a workaround, include the backported versions of the boost condition variable if boost version is not recent enough.

* add tests for SteadyTimer

* [test] add -pthread to make some tests compile

not sure if this is only need in my case on ROS indigo...

* use SteadyTime for some timeouts

* add some checks to make sure the backported boost headers are included if needed

* specialize TimerManager threadFunc for SteadyTimer

to avoid the typeid check and make really sure the correct boost condition wait_until implementation is used

* Revert "[test] add -pthread to make some tests compile"

This reverts commit f62a3f2.

* set minimum version for rostime

* mostly spaces
  • Loading branch information
flixr authored and dirk-thomas committed Oct 25, 2017
1 parent daa9dac commit 8d4cbec
Show file tree
Hide file tree
Showing 18 changed files with 1,757 additions and 18 deletions.
3 changes: 2 additions & 1 deletion clients/roscpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ list(GET roscpp_VERSION_LIST 2 roscpp_VERSION_PATCH)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/ros/common.h.in ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros/common.h)

find_package(Boost REQUIRED COMPONENTS signals filesystem system)
find_package(Boost REQUIRED COMPONENTS chrono filesystem signals system)

include_directories(include ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})

Expand Down Expand Up @@ -118,6 +118,7 @@ add_library(roscpp
src/libros/poll_set.cpp
src/libros/service.cpp
src/libros/this_node.cpp
src/libros/steady_timer.cpp
)

add_dependencies(roscpp ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
Expand Down
23 changes: 23 additions & 0 deletions clients/roscpp/include/boost_161_condition_variable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef BOOST_THREAD_CONDITION_VARIABLE_HPP
#define BOOST_THREAD_CONDITION_VARIABLE_HPP

// condition_variable.hpp
//
// (C) Copyright 2007 Anthony Williams
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/detail/platform.hpp>
#if defined(BOOST_THREAD_PLATFORM_WIN32)
#include <boost/thread/win32/condition_variable.hpp>
#elif defined(BOOST_THREAD_PLATFORM_PTHREAD)
//#include <boost/thread/pthread/condition_variable.hpp>
#include "boost_161_pthread_condition_variable.h"
#else
#error "Boost threads unavailable on this platform"
#endif

#endif

Loading

0 comments on commit 8d4cbec

Please sign in to comment.