Gazebo | Ignition | Community
Ask Your Question
0

Is it possible to create an action server in a Gazebo plugin?

asked 2020-03-12 08:18:37 -0500

546568303@qq.com gravatar image

I'm talking about ROS2 and GazeboROS here, but the question can extend to ROS1.

An excerpt of pseudo code would be

void MyPlugin::Load(gazebo::physics::ModelPtr model, sdf::ElementPtr sdf)
{
    ros_node_ = gazebo_ros::Node::Get(sdf);

    auto my_action_server = rclcpp_action::create_server<MyAction>(
        ros_node_->get_node_base_interface(),
        ros_node_->get_node_clock_interface(),
        ros_node_->get_node_logging_interface(),
        ros_node_->get_node_waitables_interface(),
        "my_command",
        std::bind(&MyPlugin::handle_action_goal, this, std::placeholders::_1, std::placeholders::_2),
        std::bind(&MyPlugin::handle_action_cancel, this, std::placeholders::_1),
        std::bind(&MyPlugin::handle_action_accepted, this, std::placeholders::_1));
}

My current finding seems to suggest that it is not possible to do so - Gazebo simply doesn't load this plugin if the action server is there.

edit retag flag offensive close merge delete

Comments

I can't see why not. What do you mean it doesn't load the plugin? Do you see any error messages in verbose mode?

chapulina gravatar imagechapulina ( 2020-03-12 11:43:53 -0500 )edit

@chapulina It simply doesn't. I can comment out the action server definition lines and see the plugin loaded and prints, but as long as these lines exist the plugin doesn't load and even debug message at the beginning of MyPlugin::Load() would not print.

546568303@qq.com gravatar image546568303@qq.com ( 2020-03-13 02:35:35 -0500 )edit

@chapulina Pushed a minimal example onto Github: https://github.com/AlanSixth/gazebo_r...

546568303@qq.com gravatar image546568303@qq.com ( 2020-03-13 02:50:01 -0500 )edit
1

@chapulina Oh I think I just fixed the problem. The reason was that I didn't add rclcpp_action as the dependency in CMakeLists.txt and somehow that caused the plugin loading to fail silently. Thanks a lot for helping though.

546568303@qq.com gravatar image546568303@qq.com ( 2020-03-13 03:04:56 -0500 )edit

Glad you could work it out! Feel free to add that as an answer and accept it so it can help others in the future.

chapulina gravatar imagechapulina ( 2020-03-13 22:40:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-15 00:48:34 -0500

546568303@qq.com gravatar image

It is possible. I have provided a minimal example here: https://github.com/AlanSixth/gazebo_r...

I had a problem before where the plugin containing an action server wouldn't load but I fixed the problem in the end. The reason was that I didn't add rclcpp_action as the dependency in CMakeLists.txt and somehow that caused the plugin loading to fail silently.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-03-12 08:18:37 -0500

Seen: 137 times

Last updated: Mar 15 '20