Skip to content

external_velocity_limit_selector: Bug - Velocity Limit Not Updated on Empty Table Clear #11370

@marvsee

Description

@marvsee

Checklist

  • I've read the contribution guidelines.
  • I've searched other issues and no duplicate issues were found.
  • I'm convinced that this is not my fault but a bug.

Description

There is a logical bug in the ExternalVelocityLimitSelectorNode implementation:

  • When a velocity limit clear command is received, onVelocityLimitClearCommand calls clearVelocityLimit, then getCurrentVelocityLimit and publishVelocityLimit.

  • If velocity_limit_table_ is empty, clearVelocityLimit returns early and does not call updateVelocityLimit().

  • This means hardest_limit_ is not updated, and subsequent calls to getCurrentVelocityLimit() may return invalid or stale data.

Expected behavior

After a clear command (even when the table is empty), the node should always update its internal state and publish a valid/default velocity limit.

Actual behavior

When a clear command is send before any velocity limit command, an undefined value will be published as the external velocity limit. In RVIZ the speed limit is immediately set to 0 km/h.

Steps to reproduce

  1. Start the planning simulation with the external_velocity_limit_selector.
  2. Do not send any external velocity limit
  3. Send a clear command (VelocityLimitClearCommand). E.g. via Terminal: ros2 topic pub -1 /planning/scenario_planning/clear_velocity_limit tier4_planning_msgs/msg/VelocityLimitClearCommand "{command: true, sender: "examplesender"}"
  4. Observe that the published velocity limit may be inconsistent or default-initialized.

Versions

No response

Possible causes

The undefined state of the hardest_limit_ can be avoided, if updateVelocityLimit() is always called. My proposal to fix this is:

void ExternalVelocityLimitSelectorNode::clearVelocityLimit(const std::string & sender)
{
  if (velocity_limit_table_.empty()) {
    RCLCPP_WARN(get_logger(), "no velocity limit has been set from internal.");
    updateVelocityLimit(); // <-- this should be added, so the limit is always updated, even if the table is empty
    return;
  }

  velocity_limit_table_.erase(sender);
  updateVelocityLimit();
}

Additional context

This bug was found together with the EDGAR team (especially @korbinianmoller and @tmasc31) while working on an integration of electronic speed limit signs for the EDGAR Demo rides at IAA 2025.

Metadata

Metadata

Assignees

Labels

type:bugSoftware flaws or errors.

Type

No type

Projects

Status

To Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions