Skip to content

Commit

Permalink
fix zero time period at control loop start (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjp committed Apr 30, 2021
1 parent e345205 commit 74e0005
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions diffbot_base/src/diffbot_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ int main(int argc, char **argv)
// Setup for the control loop.
ros::Time prev_time = ros::Time::now();
ros::Rate rate(10.0); // 50 Hz rate

rate.sleep();

// Blocks until shutdown signal recieved
while (ros::ok())
{
// Basic bookkeeping to get the system time in order to compute the control period.
const ros::Time time = ros::Time::now();
const ros::Duration period = time - prev_time;
prev_time = time;

// Execution of the actual control loop.
diffBot.read(time, period);
// If needed, its possible to define transmissions in software by calling the
Expand Down

0 comments on commit 74e0005

Please sign in to comment.