Ask Your Question

Can't load custom controller

asked 2018-03-13 03:59:21 -0500

markovalexey gravatar image

I am learning ros_control and trying to create and use own controller. But controller spawner couldn't load it.

I created empty dumb controller:

namespace roscontrol_test

    class MyController : public  controller_interface::Controller<hardware_interface::PositionJointInterface>
        virtual bool init(hardware_interface::PositionJointInterface *hw, ros::NodeHandle &n) override
            return true;

        virtual void starting(const ros::Time & /*time*/) override {}
        virtual void update(const ros::Time &time, const ros::Duration &period) override {}
        virtual void stopping(const ros::Time& /*time*/) override {}


    PLUGINLIB_EXPORT_CLASS(roscontrol_test::MyController, controller_interface::ControllerBase);

I configure plugin.


<library path="lib/libmy_controller">
        <description>This is an example ros_control plugin.</description>


    <roscontrol_test plugin="${prefix}/controller_plugins.xml"/>

I also test that pluginlib can load this plugin:

int main(int argc, char** argv)
    pluginlib::ClassLoader<controller_interface::ControllerBase> controller_loader("roscontrol_test", "controller_interface::ControllerBase");

        auto controller = controller_loader.createInstance("roscontrol_test/MyController");
        ROS_INFO("Plugin loaded");
    catch(pluginlib::PluginlibException& ex)
        ROS_ERROR("Failed to load plguin");

    return 0;

And all is OK. Finally, I create simple robot and this is a YAML config:

  # publish all joint states
    type: joint_state_controller/JointStateController
    publish_rate: 50

  # position controllers
    type: position_controllers/JointPositionController
    joint: pan_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

    #type: position_controllers/JointPositionController
    type: roscontrol_test/MyController
    joint: tilt_joint

But I faced with error while loading:

[ INFO] [1520931242.427358562, 0.308000000]: Loaded gazebo_ros_control.
[INFO] [1520931242.500081, 0.380000]: Controller Spawner: Waiting for service controller_manager/switch_controller
[INFO] [1520931242.503352, 0.383000]: Controller Spawner: Waiting for service controller_manager/unload_controller
[INFO] [1520931242.506296, 0.387000]: Loading controller: joint_state_controller
[INFO] [1520931242.517501, 0.398000]: Loading controller: pan_joint_position_controller
[INFO] [1520931242.531252, 0.412000]: Loading controller: tilt_joint_position_controller

[ERROR] [1520931242.534222608, 0.415000000]: Could not load controller 'tilt_joint_position_controller' because controller type 'roscontrol_test/MyController' does not exist.
[ERROR] [1520931242.534263585, 0.415000000]: Use 'rosservice call controller_manager/list_controller_types' to get the available types

[urdf_spawner-4] process has finished cleanly
log file: /home/garrus/.ros/log/12367bb2-269c-11e8-8a6d-94de802129d7/urdf_spawner-4*.log
[ERROR] [1520931243.535656, 1.414000]: Failed to load tilt_joint_position_controller
[INFO] [1520931243.536768, 1.415000]: Controller Spawner: Loaded controllers: joint_state_controller, pan_joint_position_controller
[INFO] [1520931243.542771, 1.421000]: Started controllers: joint_state_controller, pan_joint_position_controller

Why controller spawner couldn't load controller, but I can load it manually by pluginlib?

edit retag flag offensive close merge delete


Did the comment below solve this issue for you, or was there another step you took? My ROS package depends directly on another package that contains a custom controller plugin, but the controller manager still can't find my controller type.

jdcarp19 gravatar image jdcarp19  ( 2019-10-11 17:00:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-01 16:44:11 -0500

AndyZe gravatar image

I've found that you need a depend on controller_interface in package.xml. Did you have that?

edit flag offensive delete link more


It's a bit hidden, but this is actually documented (here):

the [plugin] package must depend directly on the package containing the plugin interface

gvdhoorn gravatar image gvdhoorn  ( 2018-11-02 08:20:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-03-13 03:59:21 -0500

Seen: 855 times

Last updated: Nov 01 '18