English is not my mother tongue, this page may contain incorrect words or sentences.
urriellu.net => Projects => Mechatronics => Tustra
Tustra is a robot made using the prebuilt parts of the skybot by ifara. The prebuilt pack includes a methacrylate structure, a free wheel, two wheels, two Futaba S3003 servos, motors control board and logic board (which includes the microcontroller and other sensor-related circuitry). This robot was built for a microbotics course given by the University of Oviedo where took place the robotics championship explained in the next section.
Championship rules
All the robots were built using the skybot kit and programmed in C language for the CCS compiler.
- Target: Leave the playground by a door painted on the floor
- Playground: Black circle, 80cm (31.5") diameter, surrounded by a 5cm (1.96") line
- Door edges are 3cm (1.18") thick lines placed at 25cm (9.84") one from each other. The robot should stop when hitting one of the vertical cylinders placed in front of the door.
- Getting out by the edges is valid but less valuable than crossing the door straightly
- Main mode -> single-elimination tournament:
- Two contestants will place their robots at a random place. The round ends when one of them leaves the playground by the door
- If after three minutes none of the robots were able to leave the playground the round will be null
- If a robot leaves by the edges, the other one will have available the whole round time (3 minutes) for leaving by the door, in that case being the winner
- If a robot leaves by the door but is not capable of detecting the stop vertical cylinders, the other one will be able to try it and win
- By this way one robot at a time will be eliminated until there is just one standing robot, which will be the winner of the competition
Videos
All remaining videos can be found at the championship page.
Application/firmware
Application written in C language for the PIC16F876A microcontroller, intended to be compiled by CCS PICC compiler. Some algorithms could be improved a lot but the rules were given to us just four hours before the championship (really!) and before that we knew almost nothing about them.
Around 230 lines (from a total of 270) were written within those last hours, at the same time the robot was tested, so considering the small time available and that I've never written a C application for a microcontroller, I think it is a good job.
The instructions at the beginning sets up the integrated peripherals and I/O pins of the microcontroller. After it the robots stands-by until one of the bumpers is pressed. When the bumper is activated the infinite loop at ModoBuscaSalida() begins, where the inputs from the CNY70 sensors are processed, detecting the color of the ground and configuring the state and direction of the wheels, so the robot will go straight until it detects the border of the playground, when it begins to follow the border until it finds the door or a bumper is pressed.
When a bumper is pressed the function Apartarse() is called and the robot begins to separate itself from the other robot: if it was traveling in straight line then it will separate itself to the side where there are no obstacles, but if Tustra was following the border of the playground then it will separate itself in the direction of the center of the playground, to avoid an infinite loop where it tries to avoid the obstacle and getting out of the ground at the same time.
When it's following the border of the playground it doesn't travel in a perfect straight line, it is turning a bit in the direction of the border. This is a neccesary problem: this behaviour allows the robot to detect the door but makes it follow the border of the ground very slowly because it is turning to it and then detecting it a lot of times per second. There was no enough time for adding an extra pair of CNY70 sensors, and with just two CNY70 the algorithm for detecting the door relies on this slight turn, so when it reaches the edges of the door it will turn enough to detect a white ground at the opposite side it was expected, so Tustra will then know that it has reached the door. Now ModoSaliendo() is called and the robot travels backwards a bit, then turns to the opposite direction of the door, travels a bit in straight line, turns again and then it can cross the door perfectly straight until it reaches the stop vertical cylinders.
Another problem asociated with this algorithm for detecting the door is that no other robot implemented an algorithm to separate from the rest of the robots, so another robot can push Tustra and/or make it turn causing it to detect a white ground at the wrong place and thinking it had reached the door (and therefore leaving the playground by the wrong place).
Note that just two of the contestant robots were able to detect the door (Tustra and Punky) and just Tustra was able to cross the door in a perfect straight line by the center of the door (and not by the edges) as it was specified in the rules. Playing the final round none of the referees took care of that rule, Punky got out by the edges and it wasn't penalized, so Punky won.
The source code is in spanish, sorry.
tustra.c, 269 lines [download]
- #include "tustra.h"
- //registros
- #byte PORTB=0x06
- #byte TRISB=0x86
- //pulsador
- #bit PULSADOR=PORTB.0
- #define Pulsado 0
- #define NoPulsado 1
- //LED
- #bit LED=PORTB.1
- #define LedActiv 1
- #define LedApag 0
- [...]
tustra.h, 5 lines [download]
- #include <16F876A.h>
- #device *=16
- #device adc=8
- #use delay(clock=20000000)
- #fuses NOWDT,HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
ProjectsElectronicsCLK³pic³progMechatronicsSoftwarePigmeoOthermabxArticlesElectronicsSoftwareOtherAdvantages of C#Events2nd (inter)Universitary Free Software ContestMicrobotics championship at the University of Oviedo. Summer 2007About urriellu.netThis websiteAbout mePublishing licensesContact
languageespañolrot13morse codebrailleenglishrot13morse codebraille