ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

how to integrate kobuki auto docking command in roscpp or python

asked 2015-06-03 15:05:29 -0500

Anis gravatar image


I am using Turtlebot with Kobuki base. I would like to drive the robot to a goal position close enough to the docking station using C++ client in ROS, then when the robot reaches the goal, I would like to call the actionlib command that would take the robot to its docking station. I could not find any pointer to this. The only tutorial on ROS wiki I found only shows how to test autodocking by starting two launch files, but I could not find any way to code this either in python or C++.

Any help would be appreciated Anis

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2016-03-06 21:39:36 -0500

Steven_Daniluk gravatar image

I know this is an old question, but I thought I would post my answer since I just had to figure this out for myself.

In the above code the node for the action client, and the goal type are incorrectly defined. The node should be dock_drive_action and the goal type should be kobuki_msgs::AutoDockingGoal. Below is a working version of some code to call the docking action:

  // Create the client
  actionlib::SimpleActionClient<kobuki_msgs::AutoDockingAction> docking_ac("dock_drive_action", true);

  // Create goal object
  kobuki_msgs::AutoDockingGoal goal;

  // Assign initial state
  actionlib::SimpleClientGoalState dock_state = actionlib::SimpleClientGoalState::LOST;

  // Send the goal

  ros::Time time = ros::Time::now();

  // Monitor progress
  while (!docking_ac.waitForResult(ros::Duration(3))) {

    dock_state = docking_ac.getState();
    ROS_INFO("Docking status: %s",dock_state.toString().c_str());

    if (ros::Time::now() > (time+ros::Duration(10))) {
      ROS_INFO("Docking took more than 10 seconds, canceling.");
    }// end if
  }// end while

Hopefully someone can find this useful.

edit flag offensive delete link more


Someone found it useful! =D

Gonzalo Hernández R gravatar image Gonzalo Hernández R  ( 2016-04-29 04:06:40 -0500 )edit

how to make the kobuki to perform auto docking program automatically when it detects that the battery is low? then how to add that program to my current go to specific coordinate?

ejat gravatar image ejat  ( 2017-04-15 11:09:07 -0500 )edit

answered 2015-06-03 17:48:42 -0500

daenny gravatar image

Did you do all the tutorials from Also you might want to the the action-server, action-client Tutorial from the ROS wiki. They are a great start and there is actually a file which already does exactly what you want to do. Have a look at the script here:

That code sends the action to the Docking server and gives you a result if the docking was successful or not.

edit flag offensive delete link more

answered 2015-06-04 03:41:44 -0500

Anis gravatar image

updated 2015-06-04 03:42:35 -0500

Thanks for the pointers. Actually, I know and did all these tutorials. I wrote the following code

  actionlib::SimpleActionClient<kobuki_msgs::AutoDockingAction> ac("AutoDockingAction", true);
        kobuki_msgs::AutoDockingActionGoal goal;

        //wait for the action to return
        bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0));

        if (finished_before_timeout)
            actionlib::SimpleClientGoalState state = ac.getState();
            ROS_INFO("Action finished: %s",state.toString().c_str());
            ROS_INFO("Action did not finish before the time out.");

But I got a compilation problem in the line ac.sendGoal(goal);

In actionlib client tutorial, the same command above is used, but in my current example, did not want to compile. Is there any error in the code?

edit flag offensive delete link more


what is the error message when the code fails to compile ?

nickw gravatar image nickw  ( 2015-06-04 04:35:53 -0500 )edit

it gives an error message saying that sendGoal was called with different parameters as it must have three additional callback functions in parameters (doneCallback, feedbackCallback, statusCallback), but the problem is that the same function sendGoal works with one parameters in ROS tutorials.

Anis gravatar image Anis  ( 2015-06-04 12:55:18 -0500 )edit

Question Tools

1 follower


Asked: 2015-06-03 15:05:29 -0500

Seen: 1,894 times

Last updated: Mar 06 '16