Skip to content

Commit

Permalink
guard dt negative case and break the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Alcantara Costa Silva committed May 12, 2021
1 parent 9bbdedd commit 9752e25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions diff_drive_controller/src/diff_drive_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ namespace diff_drive_controller{
Commands curr_cmd = *(command_.readFromRT());
const double dt = (time - curr_cmd.stamp).toSec();

if(dt < 0)
{
ROS_ERROR("Invalid time interval, delta time cannot be negative");
curr_cmd.lin = 0.0;
curr_cmd.ang = 0.0;
}

// Brake if cmd_vel has timeout:
if (dt > cmd_vel_timeout_)
{
Expand Down

0 comments on commit 9752e25

Please sign in to comment.