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

Fix various issues in TriggerRate #292

Open
wants to merge 4 commits into
base: develop
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
2 changes: 1 addition & 1 deletion franka_hw/include/franka_hw/trigger_rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TriggerRate {

private:
ros::Time time_stamp_;
double period_;
ros::Duration period_;
};

}; // namespace franka_hw
5 changes: 3 additions & 2 deletions franka_hw/src/trigger_rate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ namespace franka_hw {
TriggerRate::TriggerRate(double rate) : period_(1.0 / rate), time_stamp_(ros::Time::now()) {}

bool TriggerRate::operator()() {
if ((ros::Time::now() - time_stamp_).toSec() > period_) {
time_stamp_ = ros::Time::now();
auto now = ros::Time::now();
if (now - time_stamp_ >= period_ || now < time_stamp_) {
time_stamp_ = now;
return true;
}
return false;
Expand Down