Differential Drive Fuzzy Controller for a Sumobot

A sumo bot competition

Fighting sumo bots (also known as Robot-sumo) is a tradition that pits two robots against each other in a ring with the goal of pushing the opponent out. These sort of competitions are geared for engineers wanting to test their prowess in object detection and intelligent controls. A few years ago I had the pleasure of helping a friend program, and test (play matador with) a 150 lbs aluminum and steel shin kicker, and I thought it would be a perfect project to get my feet wet with fuzzy controllers.

At the time of writing, this system has been developed and simulated in MatLab, but has not been implemented and tested in a real bot. Before we moved to debugging sensors and hardware, let’s cover the design of the Fuzzy Inference System (FIS) with MatLab’s “Fuzzy Logic Designer” package.  We can cover system response simulations, physical testing, and a robot matador video in a future post. This write up is not intended to be a tutorial on MatLab’s fuzzy toolbox, or an in depth explanation of Fuzzy Logic. However, these may both be topics for later.


Fuzzy logic systems are best used to give a human esque understanding to controllers to classify, or partially classify, different inputs. The goal is to have the designer’s intuitive understanding of a problem be described to the controller. In this case, we need to let the controller know what it “feels” like when an opponent is close to one side, or directly in front of our bot, etc… and what to do about it.

Starting out I realized I wanted to develop a FIS that would:

  • Take readings from eight infrared sensors each pointed 45 degrees apart.
  • Use the intensity of each sensor (read by a 10 bit ADC) to determine the relative location of an opponent.
  • Control a two wheel differential drive to turn to and push an opponent out of the ring.

Input and Output Membership Functions

For this design I chose to represent the input with three “linguistic variables” to represent how much light was being absorbed by a particular sensor (with a range of 0-1023 for a 10 bit ADC) . Open sigmoid functions were selected for the “Low” and “High” and a gaussian function  to represent the “Mid” range . The values were chosen to best reflect my experience and the responsiveness of the sensors, and is almost entirely based off of intuition. Each sensor has the exact same membership functions as shown in Figure 1.

Fuzzy logic membership functions for sumobot's eight infrared sensors.
Figure 1. Input Membership Functions

The output membership functions are placed on a scale of -500 to 500 to with values less than zero represent reverse rotation. Five triangular membership functions describe the speed and direction in terms of “Rabbit,”  “Turtle,” and “Stall” for fast, slow, and low wheel speeds respectively. Both wheel’s outputs are represented identically with the membership functions seen in Figure 2.

Fuzzy logic membership functions for sumobot's two wheel outputs.
Figure 2. Output Membership Functions

Rules and Defuzzification

With the membership functions defined, we need to let the system know how to respond to certain sets of input. Figure 3. contains the 17 rules used in this project. However, Matlab does not display these rules very clearly. So let’s try and gain an intuitive understanding of what these rules accomplish:

  • If all sensors are low then the bot should “Stall” until something is detected within range.
  • If sensors 2-6 detect a “High” or “Mid” then the bot should rotate to face the opponent.
  • As the bot moves to face the other bot it should begin to gain forward momentum while still turning to hit them straight on.
  • If the front facing sensor detects something then full steam ahead.
The fuzzy inference system rules for the sumobot project.
Figure 3. FIS Rules

To accompany these rules several different defuzzification techniques were tested to find which had the ideal response. It was decided that the centroid method gave the desired output.

Coming Up

The current simulations show this controller working exactly as designed/expected. Keep an eye out for a post on the analysis of this system. We will talk about how the infrared sensor array was modeled and describe how the wheels respond to changes. The current simulations already have several wonderful plots that describe how the velocity, angular velocity, and turning radius changes based on the relative location of the opposing sumo bot. I should have access to a simple two-wheeled differential drive bot that we can test this on, I just need to find some time to get it up and running!