Difference between revisions of "LionHell McMillan"

From AIRWiki
Jump to: navigation, search
(Created page with "{{Project |title=CrickBot |coordinator=GiuseppinaGini |tutor=MicheleFolgheraiter |students=VittorioLumare; |resarea=Robotics |restopic=Robot development; |start=2006/09/10 |...")
 
m
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Project
 
{{Project
|title=CrickBot
+
|title=LionHell McMillan
 
|coordinator=GiuseppinaGini
 
|coordinator=GiuseppinaGini
|tutor=MicheleFolgheraiter
 
 
|students=VittorioLumare;  
 
|students=VittorioLumare;  
 
|resarea=Robotics
 
|resarea=Robotics
 
|restopic=Robot development;  
 
|restopic=Robot development;  
|start=2006/09/10
+
|start=2011/09/10
|end=2007/07/27
+
|end=2012/07/20
 
|status=Closed
 
|status=Closed
|level=Bs
+
|level=Ms
 
|type=Thesis
 
|type=Thesis
 
}}
 
}}
  
''Questo documento contiene materiale proveniente da fonti esterne:''
 
''1 [ [http://venomyeah.altervista.org/robotgarage/index.php/Robot_Grillo Documento Originale] - Autore: Vittorio Lumare -  [http://www.robotgarage.org Sito Riferimento] ]''
 
  
----
+
LionHell McMillan is an ''All Terrain Wheg Robot with Morphological Computation''
  
 +
It has been developed in a Master Thesis work in Robotics and Artificial Intelligence and it has been modified and improved in a Master Thesis work in Robotics and Artificial Intelligence by Alessandro Rosina ( http://airwiki.ws.dei.polimi.it/index.php/LionHell_McMillan_II ) , changing the name from "LionHell McMillan" to "LionHell McMillan II".
  
 +
Info about Thesis
 +
TItle : '''All Terrain Wheg Robot with Morphological Computation'''
 +
Robot Name: ''LionHell McMillan''
 +
Correlator: Giuseppina Gini
 +
Author: Vittorio Lumare
 +
Area: Robotics and Artifical Intelligence
 +
Start date: 2011/09/10
 +
End date: 2012/07/24
  
'''Robot Mobile con Controllo Neurale Bioispirato al Grillo Bimaculato.'''
+
{{#evp:youtube|QbMM9orBUn0|LionHell McMillan ROBOT - Walking on Rough Terrain|center|600}}
  
E' possibile vedere dei video che mostrano il suo movimento a quest'indirizzo : [http://www.youtube.com/watch?v=sXdNOFMBreM].
+
==The Idea==
 +
===Starting Point===
 +
The new locomotion system called [http://venomyeah.altervista.org/robotgarage/index.php/Wheg Wheg] (Wheel + Leg) enable mobile robots to move on rough terrains, using a simple control system  .
  
 +
===Objective===
  
 +
The project objective is to test the wheg system , in order to find a design (both of  robot, both of whegs) able to give the best agility on rough natural terrains.
  
==Idea==
+
==State of The Art==
===Punto di Partenza===
+
* [http://biorobots.cwru.edu/projects/whegs/ Whegs I]
 +
* [http://biorobots.cwru.edu/projects/whegs/ Whegs II]
 +
* [http://biorobots.cwru.edu/projects/whegs/ Autonomous Whegs II]
 +
* [http://biorobots.cwru.edu/projects/whegs/ Mini Whegs I]
 +
* [http://biorobots.cwru.edu/projects/whegs/ PROLERO]
 +
* [http://en.wikipedia.org/wiki/Rhex RHex]
 +
* [http://worldwide.espacenet.com/publicationDetails/originalDocument?CC=EE&NR=05283B1&KC=B1&FT=D&date=20100415&DB=EPODOC&locale=en_EP Ratasjalg]
 +
* [http://airlab.elet.polimi.it/index.php/EMBOT EMBOT]
  
[[file:grillo_bimaculato.jpg|right]]
+
==Simulations / Design==
Lo scopo di trovare il luogo in cui si trova un oggetto, senza sapere nulla riguardo alla sua
+
===Simulation 1===
posizione, nè rispetto a sè nè rispetto ad altri punti di riferimento, ma basandosi unicamente sulle
+
The first robot model has been taken from an existent robot : [http://airlab.elet.polimi.it/index.php/EMBOT EMBOT]
sensazioni istantanee, è e sarà sempre uno dei compiti più comuni e importanti per qualsiasi entità
+
mobile autonoma, vivente o non vivente che sia.
+
  
Quando poi è uno solo il senso che puo' aiutare a muoversi nella direzione giusta, bisogna avere la
+
This is a video of the first simulation with this model
massima fiducia in esso e quindi una grande padronanza nell'utilizzarlo.
+
  
Il grillo bimaculato è un esempio di come la natura sia riuscita a creare un sistema che assolve a
+
{{#evp:youtube|3aurAnj120Q|First simulation|center|400}}
questo compito in maniera piu' che soddisfacente e senza spreco di risorse.
+
  
Non c'è dubbio che il grillo abbia molto interesse a saper trovare l'oggetto della sua ricerca, in
+
As can be seen from simulation, robot model is unsuitable to the task.
quanto è il suo partner, e senza di esso non potra riprodursi: per lui trovarlo è di importanza vitale.
+
Fortunatamente il partner emette un suono intorno ai 4.7 KHz come richiamo, il che permette al
+
grillo di sfruttare l'udito per farsi un'idea di dove esso sia.  
+
  
Avvalendosi dell'udito il grillo comunque sfrutta solo una parte limitata delle informazioni
+
The model has been then improved extending the body length of about 5 cm.
trasportate dal suono, ed essendo un insetto possiede un apparato cerebrale tale da permettergli
+
un'elaborazione molto ridotta delle informazioni acquisite.
+
  
===Obiettivo===
+
===Simulation 2===
  
L'obiettivo del progetto Robot Grillo è stato replicare il sistema del  grillo su un sistema robotico e verificarne il
 
funzionamento valutando le prestazioni e i comportamenti assunti dal robot.
 
  
 +
Second simulation:
  
==Stato dell'Arte==
+
{{#evp:youtube|Ffu8eFY3Tug|Second simulation|center|400}}
  
 +
Now robot is able to climb all the steps, but this is not enough.
 +
The objective is harder: we want the robot to climb obstacles big as its body size, so I made another simulation  with bigger obstacles:
  
[[file:kephera.png|200px|right|thumb| Robot Khepera con due microfoni]]
+
{{#evp:youtube|_95LjvVVByw|Third simulation|center|400}}
Il progetto del Robot Grillo è basato sui lavori precedentemente svolti dalla Prof.ssa Barbara Webb e altri
+
<ref>Richard E. Reeve, Barbara H. Webb, “New neural circuits for robot phonotaxis”, 2003, University of Stirlin. </ref>
+
<ref>A.D. Horchler, R.E. Reeve, B.H. Webb, R.D. Quinn, “Robot Phonotaxis in the Wild: a Biologically Inspired Approach to Outdoor Sound Localization”, 2003, Stirling University. </ref>
+
.
+
  
 +
Despite its longer body, the robot is unable to climb over the step.
  
Il robot utilizzato nello studio iniziale della Prof.ssa Barbara Webb <ref>Barbara Webb “Phonotaxis in crickets and robots”, [http://homepages.inf.ed.ac.uk/bwebb/cricket/ ]</ref> era un Khepera, su 2 ruote differential drive.
+
This happens because it has no support in the back: when the back wheg (we see only
 +
one back wheg because of the 2D simulation) rotates, the mechanical support of the
 +
servomotor is the robot chassis, which starts rotating clockwise, making the robot
 +
falling backwards.  
  
Possiamo vedere il robot Kephera nella foto qui a destra.
+
The solution to this problem is to avoid the chassis rotation.  
  
 +
How to avoid the chassis rotation?
  
 +
A simple approach is to add a '''fixed link''' in the back ,
 +
such a kind of '''tail''', so that when the chassis starts rotating clockwise , the tail will touch the ground surface '''blocking the rotation'''.
  
 +
===Simulation 3===
  
 +
New Model:
 +
 +
* New central wheg
 +
* New link added to body
 +
* Joint in the body center
 +
* Tail added to the back
 +
* Wheg foot design improved to give better grip
  
 +
{{#evp:youtube|IVa5XNEc3KA|Fourth simulation|center|400}}
  
 +
As we can see , the robot is able to walk on very rough surface terrain.
  
 +
He goes on even in presence of high surface spikes, thing that would have been not
 +
possible for the previous robot model.
  
 +
This better behavior is principally due to the
 +
new central wheg added to the model, and to the slight body flexibility, due to the
 +
action of a spring and a damper in the body center.
  
 +
Thanks to the '''tail action''', robot '''never falls on his back'''.
  
 +
==The Real Robot==
  
 +
===First Prototype===
  
 +
[[file:lionhell_v1.jpg|600px|LionHell First Prototype]]
  
  
  
==Teoria==
 
===Phonotaxis===
 
  
La Phonotaxis è la capacità di determinare la direzione di provenienza di un suono, ed esistono piu'
 
modi per farlo utilizzando due sensori acustici (microfoni) montati alla stessa altezza, sfasati
 
orizzontalmente, ed entrambi proiettati nella stessa direzione ma sfasati radialmente.
 
  
Un sistema è quello di sfruttare la differenza di intensita sonora  tra i segnali rilevati dai due
 
sensori, dovuta al fatto che sono distanti tra loro e orientati diversamente, ed è chiamato Interaural
 
Level Difference (ILD), un altro sistema si basa sul diverso tempo di arrivo del suono ai due
 
sensori, Interaural Time Difference (ITD), dovuto solo alla distanza tra loro.
 
  
[[file:apparato_sensoriale_uditivo_grillo.png|400px|thumb|right|Apparato Sensoriale Uditivo del Grillo Bimaculato]]
 
  
Del suono il grillo determina la direzione basandosi su un effetto chiamato Interaural Phase
 
Difference (IPD), che consiste in cancellazioni di fase del suono ottenute grazie ad una struttura
 
tubolare molto particolare <ref>Richard Reeve, Andr´e van Schaik, Craig Jin, Tara Hamilton,Ben Torben-Nielsen,
 
Barbara Webb, “Directional hearing in a silicon cricket”, 2006, Elsevier, BioSystems</ref>.
 
  
L'apparato sensoriale uditivo del grillo consta di una parte sinistra e di una destra, simmetriche
 
fra loro, ciascuna costituita da un tubo tracheale che porta il suono fino al timpano, l'elemento
 
"trasduttore".
 
  
Quando il suono arriva diritto  verso l'apertura sinistra, il timpano sinistro riceve il
 
suono alla  massima  intensità,  quando il suono arriva da un'altra direzione,  avvengono
 
cancellazioni di fase e il suono è fortemente attenuato, idem per l'apparato destro.
 
  
Questo fa sì che il suono che arriva frontalmente al grillo, con uguale inclinazione tra apertura destra e apertura
+
===Final Prototype===
sinistra, venga rilevato attenuato da entrambi i timpani e quindi senza differenza tra destra e
+
sinistra; quando il suono invece proviene piu' da una direzione che dall'altra avremo un timpano
+
che riceve un suono piu' elevato rispetto all'altro timpano: la direzione del suono è stabilita. 
+
  
La determinazione della direzione è quindi possibile per il grillo grazie al sofisticato apparato
+
[[file:lionhell_v2.jpg|600px|LionHell Final Prototype]]
sensoriale acustico di cui è dotato.
+
  
La successiva elaborazione del segnale è espletata da una rete neurale molto semplice, ma che permette al grillo di reagire adeguatamente a cio' che sente,
+
=Hardware=
evitare eventuali ostacoli di fronte a lui e infine di raggiungere il luogo di provenienza del suono.
+
  
 +
In this section all the hardware components will be illustrated, excluding structure
 +
because it was yet discussed in the previous chapters.
  
 +
==Servomotors==
 +
[[file:dynamixel-ax-12a.jpg|right]]
  
 +
In this robot the '''servomotors''' are the only actuators.
  
 +
These servos have been taken from a '''Robotics kit''' called '''Bioloid''', commercialized by
 +
'''Robotis'''.
  
 +
The servomotor model is '''Dynamixel AX-12'''.
  
 +
Dynamixel servos are very versatile, quite strong and can be used in '''two modes''':
  
 +
* ''Continuous Rotation mode''
 +
* ''Position mode''
  
 +
The only limit of these servos causing some problem in this work is a '''60° dead-band '''.
 +
When motor shaft falls in this range, '''position''' is '''not retrievable''' from the '''internal potentiometer''' .
 +
This was a '''problem''' in continuous rotation mode, because I could not control the servo '''position''' in that range.
 +
This '''limit''' avoided me to '''synchronize''' all the six whegs to obtain a perfect control in climbing over obstacles.
 +
In fact I ended up with a simple open-loop motor control.
  
 +
The other 3 servos were used in Position Mode:
 +
*Two servos for the '''body joint''' in the center of robot
 +
*One servo for the '''tail'''
  
 +
Illustration 42: Servomotor - Dynamixel AX-12
  
===Sistema di Elaborazione Neurale===
+
Table 1: Servomotor - Dynamixel AX-12
[[file:neural_net_phonotaxis.png|300px|thumb|right|Rete Neurale per Phonotaxis]]
+
  
Il sistema da noi sviluppato utilizza una Rete Neurale che assolve al compito di elaborare i
+
In this case the dead band did not cause any problem, because a 180° movement was sufficient for the purpose.  
dati in ingresso dai sensori e fornire in uscita i dati di comando ai motori.
+
  
Questa soluzione è stata già ampiamente utilizzata in molti sistemi di robotica mobile.
+
I had to use '''two servos''' for the '''body joint''', because of the '''high torque''' needed to move the head and the frontal pair of whegs.
 +
At a first time I tried to use one servo, but it was subject to overheating, until it burned.
 +
Using two servos in '''parallel''',  ''mechanically coupled'', permitted a perfect control of the joint, without overheating.
  
La rete che vediamo in figura è stata usata per pilotare il Cricket Robot da Webb <ref>Richard E. Reeve, Barbara H. Webb, “New neural circuits for robot phonotaxis”, 2003, University of Stirlin. </ref> .  
+
==Control Board==
 +
[[file:cm510.png|right]]
 +
The '''central processing unit''' used is a ''CM-510''.  
  
Questo tipo di rete sfrutta i 2 ingressi dai microfoni per decidere quanta potenza dare ai due motori
+
It’s a development board producted by Robotis, and its fully compatible with
del differential drive, il tutto sfruttando solo 4 collegamenti neurali, 2 eccitatori e 2 inibitori.  
+
''Dynamixel AX-12'' '''servos'''.  
 +
 +
'''CM-510'''
 +
 +
Weight 51.3g
 +
Controller ATMega2561
 +
Working Voltage
 +
  Allowed Range : 6.5V ~ 15V
 +
  Recommended Voltage : 11.1V (Li-PO 3cell)
 +
Consumed Current
 +
  When IDLE : 50mA
 +
  External I/O Maximum Current : 0.9A
 +
  Total Maximum Current : 10A (Fuse)
  
Questa rete è stata successivamente ampliata <ref>Richard E. Reeve, Barbara H. Webb, “New neural circuits for robot phonotaxis”, 2003, University of Stirlin. </ref>, aggiungendo 2 neuroni, ON1 e ON2 e delegando a loro il compito  di incrociare i segnali inibitori.
+
Table 2: Control Board – CM-510
  
I due neuroni nuovi, come vediamo in figura, oltre a incrociare il segnale sonoro verso i neuroni motori, si inibiscono tra loro con altri 2 collegamenti inibitori.
+
Illustration 43: Control Board - CM-510
  
Questa reciproca inibizione fa sì che la normale differenza del segnale inviato ai motori venga accentuata, infatti l'inibizione reciproca favorisce il neurone ON che in
 
quel momento è più attivato inibendo l'altro.
 
  
L'attivazione neurale viene sbilanciata fortemente a favore del neurone che già era più attivo.  
+
This board is featured with standard '''Dynamixel ports''', plus 6 other '''general purpose
 +
ports'''.  
  
 +
Each general purpose port is featured with 4 usable '''pins''':
 +
* Ground
 +
* Power (5V)
 +
* Digital I/O
 +
* Analogue Input (0V– 5V)
  
 +
I used these ports to connect all '''peripheral sensors'''.
  
 +
Since I had too many sensors for the available ports, I had to built '''two multiplexer
 +
boards''':
 +
* One board to multiplex 4 rangefinders
 +
* One board to multiple 3-axis accelerometer
  
 +
The boards inputs have not been fully used, so there are '''available channels''' for an
 +
eventual '''future use'''.
  
 +
==Sensors ==
  
 +
The most critical aspects of perception in this robot are:
 +
* Terrain sensing.
 +
* Robot inclination with respect to gravity force vector.
  
  
  
  
 +
===Multiplexer Boards===
  
 +
I designed and builded two multiplexer boards: one for the IR-rangefinders , one for the 3-axsis-accelerometer.
  
 +
The board below multiplexes the analog signal from each of the four used IR Sharp Rangefinders, in order to use a single analog input on the CM-510 Board.
 +
[[file: Rangefinders_Multiplexer_Board.jpg]]
  
  
  
==Implementazione==
+
The board below multiplexes the analog signal from each accelerometer channel, in order to use a single analog input on the CM-510 Board.
===Hardware===
+
====Il Robot====
+
[[file:robot_grillo.jpg|500px|thumb|right|Il Robot Mobile "Grillo" realizzato]]
+
  
Per il sistema che abbiamo sviluppato è stato scelto di usare due microfoni direzionali come
+
[[file: Accelerometer_Multiplexer_Board.jpg]]
sensori acustici, una barriera di sensori a infrarossi per rilevare gli ostacoli e un sistema di
+
locomozione differenziale su ruote.
+
  
La struttura del robot è di forma cilindrica , diametro 32 cm altezza circa 20 .
 
  
La gestione del funzionamento dei sensori a infrarossi e dei comandi ai motori è stata affidata ad un
 
microcontrollore PIC18F4431 <ref>Microchip PIC18F4431, “PIC18F2331/2431/4331/4431 Data Sheet”, Datasheet number:
 
39616b, http://www.microchip.com</ref>, programmato in C.
 
  
Esso controlla interamente l'apparato di prossimità a infrarossi, mentre si occupa solo di una parte del sottosistema motori. I motori sono
+
For time reasons I've implemented both boards quickly by manually building the circuit tracks.
infatti pilotati dal PIC, ma l'erogazione di energia elettrica necessaria a muoverli è regolata da una
+
scheda dedicata con circuito H-bridge su integrato L298 <ref>STMicroelectronics, “L298 Dual Full-Bridge Driver” Datasheet, http://www.st.com</ref>, che permette di frenare, muovere in
+
avanti o indietro o lasciare in libera corsa ognuno dei due motori.
+
  
In questo sistema non verrà sfruttata la possibilita di lasciare in libera corsa i motori, nè quella di muoverli a marcia indietro:
+
In more relaxed circumstances I would have made the same boards by PCB photo-etching.
ogni movimento sarà conseguenza della combinazione delle velocità in avanti imposte ai due motori, che in caso di frenata diventano 0.  
+
  
Il PIC effettua un controllo in PWM della velocità, che viene regolata con precisione grazie al feedback ricevuto da due encoder incrementali posti sugli alberi dei motori.
+
===Infrared Rangefinders===
 +
[[file:GP2D120X.jpg|right]]
 +
Terrain need to be analyzed in order to know if it's possible walking over it.
  
Il sistema implementato è un regolatore [[P.I.D.]], di cui in questo studio vengono sfruttate le componenti Proporzionale e Integrale , lasciando a zero il fattore Derivativo, in quanto non necessario.  
+
If the terrain roughness is high, it is avoided: the robot turns left or right searching for a  
 +
better path.  
  
Gli encoder montati sui motori vengono usati anche per odometria, che viene gestita dal sistema su PC per disegnare il percorso compiuto dal robot.  
+
The key concept adopted to detect if a terrain is too rough is this: robot needs a planar
 +
surface in order to climb over it without possibility of falling.  
  
I microfoni non vengono gestiti dal PIC, ma hanno una scheda  di amplificazione dedicata che manda il segnale via cavo audio stereo direttamente alla scheda audio del PC su cui gira il sistema
+
In order to understand if terrain is planar, some IR rangefinders have been used.
centrale di controllo neurale.  
+
This sensors are produced by SHARP, and the model is GP2D120X.  
  
Il PIC comunica col PC tramite cavo seriale alla velocità di 9600 baud/s.  
+
Main specifications
 +
'''GP2D120X'''
 +
Measuring distance range  3 - 40 cm
 +
Output terminal voltage 0.25 – 0.55
 +
Average supply current 33 - 50 mA
 +
Operating supply voltage 4.5 – 5.5 V
  
Riassumendo quindi il robot invia al PC i suoni ricevuti con cavo audio, i segnali dei sensori di prossimità e degli encoder per odometria con cavo seriale, e riceve dal PC i comandi tramite cavo
 
seriale.
 
  
In ricezione il PIC accetta solo i due comandi di velocità ai motori.
 
  
====Sezione Audio====
+
The output distance characteristics of sensor is shown in the picture below.
  
I due microfoni usati sono a bobina, unidirezionali di tipo cardioide, pensati per amplificare la
 
voce umana.
 
  
Come nel grillo, in cui è l'apparato sensoriale uditivo esterno che si occupa di tradurre una differenza di direzione del suono in una differenza di intensità sonora, anche qui è proprio il tipo
+
[[file:SHARP_GP2D120X_diagram.png]]
direzionale  di microfoni usati e la loro disposizione ad angolo che accentuano la differenza di livello del suono. Questo  semplifica l'elaborazione da parte del sistema software, che deve solo
+
basarsi sulla differenza di intensità uscente dai due canali audio amplificati.
+
  
La scheda alla quale sono coillegati i microfoni ha 2 stadi di amplificazione per ogni microfono, ogni stadio realizzato con un integrato LM386 <ref>UTC,  “UTC LM386 Linear Integrated Circuit” Datasheet, www.datasheetcatalog.com</ref>.
 
  
In tutto 4 integrati che amplificano 2 canali e li trasmettono via cavo audio stereo alla scheda audio del PC.  
+
As we can see , the characteristic is not linear.  
  
 +
In order to take correct distances (in cm ) from the sampled values, I wrote a lookup table with 17 values and the corresponding tension value (represented as number )
  
 +
unsigned short sharp_calib[17][2] =
 +
{
 +
{63,40},
 +
{71,35},
 +
{85,30},
 +
{106,25},
 +
{132,20},
 +
{153,18},
 +
{165,16},
 +
{192,14},
 +
{214,12},
 +
{257,10},
 +
{286,9},
 +
{319,8},
 +
{360,7},
 +
{415,6},
 +
{480,5},
 +
{562,4},
 +
{613,3}
 +
}
  
  
E' visibile anche la striscia di catroncino nero che scherma eventuali fasci infrarossi uscenti dalla parte posteriore dei led.
+
The C function (used in the firmware code):
  
 +
''float readSharp_cm(unsigned char addr)'' interpolates the values in the lookup table, converting the tension value to distance in centimeters.
  
 +
Four rangefinders are disposed onto a ''SensorBar'' horizontally fixed on the head of the robot, as we can see in the picture below.
  
====Sezione Rilevamento Ostacoli====
+
[[file:Sensor_Bar.png]]
[[file:robot_grillo_zoom_front.jpg|300px|thumb|right| Robot Grillo: I Led Infrarossi disposti a semicerchio nella zona frontale.]]  
+
  
L'apparato sensoriale di prossimità è costituito da una barriera di diodi infrarossi a fascio stretto,  
+
Three of these sensors point straight towards the terrain in front of robot, analyzing
suddivisi in due sezioni, destra e sinistra, ognuna composta da 8-9 led. E' mostrato in figura
+
terrain’s surface by sensing the distance from bar in three different points.  
  
La corrente che attiva i led è distribuita in egual misura su ogni led, così che venga illuminata
+
One sensor points in the march direction and is used to detect obstacles.  
uniformemente tutta la zona di rilevazione alla relativa sezione attivata.  
+
  
I sensori di rilevazione <ref>Vishay Telefunken, TSOP17..SE1 “Photo Modules for PCM Remote Control Systems”
+
The sensors are disposed in this way:
Datasheet, www.vishay.com</ref> sono 4 e sono posti dietro ai led e coprono l'intera area di rilevazione
+
* two in the center of the bar (one pointing down, one pointing forward)
intorno alla parte frontale del robot.
+
* on in the left limit of the bar (pointing down)
 +
* one in the right limit of the bar (pointing down)
  
[[file:robot_grillo_zoom_sensors.jpg|300px|thumb|left|Robot Grillo: I 4 Sensori IR disposti a semicerchio]]
+
Robot takes samples from all three sensors, and then compares them: If the distances are
Questi sensori contengono un amplificatore di segnale e un filtro a 38kHz  che protegge da disturbi ambientali, e danno in uscita un solo valore logico, 0v o 5v , in caso di presenza o assenza di luce infrarossa modulata incidente.
+
all the same (with a little tolerance), terrain is walkable. If the difference between right
 +
and center distances is high, robot turns slightly right If the difference between left and
 +
center distances is high, robot turns slightly left.
  
Essi sono accoppiati in parallelo in un unico blocco che ha una sola uscita, così che qualunque di essi abbia l'uscita a 0v , l'uscita del blocco sarà 0v, se invece sono tutti a 5v l'uscita del blocco sarà anch'essa a 5v.
+
Before using this approach, I tried to take distances with a single sensor turret, actuated
 +
by another Dynamixel servo, but this solution has revealed to be too slow and power
 +
consuming, and was abandoned.  
  
Questa semplificazione permette di ridurre il numero dei cavi e dei segnali da elaborare.  
+
As said before in the Introduction of this thesis, this sensor-bar has been conceived
 +
thinking at the embodiment concept: it moves with the robot body, giving
 +
automatically the sensors the best point of view (in order to have a good perception of
 +
terrain and obstacles) automatically. Sensor-bar position and orientation change
 +
according to the body configuration, which in turn changes according to the interaction
 +
with the environment.
  
Il PIC attiva le sezioni sinistra e destra alternativamente, e controlla ad ogni iterazione se il blocco sensori rileva un ostacolo nella zona illuminata dalla sezione attivata.
+
===3-axis Accelerometer===
 +
[[file:acc-3axis.jpg|right]]
 +
In order to know the robot inclination with respect to gravity force vector, a 3-axis
 +
accelerometer has been used.  
  
Vengono effettuati 4 livelli di controllo per ogni sezione.
+
This sensor is produced by Freescale Semiconductor and the model is MMA7361 .  
  
Ogni livello corrisponde ad un range di distanza di rilevazione.
+
'''MMA7361'''
  
Il livello 1 è il piu' vicino, ovvero rileva solo ostacoli entro 5 cm circa dal perimetro della barriera, gli altri 3
+
Low Voltage Operation 2.2 V – 3.6 V 
livelli aumentano la distanza di rilevazione progressivamente, quindi abbiamo 10 cm , 15 cm, e
+
infine 20 cm per il livello che ha il range più ampio.
+
  
Per variare la distanza alla quale il sensore percepisce l'ostacolo si è sfruttata la variazione della frequenza di modulazione dei led emettitori
+
High Sensitivity 800 mV/g @ 1.5g
da quella ottima di 38kHz.
+
  
La luce infrarossa modulata a 38kHz è quella percepita a distanza maggiore, riducendo (o aumentando) tale frequenza, ad esempio a 34 kHz , a parità di intensità
+
Selectable Sensitivity (±1.5g, ±6g)  
emessa, la luce viene percepita ad una distanza minore.
+
  
Con questo sistema siamo riusciti ad ottenere i 4 livelli di distanza di rilevazione degli ostacoli, più che sufficienti per lo scopo.
+
Low Current Comsumption 400 µA
  
  
 +
Table 4: Accelerometer - MMA7361
  
 +
I bought a ready to use “breakout-board” with sensor yet mounted on: you can see it in
 +
the photo above.
  
 +
In this application the selected sensitivity  is ±1.5g
  
 +
The sensor has been mounted on the chassis, the most possible near to the '''center of mass''' of robot.
  
 +
The ''robot center'' changes as the '''body joint''' moves, so a perfect positioning of the accelerometer has not been possible, but this was not a problem.
  
====Sezione Motori====
+
The accelerometer  orientation is:  
[[file:robot_grillo_foto_motore_scritte.gif|500px|thumb|right|Robot Grillo: Zona motore]]
+
* x axis points towards robot forward sense of march, horizontally with respect to floor
 +
* y axis is disposed horizontally with respect to floor, pointing to the left of robot
 +
* z axis exactly in vertical position, pointing against gravity force vector.  
  
I motori sono dei Brushed a Corrente Continua, con velocità massima a 12 V di circa 6000 rpm ,
+
The convention I used is to consider each axis in standard orientation when it is '''parallel''' to the '''plane normal to gravity vector'''.  
ridotti con una scatola di ingranaggi con rapporto 30:1 per avere più forza trainante.
+
  
La velocità angolare massima risultante è di circa 200 rpm, ovvero 3,33 rps, il che significa, dato il diametro di
+
For each axis, the implemented controller computes the ''displacement_angle'' from ''standard orientation''.  
25 cm delle ruote, una velocità lineare massima del robot di circa 83 cm/s, ideale per il compito e
+
l'ambiente di funzionamento.  
+
  
Gli encoder montati sugli alberi dei motori sono progressivi e hanno una risoluzione di 32 cpr
+
The method used to determine this displacement_angle is very simple: Each of three channels values are normalized with respect to the gravity force When robot is in standard position, values are 0 for y,x channels, 1 (100% gravity force) for the z channel.  
(Counts Per Revolutions, o anche impulsi per giro).  
+
  
Gli encoder passano in un sensore infrarosso a forcella che rileva la differenza di colore (bianco o
+
The '''orientation of each axis''' is computed as:
nero) che si alterna sul disco encoder e dà in uscita un valore logico (0v o 5v) alternato.
+
 +
''displacement_angle = arcsin(channel_value_N) ''
 +
 +
where  ''channel_value_N'' is channel value '''normalized to gravity module'''.  
  
Gli impulsi così generati vengono catturati dagli ingressi del PIC che, con un timer utilizzato per scandire il tempo, rileva l'intervallo di tempo intercorrente tra un impulso e il successivo, così da determinare istantaneamente la velocità dell'albero motore e quindi della ruota.
+
Each channel value is equal to cosin(gamma), where gamma is the angle between the axis and the gravity vector
  
Altri sistemi, per rilevare la velocità di rotazione dell'asse, utilizzano  il numero di impulsi di encoder catturati in un predeterminato lasso di tempo, sistema questo che impone tempi di rilevazione più alti rispetto al sistema da noi utilizzato, in quanto il lasso di tempo deve essere sufficientemente grande da garantire che almeno un certo numero di impulsi sia stato catturato, al di sotto del quale la risoluzione dell'informazione sulla velocità è troppo bassa, soprattutto alle basse velocità.
 
  
Per variare l'intensità di energia elettrica inviata al motore viene utilizzato il sistema PWM (Pulse Width Modulation), che consiste nello spedire un treno di impulsi di cui viene variato il duty cycle.
+
'''Computation of displacement_angle:'''
 +
 +
 +
''channel_value = g * cosin(gamma) ''
 +
 +
but we want to know the normalized value , so channel_value_N = channel_value /
 +
 +
''g = cosin(gamma) ''
 +
 +
The standard position is 90° wrt gravity vector, so the displacement_angle, we call it delta, is:
 +
 +
''delta = 90° - gamma ''
 +
 +
so
 +
 +
''gamma = 90° - delta ''
 +
 +
so
 +
 +
''channel_value_N = cosin(90° - delta) ''
 +
 +
Knowing that
 +
 +
''sin(delta) = cosin(90° - delta) ''
 +
 +
we can  say
 +
 +
''channel_value_N = sin(delta) ''
 +
 +
and finally
 +
 +
''displacement_angle = delta = arcsin(channel_value_N)''
  
All'aumentare del duty cycle aumenta il numero di volte nel tempo in cui viene attivato il motore.
+
==Power==
 +
===Transformer===
  
La scheda H-Bridge, che è l'ultimo stadio prima dei motori, riceve i due treni di impulsi a 0 - 5
+
Robot has been powered by AC-DC transformer during the development phase.  
Volts, pilotando così le tensioni di alimentazione ai motori, che vanno da 0 a 12 Volts.  
+
The transformer I used has this specifications: Output Voltage 12V
 +
* Max current  5A max
  
Il PIC, potendo quindi inviare potenza variabile ai motori, e conoscendo la velocità alla quale
+
[[file:Robotis_Transformer.jpg]]
stanno andando, può effettuare un controllo in feedback calcolando l'errore rispetto alla velocità
+
desiderata.
+
  
Tale controllo è stato implementato con un algoritmo PID, di cui attualmente sono
+
===Batteries===
sfruttate le due componenti Proporzionale e Integrale, che permettono un rapido raggiungimento
+
e un'ottima precisione della velocità desiderata.
+
  
Un eventuale inclusione del fattore derivativo permetterebbe anche il mantenimento della velocità desiderata in caso di veriazioni brusche, ma in
+
When the robot development has been completed, robot has been equipped with a couple of  2-cells lithium polymer batteries.  
questo studio non è risultato necessario.  
+
  
 +
Batteries specifications:
 +
* Output Voltage 7.5V
 +
* Battery capacity 2500 mAh
  
 +
Due to the lower tension of battery with respect to transformer, servo’s speed has been slightly increased in order to ensure a sufficient  torque
  
 +
[[file:LionHell_Battery.jpg]]
  
====Sezione Comunicazione Robot-PC====
 
  
I dati rilevati ( suono , ostacoli e velocità ruote), sono inviati al PC su canali diversi accorpati in un
+
=Firmware=
unico cavo, che fornisce anche l'alimentazione al robot. Il cavo è schermato con calza esterna ed è
+
da 8 poli (contiene al suo interno 8 sotto-cavi).
+
  
La calza schermante è posta a massa, 1 polo viene usato per fornire i 12 volt di alimentazione al robot, 2 poli sono dedicati ai due canali audio che
+
The implemented firmware was initially conceived to be the only program to control the
vanno dai microfoni alla scheda audio del PC, altri 2 poli sono i canali RX e TX della seriale.
+
robot.  
  
Il due canali audio trasmettono i segnali in forma grezza come variazione di tensione nel tempo.
+
After some testing, the used microcontroller has revealed to be too less powerful in  
 +
order to obtain an acceptable loop speed and a sufficiently complex computational
 +
capability. A complex control like motion planning needs a more performant
 +
computational system.  
  
Essendo tutti i sottocavi all'interno della stessa calza, sono presenti fenomeni di mutua induzione,  
+
I decided to mantain a fast reactive behavior based control in the main loop, adding a
soprattutto da parte del canale seriale verso quello audio, che risulta così disturbato.
+
serial communication phase in order to allow data exchange with external control
 +
hardware, like a PC. A deep analysis of the behavior based control in mobile robotics
 +
can be found in a recent work from L. De Silva and H. Ekanayake [18]: they discuss
 +
several behavior control paradigms, including the subsumption.  
  
Tale disturbo è stato eliminato col filtraggio a 1 kHz, comunque richiesto anche per motivi connessi al livello di
+
In remote control applications, a simple control like this will act as a cerebellum,  
rilevazione dei microfoni e al carico di elaborazione da parte del PC.  
+
assisting the remote user in the motion control. A recent work on this topic has been
 +
made by Shigang cui, Zhengguang lian, Li zhao, Zhigang bing, Hongda chen [19].  
  
Il canale seriale è pilotato dal PIC , ed ha il seguente funzionamento in cui il MASTER è il PC e lo
+
They discuss several behavior control paradigms, including the subsumption.
SLAVE è il PIC:
+
  
# il PC INVIA un pacchetto di comandi al PIC
+
The implemented loop resulted to be very fast, and sufficient to manage the most
# il PIC lancia un interrupt e si dedica istantaneamente alla registrazione del pacchetto
+
critical behaviors, like falling prevention and obstacle climbing.
# il PIC, immediatamente dopo la ricezione, invia il suo pacchetto di informazioni al PC
+
# il PC RICEVE il pacchetto dal PIC e lo salva nel buffer, che verrà poi letto dal software
+
  
Il pacchetto inviato dal PC al PIC contiene i comandi dei motori.
+
The main control loop consists of this macro blocks:
 +
*Read and Communicate Sensors Data
 +
*Set Speed According to Body Inclination
 +
*Main Behaviors
 +
**Jump Down Behavior
 +
**Terrain Check Behavior
 +
**Approaching Obstacle Behavior
 +
**Adapt to Floor Behavior
 +
*Walking Actions
 +
**Go Backward
 +
**Turn Left
 +
**Turn Right
 +
**Restart Walking
 +
**Stop Walking
 +
*Tail Control Section
 +
**Tail Behaviors Manager
 +
**Tail Behavior 1: Avoiding Falling Backward
 +
**Tail Behavior 2: Climbing
 +
 +
==Read and Communicate Sensors Data==
 +
The first thing to do in the main loop is reading sensors, and communicating them to the
 +
eventual external hardware through the serial-usb link.  
  
 +
===Reading Sensors===
 +
This is done using this funcion:
 +
 +
*void readAllSensors(Sensors *s);
 +
It reads all sensors data saving them into a Sensors structure.
 +
 +
The above function calls a specific read function for each sensor:
 +
*float readSharp_cm(unsigned char addr);
 +
 +
It reads the value of Sharp sensor mapped at address addr  and convert it to distance
 +
in centimeters.
 +
 +
Each address indicates a channel on the distance sensors multiplexer.
 +
*float readAccDeg(unsigned char addr);
 +
 +
It reads the angle value from the Accelerometer Channel at address addr, and
 +
converts it to degrees.
 +
 +
Each address indicates a channel on the accelerometer multiplexer, and each
 +
multiplexer channel correspond to a single channel on the accelerometer.
 +
 +
Accelerometer, as seen before, has 3 channels, one for each axis.
 +
 +
===Communicating sensor data===
 +
The communication is performed through a serial link in asynchronous mode, at a
 +
baudarate of 57600 bps.
 +
 +
The serial format is 8bit, no parity, 1 stop bit.
 +
 +
The data format is the following:
 +
 +
FC <FC>\tGC <GC>\tGL <GL>\tGR <GR>\tZ <Z>\tX <X>\tY <Y>\tAD <AD>\tTD <TD>\n
 +
 +
and this is the meaning of the tags:
 
   
 
   
Formato Paccetto TX:  
+
<FC> : Distance in cm from Central Front Sensor
 +
<GC> : Distance [cm] from Central Ground Sensor
 +
<GL> : Distance [cm] from Left Ground Sensor
 +
<GR> : Distance [cm] from Rigth Ground Sensor
 +
  <Z> : Normalized [adim] value from Z axis Channel on Accelerometer
 +
  <X> : Normalized [adim] value from X axis Channel on Accelerometer
 +
  <Y> : Normalized [adim] value from Y axis Channel on Accelerometer
 +
<AD> : Abdomen Inclination angle [deg] with respect to the robot body
 +
<TD> : Tail Inclination angle [deg] with respect to the robot body
  
“XXXAYYY7”
 
  
* XXX è il valore della Velocità desiderata del Motore Sinistro in 3 cifre
+
This data is intended to be read from the serial-usb interface using a sscanf function
* YYY è il valore della Velocità desiderata del Motore Sinistro in 3 cifre
+
implemented in any programming language.  
* A è il carattere alfanumerico Ascii che abbiamo scelto come separatore tra i due valori inviati.
+
* 7 è il carattere alfanumerico Ascii che abbiamo scelto come delimitatore di Fine pacchetto.
+
  
Il pacchetto inviato dal PIC al PC contiene le informazioni sulle velocità dei motori e sugli ostacoli rilevati.  
+
All transmitted values are integers ( %d  in C, C++ format ).  
  
 +
This is the output we get connecting to it :
 +
...
 +
FC 39 GC 17 GL 19 GR 19 Z 932 X -24 Y 43 AD -34 TD -37
 +
FC 39 GC 16 GL 18 GR 18 Z 1000 X 48 Y 92 AD -34 TD -37
 +
FC 39 GC 15 GL 18 GR 19 Z 1000 X 54 Y 37 AD -34 TD -37
 +
...
  
Formato Pacchetto RX:
 
  
* “S(TAB)(CSX)(TAB)(CDX)(TAB)(OBSTSX)(TAB)(OBSTDX)(TAB)E”
+
==Set Speed According to Body Inclination==
* S : carattere Ascii delimitatore di Inizio pacchetto
+
* E : carattere Ascii delimitatore di Fine pacchetto
+
* (TAB) : carattere Ascii di Tabulazione usato come Separatore tra i valori numerici inviati
+
* (CSX) : valore Velocità Encoder Sinistro
+
* (CDX) : valore Velocità Encoder Destro
+
* (OBSTSX): valore presenza Ostacoli a Sinistra
+
* (OBSTDX) : valore presenza Ostacoli a Destra
+
  
 +
In order to adapt the servomotors torque to the current ground surface, the robot must
 +
increase their speed according to the vertical inclination of the robot body.
  
 +
If the inclination value is high and positive, the robot is walking uphill, so the torque
 +
must be increased.
  
 +
The following instruction sets the nominal speed for all whegs servos: ''dnspeed''
  
 +
(Desidered Nominal Speed) : dnspeed = (600 + 4 *sensors.body_inclination_xg);
  
===Software===
+
Dynamixel servos accept a speed value from 0 to 1023.
  
Il software che gira sul PC è Matlab, di cui viene usato il ToolBox Simulink per l'implementazione
+
Here we set 600 as base-speed, then adding a variation proportional to inclination.  
della rete neurale, e il normale codice di programmazione per operazioni di supporto, scambio
+
dati, logging e rappresentazione grafica.  
+
  
Il modello simulink rappresentato in figura è il cuore del nostro sistema di controllo del robot.
+
If the inclination is negative (robot walking downhill) the added variation will be
Il blocco centrale è la rete neurale basata su quella del grillo, essa riceve i segnali a sinistra e li
+
negative, ending up with a speed value smaller than base-speed.  
processa in 3 stadi.  
+
  
I segnali che arrivano all'ingresso del controllore neurale sono pretrattati, sempre in matlab.
 
  
 +
==Main Behaviors==
 +
This behaviors determine the commands that will be sent to the whegs in the following Walking Actions section.
  
====Discretizzazione Temporale====
+
All this behaviors are exclusive, and they have descending priority, so that the first has
 +
the high one and the last has the lower one.
  
Tutte le operazioni del sistema avvengono in quanti di tempo.
+
Each behavior has a trigger event that I call “situation”.  
  
Ogni quanto è di 0.04 secondi e all'interno di esso avviene l'estrazione dei segnali appena descritta, il loro invio alla rete, l'uscita
+
Before going to process  the behaviors, some data must be prepared.  
dei segnali dalla rete e il loro invio alle ruote, e infine i log dei dati in una matrice che aumenta di
+
una riga dati ad ogni quanto.  
+
  
 +
''float ld = abs((int)(sensors.distance_floor_left – sensors.distance_floor_center));''
 +
 +
''float rd = abs((int)(sensors.distance_floor_right – sensors.distance_floor_center));''
  
====Logging====
 
  
Nella matrice di log dei dati provenienti dal PIC vengono salvati i valori dei sensori di prossimità,
+
The above two instructions compute two difference values:
delle velocità delle ruote.
+
*ld : '''Left Difference''' This is the difference value between the left terrain distance sensor and the center terrain distance sensor
 +
*rd : '''Right Difference''' This is the difference value between the right terrain distance sensor and the center terrain distance sensor.  
  
Altre 3 matrici di log sono dedicate al salvataggio dei valori dei neuroni dei 3 strati.  
+
This difference values will be used within the following behaviors in order to detect the current situation.  
  
* inNeur : contiene in valori dello strato di input
 
* midNeur : contiene in valori dello strato intermedio
 
* outNeur : contiene in valori dello strato di output
 
  
Le matrice di log servirà alla fine di ogni esperimento per verificare cosa è successo, grazie alla
+
===Jump Down Behavior===
rappresentazione su piano cartesiano dei dati nel tempo e alla rappresentazione grafica
+
bidimensionale dell'ambiente in cui si muove il robot e del percorso da esso compiuto sotto forma
+
di scia.
+
  
In seguito queste rappresentazioni vengono studiate per comprendere il comportamento adottato
 
dal robot con quella particolare configurazione di pesi neurali.
 
  
  
 +
'''Situation 1:'''
 +
''Robot’s head is facing floor with an abdomen inclination inferior to -45 ° with respect to gravity force vector''
 +
''AND distance from floor along the view axis is less than 30 cm.''
  
 +
In this situation the robot will probably crash his head to the floor if it doesn’t lift it Instantly,  so the first command is to stop walking.
  
====Filtraggio e pre-elaborazione dati====
+
This situation requires that the distance from floor is less than 30 cm, so that the robot could “jump” toward floor without destroying itself.
  
I due canali audio vengono filtrati con un filtro passa-banda molto selettivo impostato intorno a
 
1kHz, che è la frequenza emessa dalla sorgente sonora che il robot dovra raggiungere.
 
  
Una volta filtrato, il segnale audio viene suddiviso pacchetti di campioni, e ogni pacchetto (per ogni canale)  
+
'''Behavior 1:'''
viene elaborato nel quanto di tempo.
+
''Then the robot lift up the abdomen until it exits from this situation.''
 +
 
 +
 
 +
'''Code'''
 +
 
 +
if (sensors.abdomen_inclination_g < -45 && sensors.distance_front_center < 30){
 +
stop();//STOP ROBOT
 +
while(sensors.abdomen_inclination_g < -45 && sensors.distance_front_center < 30)
 +
  {
 +
  //LIFT ABDOMEN
 +
  dpAbd = dpAbd + 1;
 +
  setAbdomenDeg(dpAbd, 1000);//Lift
 +
  sensors.abdomen_inclination_g = getAbdomenDegG();
 +
  sensors.distance_front_center = readSharp_cm(4);
 +
  }
 +
}
 +
 
 +
===Terrain Check Behavior===
 +
 
 +
This behaviors uses the Left Difference (ld) and Right Difference (rd) described before in chapter 5.3.
 +
 
 +
'''Situation 2:'''
 +
''Left Difference or Right Difference is greater than 8 cm.''
 +
 
 +
This means that terrain is not uniform.
 +
 
 +
'''Behavior 2:'''
 +
''turn where the difference is smaller. ''
 +
 
 +
'''Code:'''
 +
 
 +
if(ld > 8 || rd > 8)
 +
{
 +
  if (ld >= rd) {turnR = 1; turnL=0;}
 +
  if (ld < rd) {turnL = 1; turnR=0;}
 +
}
 +
 
 +
===Approaching Obstacle Behavior===
 +
 
 +
'''Situation 3 :'''
 +
''There is an obstacle near in front of the robot in central position.''
 +
 
 +
Obstacle is considered near if distance is less than 15 cm.
 +
 
 +
'''Behavior 3 :'''
 +
''climb over  the osbtacle.''
 +
 
 +
The sequence of actions to perform is :
 +
 
 +
1. stop walking
 +
2. lift head (abdomen) until obstacle diappears and abdomen inclination doesn't
 +
    exceed 80°. This limit has been imposed in order to avoid vain climbing efforts
 +
    on almost perpendicular walls.
 +
 
 +
Code:
 +
if (sensors.distance_front_center <  15)
 +
{
 +
  stop();
 +
  while(sensors.distance_front_center < 15 && sensors.abdomen_inclination < 80)
 +
  {
 +
    if (dpAbd > 80)dpAbd = 80; //Upper Bound setAbdomenDeg(dpAbd, 200);//Lift up
 +
    abdomen sensors.distance_front_center = readSharp_cm(4); //read distance
 +
  }
 +
}
 +
 
 +
 
 +
===Adapt to Floor Behavior===
 +
 
 +
'''Situation 4 :'''
 +
''Distance from floor is greater than 23 cm ''
 +
 
 +
This happens when the abdomen is too high, or when robot approaches a descent .  
 +
 
 +
In order to have a good sensing of the terrain the sensors array should point the floor perpendiculary (and so abdomen should be parallel to terrain).
 +
 
 +
Due to the geometry of robot (his height is about 23 cm), lowering abdomen until it's 23 cm distant from floor will put it parallel to floor surface.
 +
 
 +
 
 +
'''Behavior 4 :'''
 +
''Lower the abdomen until distance of  head  from floor is less than 23 cm ''
 +
''or it's tilted down more than 75° ''
 +
 
 +
'''Code:'''
 +
if(sensors.distance_floor_center > 23 )
 +
{ // Floor too distant ..
 +
  stop(); //stop walking
 +
  while(sensors.distance_floor_center > 23 && sensors.abdomen_inclination > -75)
 +
  {
 +
    dpAbd = dpAbd – 1; // Lower down Abdomen
 +
    if (dpAbd < -75)dpAbd = -75; // Limit value
 +
    setAbdomenDeg(dpAbd, 200);//send command to servomotor
 +
    sensors.distance_floor_center = readSharp_cm(6);
 +
  }
 +
}
  
L'elaborazione consiste nel calcolare il valore assoluto che sarà inviato agli ingressi della rete.
 
 
   
 
   
In ogni quanto i dati sui sensori di prossimità sono prelevati dal pacchetto ricevuto via porta
+
==Walking Actions==
seriale dal PIC, normalizzati , registrati nel log e quindi inviati alla rete.  
+
The purpose of this section is to send commands to servomotors, in order to perform the movements  requested by the previous behaviors section.  
 +
 
 +
The first instruction of this section is a control statement that checks if the robot should be walking or not.
 +
 
 +
This is accomplished by reading the value of a condition variable called ''walking''.
 +
 
 +
This condition variable is set within the previous behaviors section.
 +
 
 +
'''Code:'''
 +
if (walking==1)
 +
{
 +
  …
 +
}
 +
 
 +
The other condition variables used to control this section are:
  
I valori normalizzati dei sensori sono 4: 0.2, 0.4, 0.6 e 0.8 .
+
''turnL//Turn Left ''
 +
''turnR//Turn Right ''
  
I dati provenienti dagli encoder vengono elaborati in uno script di matlab che estrae la velocità,
+
===Go Backward===
basandosi sul diametro delle ruote e sulla risoluzione degli encoder, e la memorizza nel log.
+
  
 +
The way behaviors inform this section that the robot must bo backward is just enabling both turn condition variables : turnL and turnR.
  
 +
'''Code:'''
 +
If(turnL && turnR)
 +
{
 +
  int i ;
 +
  for (i=0;i<3;i++){//Go Back
 +
      dxl_write_word( whegs_sx[i], P_MOVING_SPEED_L, 1424 );
 +
      dxl_write_word( whegs_dx[i], P_MOVING_SPEED_L, 400 );
 +
      _delay_ms(20000);//Mantain behavior
 +
      //Disable behavior..
 +
      turnL = 0;
 +
      turnR = 0;
 +
  }
 +
}
 +
 
  
 +
===Turn Left===
 +
Turning Left is accomplished by going backward with the left train of whegs, keeping still the right one.
  
 +
Behavior is mantained for a while, and then condition variable are cleared.
  
 +
if(turnL)
 +
{
 +
  int i ;
 +
  for (i=0;i<3;i++) //iterate on all servos {
 +
      dxl_write_word( whegs_sx[i], P_MOVING_SPEED_L, 1424 );
 +
      dxl_write_word( whegs_dx[i], P_MOVING_SPEED_L, 0 );
 +
      _delay_ms(20000);//Mantain behavior
 +
      //Disable behavior..
 +
      turnL = 0;
 +
      turnR = 0;
 +
  }
 +
}
  
====La Rete Neurale====
+
===Turn Right===
[[file:robot_grillo_rete_neurale.png |500px|thumb|right| La Rete Neurale Utilizzata]]
+
  
La rete utilizzata è composta da 3 strati.  
+
Same as Turn Left.  
  
Il primo stadio è quello di ingresso, preleva i segnali in arrivo dai microfoni e dai sensori di
+
if(turnR){
prossimità e li normalizza.  
+
  int i ;
 +
  for (i=0;i<3;i++){
 +
      dxl_write_word( whegs_sx[i], P_MOVING_SPEED_L, 0 );
 +
      dxl_write_word( whegs_dx[i], P_MOVING_SPEED_L, 400 );
 +
      _delay_ms(20000);//Mantain behavior
 +
      //Disable behavior..
 +
      turnL = 0;
 +
      turnR = 0;
 +
  }
 +
}
  
Il secondo stadio contiene dei neuroni a peso variabile, riceve i segnali uscenti dal primo stadio ed
+
===Restart Walking===
effettua una selezione del comportamento del robot in base ai pesi impostati.
+
This section is needed to make the robot restart walking in two cases:
 +
*it was stopped before
 +
*it was turning
  
Il terzo stadio riceve i segnali dal secondo stadio e li invia agli amplificatori esterni.
+
if (!(turnL + turnR)){//If not turning
 +
  go_fwd();//Go forward
 +
}
  
Gli amplificatori esterni servono a innalzare il valore dei neuroni, che è normalizzato tra zero e
 
uno, affinchè sia sufficiente a muovere i motori e quindi le ruote.
 
  
 +
===Stop Walking===
  
E facile intuire il funzionamento della rete osservando i suoi collegamenti.
+
If the walking condition variable is not set, the robot just stops walking.  
  
Limitandoci alle Orecchie, vediamo che un attivazione del neurone 2 (Orecchio dx) provocherà un'attivazione del
+
If (walking==1)  
neurone 5 (Ruota sx) un'inibizione del neurone 6 (Ruota dx).
+
  {
 +
  …
 +
}
 +
else
 +
{
 +
  stop(); //Stop Walking
 +
}
  
Col sistema differenziale, un'attivazione della ruota sinistra o un'inibizione della ruota destra provocano una variazione in  
+
==Tail Control Section==
senso orario  (e quindi verso destra ) dell'orientamento del robot, che quindi si volgerà verso il suono (a destra). Un suono proveniente da destra, incidendo maggiormente sul microfono destro,
+
In this section we control the tail, in order to help robot to accomplish some tasks.  
provocherà un'avanzamento verso destra del robot.
+
  
La sottorete dei Baffi (sensori ostacoli) sx e dx ha lo stesso funzionamento, con eccitazione e
+
This part is located after the Walking Actions section, because it do not modifies any walking control variable.  
inibizione invertite.  
+
  
Un'attivazione del Baffo sx provocherà un'avanzamento del robot verso destra, in modo da
+
===Tail Behaviors Manager===
evitare l'ostacolo che si trova a sinistra.  
+
This section acts like a behavior manager, it mantains a behavior until it accomplishes its task.  
  
Rispetto a prima è stato aggiunto un collegamento eccitatorio tra il Baffo sx e la ruota sx.  
+
It checks if tails has reached (with little toelrance) the desidered position and, in positive case, it disables the torque on tail servomotor.  
  
Nella rete precedente non era stato usato per imporre un'asimmetria nella risposta ai motori in
+
Then it disables all tail behaviors by clearing dpTail control variable.  
presenza di un ostacolo al centro, che altrimenti avrebbe fatto muovere le ruote alla stessa velocità
+
causando uno scontro del robot con l'ostacolo.  
+
  
Senza quel collegamento il robot girava a dx in  
+
// Check if desidered Tail position (if it was set) has been reached
presenza di un ostacolo al centro.
+
if(dpTail != -1 && abs((int)dpTail - (int)pTail) < 50)
 +
{
 +
  dxl_write_word( 1, P_TORQUE_ENABLE, 0 );
 +
  // Disable Torsion Servo
 +
  // Needed to shut off tail behaviors
 +
  // activated in previous loop cycle 
 +
  dpTail = -1; //disable desidered Tail position
 +
}
  
Adesso l'asimmetria non è più presente nella struttura della rete,
 
che è simmetrica.
 
  
L'implementazione dell'asimmetria è stata delegata ai pesi neurali . I pesi dei
+
===Tail Behavior 1: Avoiding Falling Backward===
collegamenti tra baffi e ruote dovranno avere valori diversi tra baffo sinistro e baffo destro. Ad
+
esempio, negli esperimenti da noi effettuati, abbiamo reso diversi i valori delle sole inibizioni,
+
ponendo l'inibizione baffo_sx-ruota_dx più alta dell'inibizione baffo_dx-ruota_sx .
+
  
 +
'''Situation 5 : '''
 +
''• Tail is high (wrt body)''
 +
''• Abdomen isn't low (wrt body) ''
 +
''• Body is tilted up more than 45° with respect to gravity vector ''
  
 +
In this situation the robot is likely to fall backward, so robot body must be put in a less dangerous configuration.
  
 +
'''Behavior 5 : '''
 +
''Lower the tail until it’s almost in line with body (horizontal position) ''
  
 +
Putting tail in line with body makes the back of the  robot to lift up.
  
====Variazione dei Pesi Sinaptici====
+
In this way robot’s center of mass is moved forward, towards the central position, putting the whole body in a safer position.
  
I neuroni di cui variamo il peso sono quelli intermedi tra neuroni di ingresso e neuroni di uscita.
+
'''Code:'''
 +
if ( parallel && pTail < 300 &&  // Tail is high
 +
      getAbdomenDeg() >-10 && // Abdomen isn’t low (wrt body)
 +
      readAccDeg(1) > 45) // Body is tilted up more than 45 deg wrt g
 +
{
 +
    //avoid falling backwards 
 +
    dpTail = 500;
 +
    dxl_write_word( 1, P_GOAL_POSITION_L, dpTail );
 +
    dxl_write_word( 1, P_MOVING_SPEED_L, 210 );
 +
}
  
I collegamenti di cui variamo il peso sono i seguenti:
 
  
* Eccitazione del neurone-motore-sinistro da parte del neurone-orecchio-destro
+
===Tail Behavior 2: Climbing ===
* Eccitazione del neurone-motore-destro da parte del neurone-orecchio-sinistro
+
'''Situation 6 : '''
* Inibizione del neurone-motore-sinistro da parte del neurone-orecchio-sinistro
+
''• Tail is slightly up (wrt body) ''
* Inibizione del neurone-motore-destro da parte del neurone-orecchio-destro
+
''• Abdomen is slightly low (wrt body) ''
* Eccitazione del neurone-motore-sinistro da parte del neurone-ostacolo-sinistro
+
''• Body is tilted up more than 60° with respect to gravity vector ''
* Eccitazione del neurone-motore-destro da parte del neurone-ostacolo-destro
+
* Inibizione del neurone-motore-sinistro da parte del neurone-ostacolo-destro
+
* Inibizione del neurone-motore-destro da parte del neurone-ostacolo-sinistro
+
  
Variando anche singolarmente il peso un solo collegamento alla volta possiamo osservare una
+
In this situation, robot's body is very tilted up, and abdomen is slightly tilted down.  
variazione del comportamento del robot .  
+
  
Vedremo ad esempio di come un'aumento dell'inibizione dei neuroni-orecchie sui neuroni-motore
+
This means that robot is climbing over an obstacle.  
induca il robot a compiere curve più strette.  
+
  
 +
'''Behavior 6 :'''
 +
''Lower the Tail until it’s quite lower than the horizontal position.''
  
 +
If the tail is slightly upper than the horizontal position, it should be lowered down, in order to help robot in the climbing task.
  
 +
Lowering tail helps because in this way the robot’s back is lifted up, and this moves the center of mass forward, causing the frontal whegs to exert a greater pressure on terrain.
  
====Rappresentazioni Grafiche====
+
Great pressure on terrain ensures more grip, and so robot can easily bring its body forward, accomplishing the climbing task.
  
Alla fine di ogni esperimento uno script (drawLog.m) rappresenta le informazioni utili in forma
+
if ( parallel && pTail < 450 && // Tail is slightly up
grafica.
+
      getAbdomenDeg() < -20 && // Abdomen is slightly low
 +
      readAccDeg(1) > 60 ) // Body is tilted up more than 60 deg wrt g
 +
{ //climb
 +
    dpTail = 712;
 +
    dxl_write_word( 1, P_GOAL_POSITION_L, dpTail );
 +
    dxl_write_word( 1, P_MOVING_SPEED_L, 210 );
 +
}
  
# Scrive una tabella contenente i valori dei pesi dei neuroni intermedi.
+
==Flow Chart==
# Disegna in 2D la scena dell'ambiente di prova con gli ostacoli e la sorgente sonora, traccia la scia percorsa dal robot, disegna il robot nella sua posizione finale.
+
# Plotta i valori nel tempo dei neuroni dei 2 strati ingresso e uscita in una unica figura in modo che sia facile vedere a occhio nudo le relazioni fra essi in ogni istante di tempo.
+
# Plotta i valori nel tempo dei neuroni dello strato intermedio.
+
  
 +
[[file:lionhell_firmware_flow_chart.png|Firmware Flow Chart]]
  
 +
=Experiments=
  
==Bibliografia==
+
==LionHell McMillan walking on rough natural terrain ==
<references/>
+
{{#evp:youtube|QbMM9orBUn0|LionHell McMillan ROBOT - Walking on Rough Terrain|center|600}}
  
--[[Utente:Venom|venomyeah]] 18:24, 11 lug 2011 (CEST)
+
=Download=
 +
*[[http://www.robotgarage.org/wiki_files/Firmware.zip Firmware Source Code and Object File  ]]
 +
*[[http://www.robotgarage.org/wiki_files/Player_Server_Plugins.zip Player Server Plugins Source Code]]
 +
*[[http://www.robotgarage.org/wiki_files/Wheel_Drawing.rar Wheg Drawing]]

Latest revision as of 18:39, 22 April 2015

LionHell McMillan
Coordinator: GiuseppinaGini (gini@elet.polimi.it)
Tutor:
Collaborator:
Students: VittorioLumare (venom@venom.it)
Research Area: Robotics
Research Topic: Robot development
Start: 2011/09/10
End: 2012/07/20
Status: Closed
Level: Ms
Type: Thesis


LionHell McMillan is an All Terrain Wheg Robot with Morphological Computation

It has been developed in a Master Thesis work in Robotics and Artificial Intelligence and it has been modified and improved in a Master Thesis work in Robotics and Artificial Intelligence by Alessandro Rosina ( http://airwiki.ws.dei.polimi.it/index.php/LionHell_McMillan_II ) , changing the name from "LionHell McMillan" to "LionHell McMillan II".

Info about Thesis

TItle : All Terrain Wheg Robot with Morphological Computation 
Robot Name: LionHell McMillan
Correlator: Giuseppina Gini
Author: Vittorio Lumare
Area: Robotics and Artifical Intelligence
Start date: 2011/09/10
End date: 2012/07/24
LionHell McMillan ROBOT - Walking on Rough Terrain

The Idea

Starting Point

The new locomotion system called Wheg (Wheel + Leg) enable mobile robots to move on rough terrains, using a simple control system .

Objective

The project objective is to test the wheg system , in order to find a design (both of robot, both of whegs) able to give the best agility on rough natural terrains.

State of The Art

Simulations / Design

Simulation 1

The first robot model has been taken from an existent robot : EMBOT

This is a video of the first simulation with this model

First simulation

As can be seen from simulation, robot model is unsuitable to the task.

The model has been then improved extending the body length of about 5 cm.

Simulation 2

Second simulation:

Second simulation

Now robot is able to climb all the steps, but this is not enough. The objective is harder: we want the robot to climb obstacles big as its body size, so I made another simulation with bigger obstacles:

Third simulation

Despite its longer body, the robot is unable to climb over the step.

This happens because it has no support in the back: when the back wheg (we see only one back wheg because of the 2D simulation) rotates, the mechanical support of the servomotor is the robot chassis, which starts rotating clockwise, making the robot falling backwards.

The solution to this problem is to avoid the chassis rotation.

How to avoid the chassis rotation?

A simple approach is to add a fixed link in the back , such a kind of tail, so that when the chassis starts rotating clockwise , the tail will touch the ground surface blocking the rotation.

Simulation 3

New Model:

  • New central wheg
  • New link added to body
  • Joint in the body center
  • Tail added to the back
  • Wheg foot design improved to give better grip
Fourth simulation

As we can see , the robot is able to walk on very rough surface terrain.

He goes on even in presence of high surface spikes, thing that would have been not possible for the previous robot model.

This better behavior is principally due to the new central wheg added to the model, and to the slight body flexibility, due to the action of a spring and a damper in the body center.

Thanks to the tail action, robot never falls on his back.

The Real Robot

First Prototype

LionHell First Prototype






Final Prototype

LionHell Final Prototype

Hardware

In this section all the hardware components will be illustrated, excluding structure because it was yet discussed in the previous chapters.

Servomotors

Dynamixel-ax-12a.jpg

In this robot the servomotors are the only actuators.

These servos have been taken from a Robotics kit called Bioloid, commercialized by Robotis.

The servomotor model is Dynamixel AX-12.

Dynamixel servos are very versatile, quite strong and can be used in two modes:

  • Continuous Rotation mode
  • Position mode

The only limit of these servos causing some problem in this work is a 60° dead-band . When motor shaft falls in this range, position is not retrievable from the internal potentiometer . This was a problem in continuous rotation mode, because I could not control the servo position in that range. This limit avoided me to synchronize all the six whegs to obtain a perfect control in climbing over obstacles. In fact I ended up with a simple open-loop motor control.

The other 3 servos were used in Position Mode:

  • Two servos for the body joint in the center of robot
  • One servo for the tail

Illustration 42: Servomotor - Dynamixel AX-12

Table 1: Servomotor - Dynamixel AX-12

In this case the dead band did not cause any problem, because a 180° movement was sufficient for the purpose.

I had to use two servos for the body joint, because of the high torque needed to move the head and the frontal pair of whegs. At a first time I tried to use one servo, but it was subject to overheating, until it burned. Using two servos in parallel, mechanically coupled, permitted a perfect control of the joint, without overheating.

Control Board

Cm510.png

The central processing unit used is a CM-510.

It’s a development board producted by Robotis, and its fully compatible with Dynamixel AX-12 servos.

CM-510

Weight 51.3g 
Controller ATMega2561 
Working Voltage 
 Allowed Range : 6.5V ~ 15V 
 Recommended Voltage : 11.1V (Li-PO 3cell) 
Consumed Current 
 When IDLE : 50mA 
 External I/O Maximum Current : 0.9A 
 Total Maximum Current : 10A (Fuse) 

Table 2: Control Board – CM-510

Illustration 43: Control Board - CM-510


This board is featured with standard Dynamixel ports, plus 6 other general purpose ports.

Each general purpose port is featured with 4 usable pins:

  • Ground
  • Power (5V)
  • Digital I/O
  • Analogue Input (0V– 5V)

I used these ports to connect all peripheral sensors.

Since I had too many sensors for the available ports, I had to built two multiplexer boards:

  • One board to multiplex 4 rangefinders
  • One board to multiple 3-axis accelerometer

The boards inputs have not been fully used, so there are available channels for an eventual future use.

Sensors

The most critical aspects of perception in this robot are:

  • Terrain sensing.
  • Robot inclination with respect to gravity force vector.



Multiplexer Boards

I designed and builded two multiplexer boards: one for the IR-rangefinders , one for the 3-axsis-accelerometer.

The board below multiplexes the analog signal from each of the four used IR Sharp Rangefinders, in order to use a single analog input on the CM-510 Board. Rangefinders Multiplexer Board.jpg


The board below multiplexes the analog signal from each accelerometer channel, in order to use a single analog input on the CM-510 Board.

Accelerometer Multiplexer Board.jpg


For time reasons I've implemented both boards quickly by manually building the circuit tracks.

In more relaxed circumstances I would have made the same boards by PCB photo-etching.

Infrared Rangefinders

GP2D120X.jpg

Terrain need to be analyzed in order to know if it's possible walking over it.

If the terrain roughness is high, it is avoided: the robot turns left or right searching for a better path.

The key concept adopted to detect if a terrain is too rough is this: robot needs a planar surface in order to climb over it without possibility of falling.

In order to understand if terrain is planar, some IR rangefinders have been used. This sensors are produced by SHARP, and the model is GP2D120X.

Main specifications GP2D120X Measuring distance range 3 - 40 cm Output terminal voltage 0.25 – 0.55 Average supply current 33 - 50 mA Operating supply voltage 4.5 – 5.5 V


The output distance characteristics of sensor is shown in the picture below.


SHARP GP2D120X diagram.png


As we can see , the characteristic is not linear.

In order to take correct distances (in cm ) from the sampled values, I wrote a lookup table with 17 values and the corresponding tension value (represented as number )

unsigned short sharp_calib[17][2] = 
{ 
{63,40}, 
{71,35}, 
{85,30}, 
{106,25}, 
{132,20}, 
{153,18}, 
{165,16}, 
{192,14}, 
{214,12}, 
{257,10}, 
{286,9}, 
{319,8}, 
{360,7}, 
{415,6}, 
{480,5}, 
{562,4}, 
{613,3} 
} 


The C function (used in the firmware code):

float readSharp_cm(unsigned char addr) interpolates the values in the lookup table, converting the tension value to distance in centimeters.

Four rangefinders are disposed onto a SensorBar horizontally fixed on the head of the robot, as we can see in the picture below.

Sensor Bar.png

Three of these sensors point straight towards the terrain in front of robot, analyzing terrain’s surface by sensing the distance from bar in three different points.

One sensor points in the march direction and is used to detect obstacles.

The sensors are disposed in this way:

  • two in the center of the bar (one pointing down, one pointing forward)
  • on in the left limit of the bar (pointing down)
  • one in the right limit of the bar (pointing down)

Robot takes samples from all three sensors, and then compares them: If the distances are all the same (with a little tolerance), terrain is walkable. If the difference between right and center distances is high, robot turns slightly right If the difference between left and center distances is high, robot turns slightly left.

Before using this approach, I tried to take distances with a single sensor turret, actuated by another Dynamixel servo, but this solution has revealed to be too slow and power consuming, and was abandoned.

As said before in the Introduction of this thesis, this sensor-bar has been conceived thinking at the embodiment concept: it moves with the robot body, giving automatically the sensors the best point of view (in order to have a good perception of terrain and obstacles) automatically. Sensor-bar position and orientation change according to the body configuration, which in turn changes according to the interaction with the environment.

3-axis Accelerometer

Acc-3axis.jpg

In order to know the robot inclination with respect to gravity force vector, a 3-axis accelerometer has been used.

This sensor is produced by Freescale Semiconductor and the model is MMA7361 .

MMA7361

Low Voltage Operation 2.2 V – 3.6 V

High Sensitivity 800 mV/g @ 1.5g

Selectable Sensitivity (±1.5g, ±6g)

Low Current Comsumption 400 µA


Table 4: Accelerometer - MMA7361

I bought a ready to use “breakout-board” with sensor yet mounted on: you can see it in the photo above.

In this application the selected sensitivity is ±1.5g

The sensor has been mounted on the chassis, the most possible near to the center of mass of robot.

The robot center changes as the body joint moves, so a perfect positioning of the accelerometer has not been possible, but this was not a problem.

The accelerometer orientation is:

  • x axis points towards robot forward sense of march, horizontally with respect to floor
  • y axis is disposed horizontally with respect to floor, pointing to the left of robot
  • z axis exactly in vertical position, pointing against gravity force vector.

The convention I used is to consider each axis in standard orientation when it is parallel to the plane normal to gravity vector.

For each axis, the implemented controller computes the displacement_angle from standard orientation.

The method used to determine this displacement_angle is very simple: Each of three channels values are normalized with respect to the gravity force When robot is in standard position, values are 0 for y,x channels, 1 (100% gravity force) for the z channel.

The orientation of each axis is computed as:

displacement_angle = arcsin(channel_value_N)

where channel_value_N is channel value normalized to gravity module.

Each channel value is equal to cosin(gamma), where gamma is the angle between the axis and the gravity vector


Computation of displacement_angle:


channel_value = g * cosin(gamma) 

but we want to know the normalized value , so channel_value_N = channel_value / 

g = cosin(gamma) 

The standard position is 90° wrt gravity vector, so the displacement_angle, we call it delta, is: 

delta = 90° - gamma 

so 

gamma = 90° - delta 

so 

channel_value_N = cosin(90° - delta) 

Knowing that 

sin(delta) = cosin(90° - delta) 

we can  say 

channel_value_N = sin(delta) 

and finally 

displacement_angle = delta = arcsin(channel_value_N)

Power

Transformer

Robot has been powered by AC-DC transformer during the development phase. The transformer I used has this specifications: Output Voltage 12V

  • Max current 5A max

Robotis Transformer.jpg

Batteries

When the robot development has been completed, robot has been equipped with a couple of 2-cells lithium polymer batteries.

Batteries specifications:

  • Output Voltage 7.5V
  • Battery capacity 2500 mAh

Due to the lower tension of battery with respect to transformer, servo’s speed has been slightly increased in order to ensure a sufficient torque

LionHell Battery.jpg


Firmware

The implemented firmware was initially conceived to be the only program to control the robot.

After some testing, the used microcontroller has revealed to be too less powerful in order to obtain an acceptable loop speed and a sufficiently complex computational capability. A complex control like motion planning needs a more performant computational system.

I decided to mantain a fast reactive behavior based control in the main loop, adding a serial communication phase in order to allow data exchange with external control hardware, like a PC. A deep analysis of the behavior based control in mobile robotics can be found in a recent work from L. De Silva and H. Ekanayake [18]: they discuss several behavior control paradigms, including the subsumption.

In remote control applications, a simple control like this will act as a cerebellum, assisting the remote user in the motion control. A recent work on this topic has been made by Shigang cui, Zhengguang lian, Li zhao, Zhigang bing, Hongda chen [19].

They discuss several behavior control paradigms, including the subsumption.

The implemented loop resulted to be very fast, and sufficient to manage the most critical behaviors, like falling prevention and obstacle climbing.

The main control loop consists of this macro blocks:

  • Read and Communicate Sensors Data
  • Set Speed According to Body Inclination
  • Main Behaviors
    • Jump Down Behavior
    • Terrain Check Behavior
    • Approaching Obstacle Behavior
    • Adapt to Floor Behavior
  • Walking Actions
    • Go Backward
    • Turn Left
    • Turn Right
    • Restart Walking
    • Stop Walking
  • Tail Control Section
    • Tail Behaviors Manager
    • Tail Behavior 1: Avoiding Falling Backward
    • Tail Behavior 2: Climbing

Read and Communicate Sensors Data

The first thing to do in the main loop is reading sensors, and communicating them to the eventual external hardware through the serial-usb link.

Reading Sensors

This is done using this funcion:

  • void readAllSensors(Sensors *s);

It reads all sensors data saving them into a Sensors structure.

The above function calls a specific read function for each sensor:

  • float readSharp_cm(unsigned char addr);

It reads the value of Sharp sensor mapped at address addr and convert it to distance in centimeters.

Each address indicates a channel on the distance sensors multiplexer.

  • float readAccDeg(unsigned char addr);

It reads the angle value from the Accelerometer Channel at address addr, and converts it to degrees.

Each address indicates a channel on the accelerometer multiplexer, and each multiplexer channel correspond to a single channel on the accelerometer.

Accelerometer, as seen before, has 3 channels, one for each axis.

Communicating sensor data

The communication is performed through a serial link in asynchronous mode, at a baudarate of 57600 bps.

The serial format is 8bit, no parity, 1 stop bit.

The data format is the following: 

FC <FC>\tGC <GC>\tGL <GL>\tGR <GR>\tZ <Z>\tX <X>\tY <Y>\tAD <AD>\tTD <TD>\n 

and this is the meaning of the tags: 

<FC> : Distance in cm from Central Front Sensor 
<GC> : Distance [cm] from Central Ground Sensor 
<GL> : Distance [cm] from Left Ground Sensor 
<GR> : Distance [cm] from Rigth Ground Sensor 
 <Z> : Normalized [adim] value from Z axis Channel on Accelerometer 
 <X> : Normalized [adim] value from X axis Channel on Accelerometer 
 <Y> : Normalized [adim] value from Y axis Channel on Accelerometer 
<AD> : Abdomen Inclination angle [deg] with respect to the robot body 
<TD> : Tail Inclination angle [deg] with respect to the robot body 


This data is intended to be read from the serial-usb interface using a sscanf function implemented in any programming language.

All transmitted values are integers ( %d in C, C++ format ).

This is the output we get connecting to it : 
... 
FC 39 GC 17 GL 19 GR 19 Z 932 X -24 Y 43 AD -34 TD -37 
FC 39 GC 16 GL 18 GR 18 Z 1000 X 48 Y 92 AD -34 TD -37 
FC 39 GC 15 GL 18 GR 19 Z 1000 X 54 Y 37 AD -34 TD -37 
...


Set Speed According to Body Inclination

In order to adapt the servomotors torque to the current ground surface, the robot must increase their speed according to the vertical inclination of the robot body.

If the inclination value is high and positive, the robot is walking uphill, so the torque must be increased.

The following instruction sets the nominal speed for all whegs servos: dnspeed

(Desidered Nominal Speed) : dnspeed = (600 + 4 *sensors.body_inclination_xg);

Dynamixel servos accept a speed value from 0 to 1023.

Here we set 600 as base-speed, then adding a variation proportional to inclination.

If the inclination is negative (robot walking downhill) the added variation will be negative, ending up with a speed value smaller than base-speed.


Main Behaviors

This behaviors determine the commands that will be sent to the whegs in the following Walking Actions section.

All this behaviors are exclusive, and they have descending priority, so that the first has the high one and the last has the lower one.

Each behavior has a trigger event that I call “situation”.

Before going to process the behaviors, some data must be prepared.

float ld = abs((int)(sensors.distance_floor_left – sensors.distance_floor_center));

float rd = abs((int)(sensors.distance_floor_right – sensors.distance_floor_center));


The above two instructions compute two difference values:

  • ld : Left Difference This is the difference value between the left terrain distance sensor and the center terrain distance sensor
  • rd : Right Difference This is the difference value between the right terrain distance sensor and the center terrain distance sensor.

This difference values will be used within the following behaviors in order to detect the current situation.


Jump Down Behavior

Situation 1:

Robot’s head is facing floor with an abdomen inclination inferior to -45 ° with respect to gravity force vector
AND distance from floor along the view axis is less than 30 cm.

In this situation the robot will probably crash his head to the floor if it doesn’t lift it Instantly, so the first command is to stop walking.

This situation requires that the distance from floor is less than 30 cm, so that the robot could “jump” toward floor without destroying itself.


Behavior 1:

Then the robot lift up the abdomen until it exits from this situation.


Code

if (sensors.abdomen_inclination_g < -45 && sensors.distance_front_center < 30){ 
stop();//STOP ROBOT 
while(sensors.abdomen_inclination_g < -45 && sensors.distance_front_center < 30) 
  { 
  //LIFT ABDOMEN 
  dpAbd = dpAbd + 1; 
  setAbdomenDeg(dpAbd, 1000);//Lift 
  sensors.abdomen_inclination_g = getAbdomenDegG(); 
  sensors.distance_front_center = readSharp_cm(4); 
  } 
}

Terrain Check Behavior

This behaviors uses the Left Difference (ld) and Right Difference (rd) described before in chapter 5.3.

Situation 2:

Left Difference or Right Difference is greater than 8 cm.

This means that terrain is not uniform.

Behavior 2:

turn where the difference is smaller. 

Code:

if(ld > 8 || rd > 8) 
{ 
 if (ld >= rd) {turnR = 1; turnL=0;} 
 if (ld < rd) {turnL = 1; turnR=0;} 
}

Approaching Obstacle Behavior

Situation 3 :

There is an obstacle near in front of the robot in central position.

Obstacle is considered near if distance is less than 15 cm.

Behavior 3 :

climb over  the osbtacle.

The sequence of actions to perform is :

1. stop walking 
2. lift head (abdomen) until obstacle diappears and abdomen inclination doesn't 
    exceed 80°. This limit has been imposed in order to avoid vain climbing efforts 
    on almost perpendicular walls. 

Code:

if (sensors.distance_front_center <  15) 
{ 
  stop(); 
  while(sensors.distance_front_center < 15 && sensors.abdomen_inclination < 80) 
  { 
   if (dpAbd > 80)dpAbd = 80; //Upper Bound setAbdomenDeg(dpAbd, 200);//Lift up 
   abdomen sensors.distance_front_center = readSharp_cm(4); //read distance 
  } 
}


Adapt to Floor Behavior

Situation 4 :

Distance from floor is greater than 23 cm 

This happens when the abdomen is too high, or when robot approaches a descent .

In order to have a good sensing of the terrain the sensors array should point the floor perpendiculary (and so abdomen should be parallel to terrain).

Due to the geometry of robot (his height is about 23 cm), lowering abdomen until it's 23 cm distant from floor will put it parallel to floor surface.


Behavior 4 :

Lower the abdomen until distance of  head  from floor is less than 23 cm 
or it's tilted down more than 75° 

Code:

if(sensors.distance_floor_center > 23 )
{ // Floor too distant .. 
  stop(); //stop walking 
  while(sensors.distance_floor_center > 23 && sensors.abdomen_inclination > -75) 
  { 
    dpAbd = dpAbd – 1; // Lower down Abdomen 
    if (dpAbd < -75)dpAbd = -75; // Limit value 
    setAbdomenDeg(dpAbd, 200);//send command to servomotor 
    sensors.distance_floor_center = readSharp_cm(6); 
  } 
}


Walking Actions

The purpose of this section is to send commands to servomotors, in order to perform the movements requested by the previous behaviors section.

The first instruction of this section is a control statement that checks if the robot should be walking or not.

This is accomplished by reading the value of a condition variable called walking.

This condition variable is set within the previous behaviors section.

Code:

if (walking==1) 
{ 
  … 
} 

The other condition variables used to control this section are:

turnL//Turn Left 
turnR//Turn Right 

Go Backward

The way behaviors inform this section that the robot must bo backward is just enabling both turn condition variables : turnL and turnR.

Code:

If(turnL && turnR) 
{ 
  int i ; 
  for (i=0;i<3;i++){//Go Back 
     dxl_write_word( whegs_sx[i], P_MOVING_SPEED_L, 1424 ); 
     dxl_write_word( whegs_dx[i], P_MOVING_SPEED_L, 400 ); 
     _delay_ms(20000);//Mantain behavior 
     //Disable behavior.. 
     turnL = 0; 
     turnR = 0; 
  } 
}
 

Turn Left

Turning Left is accomplished by going backward with the left train of whegs, keeping still the right one.

Behavior is mantained for a while, and then condition variable are cleared.

if(turnL) 
{ 
  int i ; 
  for (i=0;i<3;i++) //iterate on all servos { 
     dxl_write_word( whegs_sx[i], P_MOVING_SPEED_L, 1424 ); 
     dxl_write_word( whegs_dx[i], P_MOVING_SPEED_L, 0 ); 
     _delay_ms(20000);//Mantain behavior 
     //Disable behavior.. 
     turnL = 0; 
     turnR = 0; 
  } 
} 

Turn Right

Same as Turn Left.

if(turnR){ 
  int i ; 
  for (i=0;i<3;i++){ 
     dxl_write_word( whegs_sx[i], P_MOVING_SPEED_L, 0 ); 
     dxl_write_word( whegs_dx[i], P_MOVING_SPEED_L, 400 ); 
     _delay_ms(20000);//Mantain behavior 
     //Disable behavior.. 
     turnL = 0; 
     turnR = 0; 
  } 
} 

Restart Walking

This section is needed to make the robot restart walking in two cases:

  • it was stopped before
  • it was turning
if (!(turnL + turnR)){//If not turning 
  go_fwd();//Go forward 
}


Stop Walking

If the walking condition variable is not set, the robot just stops walking.

If (walking==1) 
{ 
  … 
} 
else 
{ 
  stop(); //Stop Walking 
}

Tail Control Section

In this section we control the tail, in order to help robot to accomplish some tasks.

This part is located after the Walking Actions section, because it do not modifies any walking control variable.

Tail Behaviors Manager

This section acts like a behavior manager, it mantains a behavior until it accomplishes its task.

It checks if tails has reached (with little toelrance) the desidered position and, in positive case, it disables the torque on tail servomotor.

Then it disables all tail behaviors by clearing dpTail control variable.

// Check if desidered Tail position (if it was set) has been reached 
if(dpTail != -1 && abs((int)dpTail - (int)pTail) < 50) 
{ 
  dxl_write_word( 1, P_TORQUE_ENABLE, 0 ); 
  // Disable Torsion Servo 
  // Needed to shut off tail behaviors 
  // activated in previous loop cycle  
  dpTail = -1; //disable desidered Tail position 
}


Tail Behavior 1: Avoiding Falling Backward

Situation 5 :

• Tail is high (wrt body)
• Abdomen isn't low (wrt body) 
• Body is tilted up more than 45° with respect to gravity vector 

In this situation the robot is likely to fall backward, so robot body must be put in a less dangerous configuration.

Behavior 5 :

Lower the tail until it’s almost in line with body (horizontal position) 

Putting tail in line with body makes the back of the robot to lift up.

In this way robot’s center of mass is moved forward, towards the central position, putting the whole body in a safer position.

Code:

if ( parallel && pTail < 300 &&  // Tail is high 
     getAbdomenDeg() >-10 && // Abdomen isn’t low (wrt body) 
     readAccDeg(1) > 45) // Body is tilted up more than 45 deg wrt g 
{ 
   //avoid falling backwards  
   dpTail = 500; 
   dxl_write_word( 1, P_GOAL_POSITION_L, dpTail ); 
   dxl_write_word( 1, P_MOVING_SPEED_L, 210 ); 
} 


Tail Behavior 2: Climbing

Situation 6 :

• Tail is slightly up (wrt body) 
• Abdomen is slightly low (wrt body) 
• Body is tilted up more than 60° with respect to gravity vector 

In this situation, robot's body is very tilted up, and abdomen is slightly tilted down.

This means that robot is climbing over an obstacle. 

Behavior 6 :

Lower the Tail until it’s quite lower than the horizontal position.

If the tail is slightly upper than the horizontal position, it should be lowered down, in order to help robot in the climbing task.

Lowering tail helps because in this way the robot’s back is lifted up, and this moves the center of mass forward, causing the frontal whegs to exert a greater pressure on terrain.

Great pressure on terrain ensures more grip, and so robot can easily bring its body forward, accomplishing the climbing task.

if ( parallel && pTail < 450 && // Tail is slightly up 
     getAbdomenDeg() < -20 && // Abdomen is slightly low 
     readAccDeg(1) > 60 ) // Body is tilted up more than 60 deg wrt g 
{ //climb 
   dpTail = 712; 
   dxl_write_word( 1, P_GOAL_POSITION_L, dpTail ); 
   dxl_write_word( 1, P_MOVING_SPEED_L, 210 ); 
}

Flow Chart

Firmware Flow Chart

Experiments

LionHell McMillan walking on rough natural terrain

LionHell McMillan ROBOT - Walking on Rough Terrain

Download