Skip to content

Commit

Permalink
Fix cmdvel scaling bug (Closes #1175)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Sep 23, 2021
1 parent c27988a commit 4be5056
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions doc/source/doxygen-docs/changelog.md
Expand Up @@ -55,6 +55,7 @@
- Fix error generating and parsing TUM RGBD dataset rawlog files.
- Fix regresion in mrpt::opengl::CFBORender::render() throwing an exception if the input image was empty.
- Fix incorrect handling of negative, fractional viewport sizes in mrpt::opengl::COpenGLViewport
- Fix: Should not scale velocity commands when in slow down, in CAbstractPTGBasedReactive::generate_vel_cmd() (Closes [#1175](https://github.com/MRPT/mrpt/issues/1175)).

# Version 2.3.2: Released Jul 14, 2021
- Changes in applications:
Expand Down
37 changes: 22 additions & 15 deletions libs/nav/src/reactive/CAbstractPTGBasedReactive.cpp
Expand Up @@ -375,7 +375,7 @@ void CAbstractPTGBasedReactive::performNavigationStep()
* <---+--------------->|<--------------+-------->| |
* estimator: | |
* | |
* timoff_obstacles <-+ |
* timoff_obstacles <- |
* +--> timoff_curPoseVelAge |
* |<---------------------------------+--------------->|
* +-->
Expand Down Expand Up @@ -1415,25 +1415,32 @@ double CAbstractPTGBasedReactive::generate_vel_cmd(
}
else
{
const bool is_slowdown = in_movement.props.count("is_slowdown") != 0
? in_movement.props.at("is_slowdown") != 0
: false;

// Take the normalized movement command:
new_vel_cmd = in_movement.PTG->directionToMotionCommand(
in_movement.PTG->alpha2index(in_movement.direction));

// Scale holonomic speeds to real-world one:
new_vel_cmd->cmdVel_scale(in_movement.speed);
cmdvel_speed_scale *= in_movement.speed;

if (!m_last_vel_cmd) // first iteration? Use default values:
m_last_vel_cmd =
in_movement.PTG->getSupportedKinematicVelocityCommand();

// Honor user speed limits & "blending":
const double beta = meanExecutionPeriod.getLastOutput() /
(meanExecutionPeriod.getLastOutput() +
params_abstract_ptg_navigator.speedfilter_tau);
cmdvel_speed_scale *= new_vel_cmd->cmdVel_limits(
*m_last_vel_cmd, beta,
params_abstract_ptg_navigator.robot_absolute_speed_limits);
if (!is_slowdown)
{
new_vel_cmd->cmdVel_scale(in_movement.speed);
cmdvel_speed_scale *= in_movement.speed;

if (!m_last_vel_cmd) // first iteration? Use default values:
m_last_vel_cmd =
in_movement.PTG->getSupportedKinematicVelocityCommand();

// Honor user speed limits & "blending":
const double beta = meanExecutionPeriod.getLastOutput() /
(meanExecutionPeriod.getLastOutput() +
params_abstract_ptg_navigator.speedfilter_tau);
cmdvel_speed_scale *= new_vel_cmd->cmdVel_limits(
*m_last_vel_cmd, beta,
params_abstract_ptg_navigator.robot_absolute_speed_limits);
}
}

m_last_vel_cmd = new_vel_cmd; // Save for filtering in next step
Expand Down

0 comments on commit 4be5056

Please sign in to comment.