Skip to content

Fixes eager interface claiming bug in franka_hardware #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: humble
Choose a base branch
from
Open
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
19 changes: 16 additions & 3 deletions franka_hardware/src/franka_hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,25 @@ hardware_interface::return_type FrankaHardwareInterface::perform_command_mode_sw
hardware_interface::return_type FrankaHardwareInterface::prepare_command_mode_switch(
const std::vector<std::string>& start_interfaces,
const std::vector<std::string>& stop_interfaces) {
auto contains_interface_type = [](const std::string& interface,
const std::string& interface_type) {
auto contains_interface_type = [this](const std::string& interface,
const std::string& interface_type) {
size_t slash_position = interface.find('/');
if (slash_position != std::string::npos && slash_position + 1 < interface.size()) {
std::string after_slash = interface.substr(slash_position + 1);
return after_slash == interface_type;
std::string before_slash = interface.substr(0, slash_position);

if (after_slash == interface_type) {
if (interface_type != "position" && interface_type != "velocity" &&
interface_type != "effort" && interface_type != "acceleration") {
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very hardcoded.

What do you actually want to achieve?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On humble today, the hardware interface assumes every hardware plugin loaded by the controller manager is a FrankaHardwareInterface owned resource. This is often not true; for example, if a custom hardware (gripper, extra joints etc.) is loaded in the same controller manager. As a result, if you try to launch two separate hardware interfaces in the same controller manager, the FrankaHardwareInterface crashes.

The FrankaHardwareInterface allows for a subset of the standard interfaces: position, velocity, acceleration, and effort. The FrankaHardwareInterface also includes non-standard interface names, e.g. 1/cartesian_pose.

This PR first checks if the hardware interface is not one of the standard interfaces supported by the class. If not, it assumes (as it does on main) that the interface is owned by the class. If the interface is a standard interface, then it checks that the "joint" part of the interface name is a joint owned by the class.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreasKuhner do you have any thoughts on allowing for this functionality? Regardless of the hard-coding of the interface names, I think this is critical functionality for users. Should I replace "position" with hardware_interface::HW_IF_POSITION?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for a custom solution it works. But for our 'bigger' picture, it would need to resolve a few more issues... But I didn't have much time so far to investigate and see what that exactly means 😓

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to merge this, or a similar PR? The behavior change is very important for users running multiple hardware types in one controller manager (which I understand to be a common use case in ros2_control).

}

for (const auto& joint : this->info_.joints) {
if (before_slash == joint.name) {
return true;
}
}
}
}
return false;
};
Expand Down