Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Release Versions:
- [2.1.1](#211)
- [2.1.0](#210)

## Upcoming changes

- fix(controllers): safe interface map check (#233)

## 5.3.0

### January 13th, 2026
Expand Down
7 changes: 5 additions & 2 deletions source/modulo_controllers/src/RobotControllerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RobotControllerInterface::RobotControllerInterface(
new_joint_command_ready_(false),
command_decay_factor_(0.0),
command_rate_limit_(std::numeric_limits<double>::infinity()) {
if (!control_type.empty() && interface_map.find(control_type) == interface_map.cend()) {
if (!control_type.empty() && interface_map.count(control_type) == 0) {
RCLCPP_ERROR(get_node()->get_logger(), "Invalid control type: %s", control_type.c_str());
throw std::invalid_argument("Invalid control type: " + control_type);
}
Expand Down Expand Up @@ -233,6 +233,9 @@ controller_interface::return_type RobotControllerInterface::read_state_interface
joint.c_str(), interface.c_str());
return controller_interface::return_type::ERROR;
}
if (interface_map.count(interface) == 0) {
continue;
}
switch (interface_map.at(interface)) {
case JointStateVariable::POSITIONS:
joint_state_.set_position(value, joint_index);
Expand Down Expand Up @@ -387,7 +390,7 @@ void RobotControllerInterface::set_control_type(const std::string& control_type)
if (control_type_fixed_) {
throw std::runtime_error("Control type is fixed and cannot be changed anymore");
}
if (!control_type.empty() && interface_map.find(control_type) == interface_map.cend()) {
if (!control_type.empty() && interface_map.count(control_type) == 0) {
throw std::runtime_error("Invalid control type: " + control_type);
}
control_type_ = control_type;
Expand Down