Skip to content

Commit

Permalink
Set cmd_dt to zero when detecting negative value
Browse files Browse the repository at this point in the history
Instead of setting curr_cmd to zero, the correct approach is to set cmd_dt to zero and this will then keep the current control, without any abrupt change

Co-authored-by: Matt Reynolds <[email protected]>
  • Loading branch information
alcantara09 and matthew-reynolds authored Jun 10, 2021
1 parent a37bff1 commit 7b68cd7
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,11 @@ namespace ackermann_steering_controller{
}

// Limit velocities and accelerations:
const double cmd_dt = (period.toSec() > 0) ? period.toSec() : 0.0;
if(cmd_dt < 0)
double cmd_dt(period.toSec());
if (cmd_dt < 0.0)
{
ROS_ERROR("Invalid time interval, delta time cannot be negative");
curr_cmd.lin = 0.0;
curr_cmd.ang = 0.0;
cmd_dt = 0.0;
}

limiter_lin_.limit(curr_cmd.lin, last0_cmd_.lin, last1_cmd_.lin, cmd_dt);
Expand Down

0 comments on commit 7b68cd7

Please sign in to comment.