dimensions:48 × 32 × 12 mm
weight:20 g (body 16g, cell 4g)
speed:0.7 ms-1 (line following)

PocketBot 2 the multi-robot system

PocketBot2 are matchbox-sized robots designed for batch production. They are equipped with an optical communication system that makes the robots ideal for testing multi-robot algorithms. PocketBot2 is based on the former PocketBot project. PocketBot2 brings new impressive features, though it still keeps all functions and properties of the previous version of the robot. Namely, the dimension constraints of 48 × 32 × 12 mm are preserved, so the robot fits exactly into a matchbox.

full HD version available on Vimeo

Features - overview

Cooperative Object Manipulation

Robots follow a line. An obstacle may appear on their track. One robot does not have sufficient power to push the obstacle away. However, when two robots cooperate, they are able to eject the obstacle out from their track.

This example shows how to coordinate movements of robots. Robots perform line following, until one of them reaches the obstacle. Then, the robot stops and wait for help. When second robot comes to the obstacle, the control program in host issues synchronized movement commands, so that both robots move simultaneously and push the obstacle away from track. Afterwards, robots continue in line following, avoiding collisions with each other.

Passing a Message

Three PocketBot2 robots ride on a round track marked with a black tape. Robots avoid collisions with each other. When two robots meet, they identify each other and exchange a message. One robot carries a message token. When it meets another robot, it passes the message to it. The robot which is currently carrying the message token has orange light on. As result, the message token (indicated by orange light) travels around the track. If there is an obstacle in way, robots will drive around it.


A double-sided printed circuit board stands as the robot’s chassis at the same time. Line sensors are placed on a smaller printed circuit board, witch is soldered underneath the main board. Robot has two propelled wheels and two sustaining points in front and rear. It is powered with a rechargeable Li-Pol battery (3.7V, 190mAh). A 10-pin connector offers JTAG and UART interface for programming and debugging.

The Atmel ATXmega128A3 microcontroller runs robot’s program, which is written in C.

Top view

PocketBot 2 top view with descriptions

Bottom view

PocketBot 2 bottom view with descriptions Undercarriage


Two separately driven wheels (9mm diameter) provide differential steering. Powerful motors from mini helicopter are used, which guarantees high speed performance. The dimensions of the gear mechanism were crucial due to considerable space constraints. The wheelframe employs a friction gear system with magnetic pressure. A neodymium magnet in the central tube attracts wheel axles, pressing each wheel to the motor shaft. The pressure can by adjusted by moving the wheel on its axle, i.e. by changing the distance of axle and magnet.

Optical encoders

On each wheel there is a metal cylinder, which is marked with 20 black stripes. A reflective photointerrupter sensor is placed above the cylinder and it provides 40 counts per wheel revolution. That gives an impuls per each 725μm of trajectory. In other words, the resolution of the encoder is 14 pulses per 1cm of trajectory. The odometry system ensures precise movement of the robot and it is used for localization. Optical wheel encoders - top view Optical wheel encoders - bottom view

Line sensor module

A guideline is marked with black PVC isolation tape. This material doesn't reflect infrared light so it is easy to distinguish a guideline by measuring the light reflection of the surface.

The sensor module consists of 4 detectors and 5 emitters. The emitters (infra-red LEDs) and detectors (phototransistors) are placed in a row alternately so that each phototransistor is surrounded with two IR LEDs. Thanks to this design it is possible to measure the surface reflectivity on eight spots under the sensor module, using only four phototransistors and five IR LEDs. Generally, this approach reduces the number of components and ADC inputs required for a line sensor module, which is desired with respect to dimension constraints.

The illustration bellow shows how this method works:

sensors_schema1.png, 2,9kB

LED1 is emitting infrared light that reflects to the phototransistor T1, hence the light reflectivity at point 1 is measured.

sensors_schema2.png, 3,0kB

Then, LED1 is turned off and LED2 starts emitting IR light. The phototransistor T1 measures the light reflectivity at point 2.

Ambient light suppression

Because light conditions often vary according to time and place, it is necessary to use an ambient light suppression algorithm for sensors to work properly. The method is simple: Every sensor does two measurements. At first, it scans for the amount of ambient light. Then, it turns its infra-red LED on and measures the value again. Subtracting these two values, the bias of ambient light is suppressed.

Line following

Optical sensors measure the light reflectivity of the surface and acquired data is processed by the line detection algorithm. The algorithm is designed in such a manner that line width doesn't matter. The line detection algorithm outputs signed integer value that states the actual deflection of a guideline. Values close to zero mean that the line is located accurately in the middle of the sensor module, positive values state how much does the line deflects to the right and negative values state the deflection to the left. This output is then used for proportional-integral-derivate (PID) control of the line tracking. The PID controller adjusts the wheels' speed according to the actual line deflection and previous states. The position of the line is evaluated 210 times per second.

Please note that the algorithm doesnt directly set PWM for the motors, it just calculate appropriate wheel speed. The wheel speed is then maintained by another PID regulator for each wheel separately. This approach brings better line following performance. On the top of it, the performance is not affected with battery state.

