Exporting a plugin with multiple parents implementing same base

asked 2019-08-28 03:42:40 -0500

tahsinkose gravatar image

updated 2019-08-28 08:04:05 -0500

Hi there,

I'm trying to attach a controllable gimbal to a drone and simulate the outcome in Gazebo. After a lot of struggle on writing my own gazebo_ros_control::RobotHWSim derivation that can command both the drone and gimbal, I have decided to combine existing such instances in my own. In order to do that, I apply multiple inheritance as follows:

class MyDroneHardwareSim : public gazebo_ros_control::DefaultRobotHWSim, public hector_quadrotor_controller_gazebo::QuadrotorHardwareSim

Both of those classes are also derived from gazebo_ros_control::RobotHWSim. At the end I add PLUGINLIB_EXPORT_CLASS(dji_m100_controller_gazebo::DJIM100HardwareSim, gazebo_ros_control::RobotHWSim) as tutorial suggests. However, due to multiple inheritance pluginlib fails to discover which base to use from the inherited plugins and throws ‘gazebo_ros_control::RobotHWSim’ is an ambiguous base of ‘my_drone_controller_gazebo::MyDroneHardwareSim error.

This is more of a C++ problem, and there are ways to resolve this disambiguity. However, I doubt that pluginlib has such flexibility in its class exporting macro. Does anyone know a workaround on that? I really don't want to copy paste all the code from all hardware sim classes.

edit retag flag offensive close merge delete



Not an answer, but: isn't this what combined_robot_hw was created for? I don't know whether it is supported by the Gazebo plugin, but if you're after being able to control all joints from a single controller, then perhaps you could take a look at combined_robot_hw.

gvdhoorn gravatar image gvdhoorn  ( 2019-08-28 08:11:57 -0500 )edit

As you said, it is a facility to easily combine several existing controllers; but it lacks any Gazebo support. That is, one needs to implement a custom RobotHWSim class, which registers the combined robot hw interface with all Gazebo-related primitives from scratch. Indeed I have started with combined_robot_hw, nonetheless consequently the bottleneck revealed out as the gazebo_ros_control side.

Since my use-case demands only two such Sim classes, I've inherited from the one with most line of code and copy-pasted the other. I'm planning to add a 3DOF manipulator and if such a partial robot has another custom sim class, I'll copy-paste it too. Luckily, DefaultRobotHwSim covers all joint-specific controllers.

tahsinkose gravatar image tahsinkose  ( 2019-08-28 15:46:30 -0500 )edit