Skip to content

Commit d438243

Browse files
committed
Add warning when period is exceeded.
1 parent 98edaef commit d438243

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/log.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ void Log::start_it() {
114114
timeorigin_;
115115
}
116116

117-
void Log::stop_it() {
117+
double Log::stop_it() {
118118
struct timeval current;
119119
gettimeofday(&current, 0);
120120

121121
time_stop_it_ =
122122
((double)current.tv_sec + 0.000001 * (double)current.tv_usec) -
123123
timeorigin_;
124+
125+
return time_stop_it_ - time_start_it_;
124126
}
125127

126128
void Log::save(std::string &fileName) {

src/log.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public:
9292

9393
void save(std::string &fileName);
9494
void start_it();
95-
void stop_it();
95+
/// \return the elapsed time since the previous \ref start_it
96+
double stop_it();
9697
};
9798
} // namespace rc_sot_system
9899

src/roscontrol-sot-controller.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,11 @@ void RCSotController::one_iteration() {
967967
readControl(controlValues_);
968968

969969
// Chrono stop.
970-
RcSotLog_.stop_it();
970+
double it_duration = RcSotLog_.stop_it();
971+
if (it_duration > dt_) {
972+
ROS_WARN_THROTTLE(1, "Iteration duration (%d) bigger than max period (%d)",
973+
it_duration, dt_);
974+
}
971975

972976
/// Store everything in Log.
973977
RcSotLog_.record(DataOneIter_);

0 commit comments

Comments
 (0)