Skip to content

Commit 9752e25

Browse files
author
Gabriel Alcantara Costa Silva
committed
guard dt negative case and break the controller
1 parent 9bbdedd commit 9752e25

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

diff_drive_controller/src/diff_drive_controller.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,13 @@ namespace diff_drive_controller{
461461
Commands curr_cmd = *(command_.readFromRT());
462462
const double dt = (time - curr_cmd.stamp).toSec();
463463

464+
if(dt < 0)
465+
{
466+
ROS_ERROR("Invalid time interval, delta time cannot be negative");
467+
curr_cmd.lin = 0.0;
468+
curr_cmd.ang = 0.0;
469+
}
470+
464471
// Brake if cmd_vel has timeout:
465472
if (dt > cmd_vel_timeout_)
466473
{

0 commit comments

Comments
 (0)