Ball Tracking Example
This example shows how to control a basic Robotic System using a Desktop Computer, a Kinect and an Arduino. As an example, this Robotic System will track a green ball by trying to keep it in the center of the Kinect's field of view and at a particular distance.
Three examples are provided, showing how to use MATLAB and Simulink to control the robotic system. Each method has its advantages and disadvantages. The first example uses MATLAB manage the robotic system without any code generation. The second and third examples show how to generate an executable out of MATLAB and Simulink code.
- Hardware Layout
In this Robotic System, there are five major components that I am using:
- Microsoft Kinect for Windows to acquire color and depth video, which is sending data to a laptop using a USB cable. This Kinect takes the place of a camera and LIDAR in a typical mobile robotic system.
- Standard laptop to perform high-level processing.
- Lynxmotion Rover chassis which includes DC Motors
- Arduino Mega 2560 without an Ethernet Shield for the first example, and with an Ethernet Shield for the second and third examples. The first example simply connects the Arduino to the Laptop using a USB Cable. The second example connects the Arduino and Ethernet Shield to the laptop using an Ethernet Cable. The Arduino receives motor commands from the laptop and sends motor commands to the Sabertooth Motor Controller using one of the digital pins and jumper wires.
- Sabertooth Motor Controller receives a motor command from the Arduino, and sends a PWM with the necessary current to the motors
The provided functions and models have been configured for the Arduino Mega 2560 with pins D47 and D46 controlling the left and right motors, respectively.
There are three examples that are shown:
- MATLAB on the host with MATLAB Support Package for Arduino
- MATLAB on the host with Simulink Target for Arduino
- Simulink on the host with Simulink Target for Arduino
All of the examples perform the same task, find the green ball using the Kinect's color and depth data and maintain the ball in the center of the Kinect's field of view at a specific distance from the Kinect.
The Kinect's view and data related to the ball's position and resulting control commands are overlaid onto the video feed and displayed. Here is an example of the Kinect's Video Player.
MATLAB on the host with MATLAB Support Package for Arduino
MATLAB on the host with Simulink Target for Arduino
Simulink on the host with Simulink Target for Arduino