Skip to content

Commit 369dff0

Browse files
committed
Only append to start_modes in prepare_switch
Before the main control mode (position/velocity) was always overwriting the complete list for the joint. That worked fine when that was the only control mode for a joint or if it was the first in the list. But that is not guaranteed. Since we create the list as an empty vector beforehand, anyway, we can simply append to that list in any case. The list will be checked for compatibility at a later point, anyway. # Conflicts: # ur_robot_driver/src/hardware_interface.cpp
1 parent 714768c commit 369dff0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ur_robot_driver/src/hardware_interface.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,12 +1094,6 @@ hardware_interface::return_type URPositionHardwareInterface::prepare_command_mod
10941094
}
10951095
}
10961096

1097-
if (!std::all_of(start_modes_.begin() + 1, start_modes_.end(),
1098-
[&](const std::vector<std::string>& other) { return other == start_modes_[0]; })) {
1099-
RCLCPP_ERROR(rclcpp::get_logger("URPositionHardwareInterface"), "Start modes of all joints have to be the same.");
1100-
return hardware_interface::return_type::ERROR;
1101-
}
1102-
11031097
// Starting interfaces
11041098
// If a joint has been reserved already, raise an error.
11051099
// Modes that are not directly mapped to a single joint such as force_mode reserve all joints.
@@ -1115,7 +1109,7 @@ hardware_interface::return_type URPositionHardwareInterface::prepare_command_mod
11151109
"requested.");
11161110
return hardware_interface::return_type::ERROR;
11171111
}
1118-
start_modes_[i] = { hardware_interface::HW_IF_POSITION };
1112+
start_modes_[i].push_back(hardware_interface::HW_IF_POSITION);
11191113
} else if (key == info_.joints[i].name + "/" + hardware_interface::HW_IF_VELOCITY) {
11201114
if (std::any_of(start_modes_[i].begin(), start_modes_[i].end(), [&](const std::string& item) {
11211115
return item == hardware_interface::HW_IF_POSITION || item == PASSTHROUGH_GPIO ||
@@ -1126,7 +1120,7 @@ hardware_interface::return_type URPositionHardwareInterface::prepare_command_mod
11261120
"requested.");
11271121
return hardware_interface::return_type::ERROR;
11281122
}
1129-
start_modes_[i] = { hardware_interface::HW_IF_VELOCITY };
1123+
start_modes_[i].push_back(hardware_interface::HW_IF_VELOCITY);
11301124
} else if (key == tf_prefix + FORCE_MODE_GPIO + "/type") {
11311125
if (std::any_of(start_modes_[i].begin(), start_modes_[i].end(), [&](const std::string& item) {
11321126
return item == hardware_interface::HW_IF_POSITION || item == hardware_interface::HW_IF_VELOCITY;
@@ -1171,6 +1165,12 @@ hardware_interface::return_type URPositionHardwareInterface::prepare_command_mod
11711165
}
11721166
}
11731167

1168+
if (!std::all_of(start_modes_.begin() + 1, start_modes_.end(),
1169+
[&](const std::vector<std::string>& other) { return other == start_modes_[0]; })) {
1170+
RCLCPP_ERROR(rclcpp::get_logger("URPositionHardwareInterface"), "Start modes of all joints have to be the same.");
1171+
return hardware_interface::return_type::ERROR;
1172+
}
1173+
11741174
// Stopping interfaces
11751175
// add stop interface per joint in tmp var for later check
11761176
for (const auto& key : stop_interfaces) {

0 commit comments

Comments
 (0)