ros-controls / ros_control

Generic and simple controls framework for ROS
http://wiki.ros.org/ros_control
BSD 3-Clause "New" or "Revised" License
480 stars 306 forks source link

TransmissionInterfaceLoader cannot find a handle of JointStateInterface #260

Open canalteks opened 7 years ago

canalteks commented 7 years ago

Dear developers,

I found that transmission_interface::TransmissionInterfaceLoader will throw an exception in loading new hardware_interface/Position,Velocity,EffortJointInterfaces from URDF::transmission tags.

This problem only occurs when the users used their own RobotHw with JointStateInterface.

It's because that

Then, the inconsistency of references between two JointStateInterfaces makes this problem.

I'll suggest following approaches,

  1. notify in the comment of the TransmissionInterfaceLoader --- RobotHw should not have its own JointStateInterface to use TransmissionInterfaceLoader,
  2. or add this code, instead of using joint_interfaces.joint_state_interface.
// test code to make this problem
RobotHw  robot_hw;
RobotTransmissions  robot_transmissions;
JointStateInterface  joint_state_interface;
robot_hw.registerInterface( &joint_state_interface );

TransmissionInterfaceLoader  loader( &robot_hw, &robot_transmissions );

loader.load( urdf );

yours sincerely.

littlejohnyang commented 7 years ago

I am having similar issue here. I have my own RobotHW with JointStateInterface. It'll throw an error "Failed to load transmission 'xxxx'. It contains no valid hardware interface. I can control the motors fine but I will not be able to receive any feedback. The moment I register a JointStateInterface with my RobotHW class, it'll throw this error. But I need it in order to control the group of motors through joint trajectory controller.

But the unit test cases inside ros_control has exactly the same code. Has the developer not run into the same problem with registering JointStateInterface with RobotHW?

mathias-luedtke commented 7 years ago

It took me a while to understand the problem, but I can confim @canalteks's code analysis. Another problem exists for the other interface types, if you try to register them after running loader.load.

As a workaround, instead of registering the interfaces yourself, you could use the interfaces from loader.getData()->joint_interface

jlack1987 commented 6 years ago

I too have found my way to this bug. Gotta give @canalteks a hand in actually tracking down the problem. I just started getting very strange plugin load errors that gave me no indication of what the actual problem was.

bmagyar commented 6 years ago

Can we afford to eliminate the local joint state interface as the (this code) section of point 2 suggests? This would be a slightly breaking change but I think it could still fly for melodic.

ompugao commented 5 years ago

any updates for this issue? I got a same error in melodic. How should I avoid this error?

jlack1987 commented 5 years ago

@ompugao the way I get around it is I load all transmissions containing my custom hardware interfaces before all others. Bit hacky, but it works for me

bmagyar commented 5 years ago

I've been thinking about this recently working on similar stuff and I am opting for point 2. What do you guys think of such a change?