Line 35: |
Line 35: |
| events.add( Dist.getDistancia, '>', 700, adelante ) | | events.add( Dist.getDistancia, '>', 700, adelante ) |
| events.go() | | events.go() |
| + | |
| + | ==Simple example (other)== |
| + | Butia with dynamic stability. Take a Butiá, remove idler wheels and place an IR distance sensor pointing to the floor. The button toggles the behavior. |
| + | |
| + | local d --lecturas de distancia |
| + | local eq --posicion de equilibrio de d |
| + | local v --velocidad calculada |
| + | |
| + | while true do |
| + | print ("Presione el botón para comenzar") |
| + | repeat until Boton.getBoton()==1 |
| + | |
| + | eq = Dist.getDistancia() |
| + | |
| + | print("Arrancando", eq) |
| + | util.wait(1) |
| + | |
| + | repeat |
| + | d = Dist.getDistancia() |
| + | v = 100+5*math.abs(d-eq) |
| + | if v > 1024 then v = 1024 end |
| + | if d < eq then |
| + | Motores.setvel2mtr(1, v, 1, v) |
| + | else |
| + | Motores.setvel2mtr(0, v, 0, v) |
| + | end |
| + | until Boton.getBoton()==1 |
| + | |
| + | print("Fin") |
| + | Motores.setvel2mtr(1, 0, 1, 0) |
| + | util.wait(1) |
| + | end |
| | | |
| ==Continue reading in Spanish== | | ==Continue reading in Spanish== |
| [http://www.fing.edu.uy/inco/proyectos/butia/mediawiki/index.php/Butialo] | | [http://www.fing.edu.uy/inco/proyectos/butia/mediawiki/index.php/Butialo] |