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

Insert tracing calls #80

Open
wants to merge 2 commits into
base: kinetic-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
4 changes: 2 additions & 2 deletions rostime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.3)
project(rostime)

find_package(catkin REQUIRED COMPONENTS cpp_common)
find_package(catkin REQUIRED COMPONENTS cpp_common tracetools)
find_package(Boost REQUIRED COMPONENTS date_time system thread)
catkin_package(
INCLUDE_DIRS include
Expand All @@ -17,7 +17,7 @@ add_library(rostime
src/rate.cpp
src/time.cpp)

target_link_libraries(rostime ${Boost_LIBRARIES})
target_link_libraries(rostime ${Boost_LIBRARIES} ${catkin_LIBRARIES})
if(NOT APPLE)
target_link_libraries(rostime ${RT_LIBRARY})
endif()
Expand Down
1 change: 1 addition & 0 deletions rostime/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

<run_depend>boost</run_depend>
<run_depend>cpp_common</run_depend>
<run_depend>tracetools</run_depend>
</package>
25 changes: 21 additions & 4 deletions rostime/src/rate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Author: Eitan Marder-Eppstein
*********************************************************************/
#include <ros/rate.h>
#include <tracetools/tracetools.h>

namespace ros
{
Expand All @@ -43,13 +44,19 @@ Rate::Rate(double frequency)
: start_(Time::now())
, expected_cycle_time_(1.0 / frequency)
, actual_cycle_time_(0.0)
{ }
{
ros::trace::timer_added((const void*)this, "ros::Rate(double)",
expected_cycle_time_.sec, expected_cycle_time_.nsec);
}

Rate::Rate(const Duration& d)
: start_(Time::now())
, expected_cycle_time_(d.sec, d.nsec)
, actual_cycle_time_(0.0)
{ }
{
ros::trace::timer_added((const void*)this, "ros::Rate(ros::Duration)",
expected_cycle_time_.sec, expected_cycle_time_.nsec);
}



Expand All @@ -74,6 +81,8 @@ bool Rate::sleep()
//make sure to reset our start time
start_ = expected_end;

ros::trace::time_sleep(this, sleep_time.sec, sleep_time.nsec);

//if we've taken too much time we won't sleep
if(sleep_time <= Duration(0.0))
{
Expand Down Expand Up @@ -104,13 +113,19 @@ WallRate::WallRate(double frequency)
: start_(WallTime::now())
, expected_cycle_time_(1.0 / frequency)
, actual_cycle_time_(0.0)
{}
{
ros::trace::timer_added((const void*)this, "ros::WallRate(double)",
expected_cycle_time_.sec, expected_cycle_time_.nsec);
}

WallRate::WallRate(const Duration& d)
: start_(WallTime::now())
, expected_cycle_time_(d.sec, d.nsec)
, actual_cycle_time_(0.0)
{}
{
ros::trace::timer_added((const void*)this, "ros::WallRate(ros::Duration)",
expected_cycle_time_.sec, expected_cycle_time_.nsec);
}

bool WallRate::sleep()
{
Expand All @@ -133,6 +148,8 @@ bool WallRate::sleep()
//make sure to reset our start time
start_ = expected_end;

ros::trace::time_sleep(this, sleep_time.sec, sleep_time.nsec);

//if we've taken too much time we won't sleep
if(sleep_time <= WallDuration(0.0))
{
Expand Down