In other words, the PID controller drives the robot so that the line is always centered to the middle of the sensor module, so that the robot performs smooth line following.

Line color detection

PocketBot2 is equiped with an RGB color sensor. The sensor is placed on the bottom of the robot, next to line sensors. It recognizes the color of the surface. The RGB sensor is employed in line following. Difficult segments of the track can be marked in red, so the robot knows it had better to slow down. In the same manner, the straight segments can be marked with a blue tape, indicating that the speed can be increased safely.

Proximity sensor & short distance IR communication

Proximity sensors use modulated infrared light for detecting obstacles. There are two such sensors in the robot; front and rear. The front sensor has three directed IR leds, so it can detect whether the obstacle is on the left, right or in the center.

Furthermore, the proximity sensors have a second function; they provide short distance infrared communication between PocketBot2 robots. It means that robots can identify each other when they meet.


Bluetooth technology is used for wireless communication with a computer, cell phone and other robots. It ensures a wireless link between the robot and a control application.

The robot is equipped with a Bluetooth HCI module. The HCI Bluetooth module provides a baseband controller and link manager (i.e. the HCI module ensures only the radio layer for Bluetooth technology). That means that a Bluetooth stack must be implemented in the MCU of the robot. The LUFA BT stack by Dean Camera was used.

Although this approach to the Bluetooth implementation is much more complex than commonly used Bluetooth RS232 serial port adapter modules, it brings considerable advantages, such as broadcasting, forming piconets and scatternets, HID profile support etc..

Control application

PocketBot control application screnshot

PocketBot2 is supported with a PC control application. The application allows to access all robot's sensors and modules, providing live information about the state of line sensors, color sensor, battery voltage, acceleration and others. It also offers adjusting robot settings, such as PID constants, sensor calibration and line following attributes.

The application keeps track of robot position. The position is periodically updated according to data from wheel encoders. The trajectory of the robot is drawn on a white canvas.

Movement control

User may manually control the movement of the robot. It is possible to set the speed of each wheel, or to use more advanced system of movement control. The robot can perform three types of movement commands: straight movement, rotation movement and circular movement. User specifies the distance, speed, (angle, radius) and the robot performs requested action.

StraightMovement(speed_in_mps, distance_in_m);
RotationMovement(speed_in_mps, angle_in_deg);
CircularMovement(speed_in_mps, angle_in_deg, radius_in_m);

The movement commands are kept in queue and performed one by one, thus the programmer can compound these basic movements into a sequence. The movement commands are designed to be nonblocking, so the robot can perform other computations while it is moving.

PocketBot2 Java library

The backend of the control application is the PocketBotBTlib. This library provides a programmer with access to all facilities of the robot. It is responsible for discovering PocketBot2 robots and establishing the Bluetooth link to them.

The library is programmed in Java and it uses the BlueCove implementation of the JSR-82 bluetooth specification, which makes the control application platform-independent.


Before the PocketBot2 was manufactured, all its parts had been thoroughly tested on separate prototypes.

The prototyping had two stages. First prototypes proved the concept of an optical encoder, a color sensor, proximity sensors and other modules.

In the next stage, prototypes that conformed to the final design of the robot were built. These prototypes had (almost) same components, layout and circuit design as the final PocketBot2 robot. This allowed to develop and debug the software long before the actual PocketBot2 was manufactured. On the great day, when the first piece of PocketBot2 was assembled, I flashed the software to the robot and it just worked. It was amazing experience!

komplet.jpg, 87kB

Complete prototype of PocketBot2. The next step was to put all this into a matchbox.

PocketBot2 accessories

PocketBot2 with equipment

PocketBot2 is equiped with a battery charger and a USB docking station. These two utilities fit into another matchbox. As you can see, the whole PocketBot2 platform is packed in two matchboxes. A pocket robot indeed!

The battery charger can be powered from USB or from a DC wall adapter.

The USB docking station stands as a USB to serial converter. The serial interface is used for transmitting debuging messages and for flashing new firmware into the robot. There is a pre-flashed bootloader in the PocketBot2's microcontroller, which allows to flash new program without the need of an expensive JTAG programmer.

However, there is a common 10pin connector for JTAG and PDI onchip debugging as well.

Project timeline in brief

Material related to the PocketBot2 project

PocketBot 2, the robot's electronics, electrical scheme, PCB layout, gearing system, charger, dock station. Copyright © 2011 Ondřej Staněk

Ondrej Stanek


Ondřej Staněk (22) is the third-year student of the Computer science at the Faculty of Mathematics and Physics at Charles University Prague, the Czech Republic. He is interested in robotics, computer programming, electronics and system design. Author participates in the Umornik robotic team of Charles University. Moreover, he develops custom embedded systems, mainly for scientific purposes.

"I love challanges and I have great passion for detail."

www.ostan.cz, ostan89@gmail.com

published: 3. 12. 2011
© Ondřej Staněk

Software used: Eclipse Netbeans Eagle Eagle3D plugin PovRay AviSynth Gimp Dia Bluefish