QQFLY.NET
← Writing

MarketBot: building a shopping-cart robot with ROS

In my introduction to ROS, I briefly mentioned a mobile robot we built in a month using ROS and other open-source tools. By 2018, the project was already two or three years old. I tend to think my old work is nothing special after about three months, so I had not been in a hurry to write about it.

Questions from readers changed my mind. Perhaps the process would still be useful to someone getting started.

This image had long served as the logo for my WeChat account:

The MarketBot logo and cart design

I had never properly explained where it came from. Readers of my early posts might remember an unusual competition, for which we built an unusual smart shopping cart called MarketBot:

The MarketBot prototype and planned features

Let's go through the slides and pretend this is a MarketBot launch event.

Hand baskets, wheeled baskets, and shopping carts

Supermarket baskets generally come in three forms: carried by hand, pulled along, or pushed as a cart. We were not particularly happy with the experience of the first two. So we built MarketBot 1.0:

Icons for MarketBot’s features

The icons I made in PowerPoint give an overview of its features.

Following a person

The person-following feature

What if a shopping cart followed us instead of making us push or pull it?

We fitted MarketBot with a Kinect and used the NITE 2 library for body-skeleton recognition:

Human-skeleton tracking with Kinect and NITE 2

A skeleton detector alone is not a tracker. We needed to avoid switching to another shopper, and to cope when our shopper briefly left the Kinect's field of view. Our simple motion model assumed constant acceleration with noise; a Kalman filter then tracked the person's position from the Kinect measurements.

We added Bluetooth to make tracking more reliable. Most shoppers already carried a smartphone, making it a convenient identifier. We initially hoped to estimate the distance between the shopper and MarketBot from Bluetooth RSSI. Here is what the tests looked like:

Measured Bluetooth RSSI against distance

The received signal generally weakened with distance, but the distance estimates were too unstable. We abandoned Bluetooth ranging and used a signal threshold to trigger an alert when the cart lost its shopper instead.

The cart normally followed about two meters behind, so the signal threshold was a reasonably reliable way to tell when it had lost its shopper.

The cart following a user

Recognizing gestures

Keeping a cart two meters away is not helpful when you want to put something in it. We added gesture recognition to switch between following mode and a loading mode.

Switching modes with gestures

This also used NITE 2's skeleton estimates. We calculated the angles of the shopper's arm joints, normalized the features, and trained a simple SVM classifier.

When MarketBot recognized the designated gesture, it switched modes, approached the shopper, and stopped so that items could be placed in the basket.

The cart approaching the user after recognizing a gesture

Moving around the supermarket

A cart that moves on its own needs a mechanism that can handle the supermarket floor and a way to avoid obstacles.

Mobility and obstacle-avoidance features

The mechanism could cross small obstacles such as gentle slopes and narrow gaps:

The cart crossing small floor obstacles

Ultrasonic sensors detected obstacles it could not cross, such as walls and steps, so the cart could avoid them:

The cart avoiding an obstacle it cannot cross

Keeping a running total

It is useful to know how much you are spending before reaching the checkout. We therefore added barcode scanning and a running price total.

Barcode recognition and price calculation

We could have bought a barcode scanner. To save money, we used an ordinary camera and the open-source ZBar project instead. ZBar identified the product code, which we looked up in a database to obtain the price.

For the display, we again chose the inexpensive route: an STM32 microcontroller and a seven-segment numeric display.

Scanning a barcode and displaying the price

A self-checkout demonstration

Queues at supermarket checkouts

Once MarketBot knows the total, it is tempting to let trusted customers pay for themselves and avoid the checkout queue. For the demonstration, I simply used my own payment QR code as a stand-in.

A payment-code illustration from the historical prototype

The entire project, including the hardware, had been completed in one month. There was obviously plenty left to improve.

Ideas for later versions

Return to the overview slide:

Ideas for later MarketBot versions

We had also sketched possible future versions. These were plans, rather than additional features of the prototype:

  • MarketBot 1 Plus: a phone app to handle interactions such as Bluetooth pairing and payment. It seemed simple enough—apart from needing someone to write it.
  • MarketBot 1S: automatic charging, as already found in robot vacuum cleaners. We expected this to reduce the effort of managing carts in a supermarket.
  • MarketBot 1S Plus: autonomous navigation with a laser scanner, allowing the robot to guide a shopper directly to a desired product.

We had considered cheaper navigation approaches as well:

  1. Following TurtleBot's approach, use ROS's depthimage_to_laserscan to take a slice of Kinect depth data at a chosen height and turn it into a two-dimensional scan. In our tests, the accuracy was disappointing.
  2. Use RGB-D SLAM. Unfortunately, the 800-yuan computer we had bought to save money could not handle it.

At that point, I was ready to declare that I would never work on SLAM. Ever.

What the project taught us

By 2018, none of this looked particularly remarkable to me. But the project still showed how much open-source tools can speed up development for someone getting started.

Those tools were only part of the explanation. Without capable teammates handling hardware and communications, we could not have built it in a month.

By 2018, NITE 2's body tracking could not compete with deep-learning methods such as OpenPose. If you're doing research, you still need to keep up with the literature.

An example of human-pose detection with OpenPose

Incidentally, that logo is animated:

The animated MarketBot logo

Here is a short video of the project:

Watch the video in the original article ↗

← Writing