A Tic Tac Toe robot using ABB ARM Robot controlled by Node.JS
Watch the video:
- An ABB Robot
- An Arduino board with Bluetooth and a Light Sensor
- An Computer, connected to ABB Robot through Ethernet cable
Files: components/ABBRobot.js
and ABBNator.txt
;
ABB Robots provide us with RAPID
programming language. That language, allows
us to use Sockets
and also FTP
.
For a matter of simplicity, and also facility, we opted to use FTP
as the
data exchange format.
The code running in the ABB is the ABBNator.txt
. It basically waits for
a given file (In this case, /hd0a/abbnator/target.txt
), and reads it.
The file contains the speed, x, y and z params for the MoveL
instruction.
Here is the format:
// Protocol:
<SPEED>:<X>|<Y>|<Z>;
// Example (Go to [50, 120, 340] with speed 200):
200:50|120|340;
After executing the action, ABBNator
will remove the file in order to notify
any system using the FTP to know that "the action has been completed".
Files: components/SerialSensor.js
and components/SerialConnection.js
;
The sensor used was a simple infrared light sensor, connected to a servo motor to raise and lower the sensor.
The connection with the Arduino used a (really) simple protocol:
- Send character
A
: Activates the motor (lower) - Send character
I
: Deactivate the motor (raise) - Send character
S
: Reads the analog sensor value and sends back
In Node.JS, the library serialport
was used to have access to the stream
of
data from and to the bluetooth port.
File: components/TicTacToe.js
;
Using Minimax
algorithm.
It will never loose, but it can end in a draw. You can look at the file
components/TicTacToe.js
for that.
Files: RealGame.js
and components/GameController.js
;
Dig in the code, you will get the idea ;)