Difference between revisions of "LionHell McMillan"

From AIRWiki
Jump to: navigation, search
m
 
(26 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
|title=LionHell McMillan
 
|title=LionHell McMillan
 
|coordinator=GiuseppinaGini
 
|coordinator=GiuseppinaGini
|tutor=MicheleFolgheraiter
 
 
|students=VittorioLumare;  
 
|students=VittorioLumare;  
 
|resarea=Robotics
 
|resarea=Robotics
 
|restopic=Robot development;  
 
|restopic=Robot development;  
 
|start=2011/09/10
 
|start=2011/09/10
|end=2012/??/??
+
|end=2012/07/20
|status=Open
+
|status=Closed
 
|level=Ms
 
|level=Ms
 
|type=Thesis
 
|type=Thesis
Line 14: Line 13:
  
  
 +
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".
  
'''Robot Mobile con Controllo Neurale Bioispirato al Grillo Bimaculato.'''
+
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
  
E' possibile vedere dei video che mostrano il suo movimento a quest'indirizzo : [http://www.youtube.com/watch?v=sXdNOFMBreM].
+
{{#evp:youtube|QbMM9orBUn0|LionHell McMillan ROBOT - Walking on Rough Terrain|center|600}}
  
 +
==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===
  
==Idea==
+
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.
===Punto di Partenza===
+
  
[[file:grillo_bimaculato.jpg|right]]
+
==State of The Art==
Lo scopo di trovare il luogo in cui si trova un oggetto, senza sapere nulla riguardo alla sua
+
* [http://biorobots.cwru.edu/projects/whegs/ Whegs I]
posizione, nè rispetto a sè nè rispetto ad altri punti di riferimento, ma basandosi unicamente sulle
+
* [http://biorobots.cwru.edu/projects/whegs/ Whegs II]
sensazioni istantanee, è e sarà sempre uno dei compiti più comuni e importanti per qualsiasi entità
+
* [http://biorobots.cwru.edu/projects/whegs/ Autonomous Whegs II]
mobile autonoma, vivente o non vivente che sia.  
+
* [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]
  
Quando poi è uno solo il senso che puo' aiutare a muoversi nella direzione giusta, bisogna avere la
+
==Simulations / Design==
massima fiducia in esso e quindi una grande padronanza nell'utilizzarlo.  
+
===Simulation 1===
 +
The first robot model has been taken from an existent robot : [http://airlab.elet.polimi.it/index.php/EMBOT EMBOT]
  
Il grillo bimaculato è un esempio di come la natura sia riuscita a creare un sistema che assolve a
+
This is a video of the first simulation with this model
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
+
{{#evp:youtube|3aurAnj120Q|First simulation|center|400}}
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
+
As can be seen from simulation, robot model is unsuitable to the task.
trasportate dal suono, ed essendo un insetto possiede un apparato cerebrale tale da permettergli
+
un'elaborazione molto ridotta delle informazioni acquisite.
+
  
===Obiettivo===
+
The model has been then improved extending the body length of about 5 cm.
  
L'obiettivo del progetto Robot Grillo è stato replicare il sistema del  grillo su un sistema robotico e verificarne il
+
===Simulation 2===
funzionamento valutando le prestazioni e i comportamenti assunti dal robot.
+
  
  
==Stato dell'Arte==
+
Second simulation:
  
 +
{{#evp:youtube|Ffu8eFY3Tug|Second simulation|center|400}}
  
[[file:kephera.png|200px|right|thumb| Robot Khepera con due microfoni]]
+
Now robot is able to climb all the steps, but this is not enough.
Il progetto del Robot Grillo è basato sui lavori precedentemente svolti dalla Prof.ssa Barbara Webb e altri
+
The objective is harder: we want the robot to climb obstacles big as its body size, so I made another simulation  with bigger obstacles:
<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>
+
.
+
  
 +
{{#evp:youtube|_95LjvVVByw|Third simulation|center|400}}
  
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.
+
Despite its longer body, the robot is unable to climb over the step.  
  
Possiamo vedere il robot Kephera nella foto qui a destra.
+
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
  
 +
{{#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
 
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
+
===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,
+
[[file:lionhell_v2.jpg|600px|LionHell Final Prototype]]
evitare eventuali ostacoli di fronte a lui e infine di raggiungere il luogo di provenienza del suono.  
+
  
 +
=Hardware=
  
 +
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'''
  
===Sistema di Elaborazione Neurale===
+
Illustration 42: 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
+
Table 1: Servomotor - Dynamixel AX-12
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.
+
In this case the dead band did not cause any problem, because a 180° movement was sufficient for the purpose.  
  
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> .  
+
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.
  
Questo tipo di rete sfrutta i 2 ingressi dai microfoni per decidere quanta potenza dare ai due motori
+
==Control Board==
del differential drive, il tutto sfruttando solo 4 collegamenti neurali, 2 eccitatori e 2 inibitori.  
+
[[file:cm510.png|right]]
 +
The '''central processing unit''' used is a ''CM-510''.  
  
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.
+
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)
  
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.
+
Table 2: 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
+
Illustration 43: Control Board - CM-510
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==
 
===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
+
The board below multiplexes the analog signal from each accelerometer channel, in order to use a single analog input on the CM-510 Board.
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 .  
+
[[file: Accelerometer_Multiplexer_Board.jpg]]
  
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
 
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:
+
For time reasons I've implemented both boards quickly by manually building the circuit tracks.
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.
+
In more relaxed circumstances I would have made the same boards by PCB photo-etching.
  
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.  
+
===Infrared Rangefinders===
 +
[[file:GP2D120X.jpg|right]]
 +
Terrain need to be analyzed in order to know if it's possible walking over it.
  
Gli encoder montati sui motori vengono usati anche per odometria, che viene gestita dal sistema su PC per disegnare il percorso compiuto dal robot.  
+
If the terrain roughness is high, it is avoided: the robot turns left or right searching for a
 +
better path.  
  
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
+
The key concept adopted to detect if a terrain is too rough is this: robot needs a planar
centrale di controllo neurale.  
+
surface in order to climb over it without possibility of falling.  
  
Il PIC comunica col PC tramite cavo seriale alla velocità di 9600 baud/s.  
+
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.  
  
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
+
Main specifications
seriale.  
+
'''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
  
In ricezione il PIC accetta solo i due comandi di velocità ai motori.
 
  
====Sezione Audio====
 
  
I due microfoni usati sono a bobina, unidirezionali di tipo cardioide, pensati per amplificare la
+
The output distance characteristics of sensor is shown in the picture below.  
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
 
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>.
+
[[file:SHARP_GP2D120X_diagram.png]]
  
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.
  
====Sezione Rilevamento Ostacoli====
+
Four rangefinders are disposed onto a ''SensorBar'' horizontally fixed on the head of the robot, as we can see in the picture below.
[[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,
+
[[file:Sensor_Bar.png]]
suddivisi in due sezioni, destra e sinistra, ognuna composta da 8-9 led. E' mostrato in figura
+
  
La corrente che attiva i led è distribuita in egual misura su ogni led, così che venga illuminata
+
Three of these sensors point straight towards the terrain in front of robot, analyzing
uniformemente tutta la zona di rilevazione alla relativa sezione attivata.  
+
terrain’s surface by sensing the distance from bar in three different points.  
  
I sensori di rilevazione <ref>Vishay Telefunken, TSOP17..SE1 “Photo Modules for PCM Remote Control Systems”
+
One sensor points in the march direction and is used to detect obstacles.  
Datasheet,  www.vishay.com</ref> sono 4 e sono posti dietro ai led e coprono l'intera area di rilevazione
+
intorno alla parte frontale del robot.  
+
  
[[file:robot_grillo_zoom_sensors.jpg|300px|thumb|left|Robot Grillo:  I 4 Sensori IR disposti a semicerchio]]
+
The sensors are disposed in this way:  
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.
+
* 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)
  
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.
+
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.
  
Questa semplificazione permette di ridurre il numero dei cavi e dei segnali da elaborare.  
+
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.  
  
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.
+
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.
  
Vengono effettuati 4 livelli di controllo per ogni sezione.
+
===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.  
  
Ogni livello corrisponde ad un range di distanza di rilevazione.
+
This sensor is produced by Freescale Semiconductor and the model is MMA7361 .  
  
Il livello 1 è il piu' vicino, ovvero rileva solo ostacoli entro 5 cm circa dal perimetro della barriera, gli altri 3
+
'''MMA7361'''
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
+
Low Voltage Operation 2.2 V – 3.6 V 
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à
+
High Sensitivity 800 mV/g @ 1.5g
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.  
+
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.
  
====Sezione Motori====
+
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.  
[[file:robot_grillo_foto_motore_scritte.gif|500px|thumb|right|Robot Grillo: Zona motore]]
+
  
I motori sono dei Brushed a Corrente Continua, con velocità massima a 12 V di circa 6000 rpm ,  
+
The accelerometer  orientation is:
ridotti con una scatola di ingranaggi con rapporto 30:1 per avere più forza trainante.
+
* 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.  
  
La velocità angolare massima risultante è di circa 200 rpm, ovvero 3,33 rps, il che significa, dato il diametro di
+
The convention I used is to consider each axis in standard orientation when it is '''parallel''' to the '''plane normal to gravity vector'''.  
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
+
For each axis, the implemented controller computes the ''displacement_angle'' from ''standard orientation''.  
(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 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.  
nero) che si alterna sul disco encoder e dà in uscita un valore logico (0v o 5v) alternato.
+
  
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.
+
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'''.  
  
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à.
+
Each channel value is equal to cosin(gamma), where gamma is the angle between the axis and the gravity vector
  
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.
 
  
All'aumentare del duty cycle aumenta il numero di volte nel tempo in cui viene attivato il motore.
+
'''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)''
  
La scheda H-Bridge, che è l'ultimo stadio prima dei motori, riceve i due treni di impulsi a 0 - 5
+
==Power==
Volts, pilotando così le tensioni di alimentazione ai motori, che vanno da 0 a 12 Volts.
+
===Transformer===
  
Il PIC, potendo quindi inviare potenza variabile ai motori, e conoscendo la velocità alla quale
+
Robot has been powered by AC-DC transformer during the development phase.
stanno andando, può effettuare un controllo in feedback calcolando l'errore rispetto alla velocità
+
The transformer I used has this specifications: Output Voltage 12V
desiderata.
+
* Max current  5A max
  
Tale controllo è stato implementato con un algoritmo PID, di cui attualmente sono
+
[[file:Robotis_Transformer.jpg]]
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
+
===Batteries===
questo studio non è risultato necessario.
+
  
 +
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
  
====Sezione Comunicazione Robot-PC====
+
[[file:LionHell_Battery.jpg]]
  
I dati rilevati ( suono , ostacoli e velocità ruote), sono inviati al PC su canali diversi accorpati in un
 
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
+
=Firmware=
vanno dai microfoni alla scheda audio del PC, altri 2 poli sono i canali RX e TX della seriale.
+
  
Il due canali audio trasmettono i segnali in forma grezza come variazione di tensione nel tempo.
+
The implemented firmware was initially conceived to be the only program to control the
 +
robot.  
  
Essendo tutti i sottocavi all'interno della stessa calza, sono presenti  fenomeni di mutua induzione,  
+
After some testing, the used microcontroller has revealed to be too less powerful in
soprattutto da parte del canale seriale verso quello audio, che risulta così disturbato.
+
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.  
  
Tale disturbo è stato eliminato col filtraggio a 1 kHz, comunque richiesto anche per motivi connessi al livello di
+
I decided to mantain a fast reactive behavior based control  in the main loop, adding a
rilevazione dei microfoni e al carico di elaborazione da parte del PC.  
+
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.  
  
Il canale seriale è pilotato dal PIC , ed ha il seguente funzionamento in cui il MASTER è il PC e lo
+
In remote control applications, a simple control like this will act as a cerebellum,
SLAVE è il PIC:
+
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 PC INVIA un pacchetto di comandi al PIC
+
They discuss several behavior control paradigms, including the subsumption.
# il PIC lancia un interrupt e si dedica istantaneamente alla registrazione del pacchetto
+
# 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 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
 
   
 
   
Formato Paccetto TX:
+
==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.
  
“XXXAYYY7”
+
===Reading Sensors===
 +
This is done using this funcion:
  
* XXX è il valore della Velocità desiderata del Motore Sinistro in 3 cifre
+
*void readAllSensors(Sensors *s);
* YYY è il valore della Velocità desiderata del Motore Sinistro in 3 cifre
+
It reads all sensors data saving them into a Sensors structure.  
* 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.
+
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.
  
Formato Pacchetto RX:
+
Each address indicates a channel on the distance sensors multiplexer.
 +
*float readAccDeg(unsigned char addr);
  
* “S(TAB)(CSX)(TAB)(CDX)(TAB)(OBSTSX)(TAB)(OBSTDX)(TAB)E”
+
It reads the angle value from the Accelerometer Channel at address addr, and
* S : carattere Ascii delimitatore di Inizio pacchetto
+
converts it to degrees.
* 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
+
  
 +
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.
  
===Software===
+
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
  
Il software che gira sul PC è Matlab, di cui viene usato il ToolBox Simulink per l'implementazione
 
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.
+
This data is intended to be read from the serial-usb interface using a sscanf function
Il blocco centrale è la rete neurale basata su quella del grillo, essa riceve i segnali a sinistra e li
+
implemented in any programming language.  
processa in 3 stadi.  
+
  
I segnali che arrivano all'ingresso del controllore neurale sono pretrattati, sempre in matlab.  
+
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
 +
...
  
====Discretizzazione Temporale====
 
  
Tutte le operazioni del sistema avvengono in quanti di tempo.
+
==Set Speed According to Body Inclination==
  
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
+
In order to adapt the servomotors torque to the current ground surface, the robot must
dei segnali dalla rete e il loro invio alle ruote, e infine i log dei dati in una matrice che aumenta di
+
increase their speed according to the vertical inclination of the robot body.  
una riga dati ad ogni quanto.  
+
  
 +
If the inclination value is high and positive, the robot is walking uphill, so the torque
 +
must be increased.
  
====Logging====
+
The following instruction sets the nominal speed for all whegs servos: ''dnspeed''
  
Nella matrice di log dei dati provenienti dal PIC vengono salvati i valori dei sensori di prossimità,
+
(Desidered Nominal Speed) : dnspeed = (600 + 4 *sensors.body_inclination_xg);
delle velocità delle ruote.
+
  
Altre 3 matrici di log sono dedicate al salvataggio dei valori dei neuroni dei 3 strati.  
+
Dynamixel servos accept a speed value from 0 to 1023.  
  
* inNeur : contiene in valori dello strato di input
+
Here we set 600 as base-speed, then adding a variation proportional to inclination.
* 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
+
If the inclination is negative (robot walking downhill) the added variation will be
rappresentazione su piano cartesiano dei dati nel tempo e alla rappresentazione grafica
+
negative, ending up with a speed value smaller than base-speed.  
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.
 
  
 +
==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”.
  
====Filtraggio e pre-elaborazione dati====
+
Before going to process  the behaviors, some data must be prepared.
  
I due canali audio vengono filtrati con un filtro passa-banda molto selettivo impostato intorno a
+
''float ld = abs((int)(sensors.distance_floor_left – sensors.distance_floor_center));''
1kHz, che è la frequenza emessa dalla sorgente sonora che il robot dovra raggiungere.
+
 +
''float rd = abs((int)(sensors.distance_floor_right – sensors.distance_floor_center));''
  
Una volta filtrato, il segnale audio viene suddiviso pacchetti di campioni, e ogni pacchetto (per ogni canale)
 
viene elaborato nel quanto di tempo.
 
  
L'elaborazione consiste nel calcolare il valore assoluto che sarà inviato agli ingressi della rete.
+
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);
 +
  }
 +
}
 +
 
 
   
 
   
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 17: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