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

how to integrate kobuki auto docking command in roscpp or python

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

Anis gravatar image

Hello

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
3

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

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);
  docking_ac.waitForServer();

  // Create goal object
  kobuki_msgs::AutoDockingGoal goal;

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

  // Send the goal
  docking_ac.sendGoal(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.");
      docking_ac.cancelGoal();
      break;
    }// end if
  }// end while

Hopefully someone can find this useful.

edit flag offensive delete link more

Comments

Someone found it useful! =D

Gonzalo Hernández R gravatar image Gonzalo Hernández R  ( 2016-04-29 04:06:40 -0600 )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 -0600 )edit
0

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

daenny gravatar image

Did you do all the tutorials from http://learn.turtlebot.com? 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 coffe_bot.py script here:

https://github.com/markwsilliman/turt...

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
0

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

Anis gravatar image

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

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);
        ac.waitForServer();
        kobuki_msgs::AutoDockingActionGoal goal;
        ac.sendGoal(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());
        }
        else
            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

Comments

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

nickw gravatar image nickw  ( 2015-06-04 04:35:53 -0600 )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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,926 times

Last updated: Mar 06 '16