The Kobuki charger costs an extra $49 when you buy the Deep Learning Robot and is well worth throwing into the package. With a few simple commands you can get your robot to dock and recharge itself, providing it is in the general vicinity of the charging station. The following is adapted from the Kobuki / ROS tutorials.

Here’s a video of docking place in my crowded living room. Please forgive the baby noises:

The official advice is to fasten the dock to a wall with at least 2m space (1m either side I suppose) and 5m empty space in front. That’s actually larger than most rooms in my current house. In any case you’ll have to navigate the robot manually or autonomously to a spot reasonably close to the charger, then you send a message to the Kobuki which takes over.

As usual, ssh into the robot and bring up the basic Turtlebot nodes:

roslaunch turtlebot_bringup minimal.launch

In a second ssh window into the robot, launch the auto-docking action server:

roslaunch kobuki_auto_docking minimal.launch

This node (called “dock_drive”) will listen out for action clients that send it a command to dock. The server will then manage the whole process of docking over time. Commands are listened for on the topic /dock_drive_action/goal and feedback is sent on the current status via /dock_drive_action/feedback. A one-off command is sent once the dock is reached on the topic /dock_drive_action/result.

To launch an action client, open a third ssh window onto the robot and type:

roslaunch kobuki_auto_docking activate.launch --screen

You will see a stream of messages in this window as the action server sends the client feedback on the status of the goal:

Goal: Sent. Feedback: [DockDrive: SCAN]:  Feedback: [DockDrive: SCAN]: … Feedback: [DockDrive: FIND_STREAM]: Feedback: [DockDrive: FIND_STREAM]: … Feedback: [DockDrive: GET_STREAM]: Feedback: [DockDrive: GET_STREAM]: … Feedback: [DockDrive: SCAN]: Feedback: [DockDrive: SCAN]: … Feedback: [DockDrive: ALIGNED]: Feedback: [DockDrive: ALIGNED_FAR]: … Feedback: [DockDrive: ALIGNED_NEAR]: Feedback: [DockDrive: ALIGNED_NEAR]: … Feedback: [DockDrive: ALIGNED_NEAR]: Feedback: [DockDrive: BUMPED]: Feedback: [DockDrive: BUMPED]: Feedback: [DockDrive: BUMPED]: Feedback: [DockDrive: BUMPED]: Feedback: [DockDrive: BUMPED_DOCK]: Feedback: [DockDrive: DOCKED_IN]: Result – [ActionServer: SUCCEEDED]: Arrived on docking station successfully.

 

How It Works

For details of how this works from a mechanical / electronic point of view, see the “How it Works” section here.

To understand the software side of things, try monitoring the topics connected to the dock_drive server node.

The dock_drive node listens on the dock_drive_action/goal topic for a command telling it to dock. To see this, move the robot off the dock (pick it up or use the teleop node) and before running the activate.launch command again, open yet another ssh window and monitor the goal /dock_drive_action/goal:

rostopic echo /dock_drive_action/goal

When you run the docking command again

roslaunch kobuki_auto_docking activate.launch --screen

you’ll see something like the following appear on the /dock_drive_action/goal window:

header:    seq: 1   stamp:      secs: 1458390791     nsecs: 819741964   frame_id: ” goal_id:    stamp:      secs: 1458390791     nsecs: 819670915   id: /dock_drive_client_py-1-1458390791.820 goal:  —

That’s a ROS message telling the Kobuki to dock and it’s pretty much all boilerplate. To call the goal from your own Python nodes, checkout the activate.launch source code, in particular the dock_drive_client() method.

Try again and this time monitor the feedback messages using

rostopic echo /dock_drive_action/feedback You’ll see a stream of messages along these lines: header:    seq: 4729   stamp:      secs: 1458392034     nsecs: 14848733   frame_id: ” status:    goal_id:      stamp:        secs: 1458392029       nsecs: 477123022     id: /dock_drive_client_py-1-1458392029.477   status: 1   text: This goal has been accepted by the simple action server feedback:    state: ALIGNED_NEAR   text: ” —

The only piece that matter is the state variable near the bottom.

Finally, for completeness sake, let’s repeat and this time monitor the /dock_drive_action/result topic:

rostopic echo /dock_drive_action/result You’ll see one message only, once the robot docks: header:    seq: 5   stamp:      secs: 1458392306     nsecs: 796196334   frame_id: ” status:    goal_id:      stamp:        secs: 1458392286       nsecs: 354389905     id: /dock_drive_client_py-1-1458392286.354   status: 3   text: ” result:    text: Arrived on docking station successfully. —

This system of having a server a node that accepts a goal on one topic, manages it over time while sending feedback over another and sending a final result on completion via a third is a common pattern in ROS.