Archived-OR / osprey_ros

UNF Osprey Robotics Club ROS implementation for NASA Lunabotics Remote Mining Competition Robots
Apache License 2.0
0 stars 1 forks source link

Fix Gazbo Ros2 Control Plugin #1

Open wltjr opened 7 months ago

wltjr commented 7 months ago

There are some issues with loading the Gazebo Ros2 Control Plugin, Gazebo startup may have to be moved into the same launcher with the rest of the robot. Based on settings in ros2_control.xacro , either the robot itself fails to start, or gazebo has errors, no way to get both to play nice yet...

Using the following configuration

            <hardware>
                <plugin>mock_components/GenericSystem</plugin>
            </hardware>

        <plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
            <robot_param>robot_description</robot_param>
            <robot_param_node>robot_state_publisher</robot_param_node>
            <parameters>$(find osprey_ros)/config/robot_controllers.yaml</parameters>
        </plugin>

Gazebo produces the following error

[gzserver-1] [ERROR] [1705952003.775934601] [gazebo_ros2_control]: The plugin failed to load for some reason. Error: According to the loaded plugin descriptions the class mock_components/GenericSystem with base class type gazebo_ros2_control::GazeboSystemInterface does not exist. Declared types are  gazebo_ros2_control/GazeboSystem

If you change the hardware to

            <hardware>
                <plugin>gazebo_ros2_control/GazeboSystem</plugin>
            </hardware>

Then the robot fails to start with

[ros2_control_node-1] terminate called after throwing an instance of 'pluginlib::LibraryLoadException'
[ros2_control_node-1]   what():  According to the loaded plugin descriptions the class gazebo_ros2_control/GazeboSystem with base class type hardware_interface::SystemInterface does not exist. Declared types are  fake_components/GenericSystem mock_components/GenericSystem robot_hardware_interface/RobotSystemHardware

At the moment, no way to use both. Changing the name element of the plugin tag does not seem to have any impact, but there might be some relation there.

wltjr commented 7 months ago

The server crashes with the same error as mentioned in the initial issue if the following line is changed to

<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control::GazeboSystemInterface">

It seems commenting it out entirely makes all errors go away and might be the correct solution, no gazebo tag with plugin tag, etc; removing the following from ros2_control.xacro

    <gazebo>
        <plugin>
         ...
        </plugin>
    </gazebo>