Diferencia entre revisiones de «Python»

De Proyecto Butiá
Saltar a: navegación, buscar
Línea 6: Línea 6:
 
<source lang="python">
 
<source lang="python">
 
butiabot = butiaAPI.robot()
 
butiabot = butiaAPI.robot()
</source>
 
  
 
APERTURA:
 
APERTURA:
 
<source lang="python">
 
<source lang="python">
 
butiabot.abrirButia()
 
butiabot.abrirButia()
</source>
+
 
 
VERSIÓN:
 
VERSIÓN:
 
getVersion
 
getVersion
 
Devuelve la version del firmware de la placa con el que estamos trabajando  
 
Devuelve la version del firmware de la placa con el que estamos trabajando  
<source lang="python">
+
<syntaxhighlight lang="python">
 
ver = butiabot.getVersion()
 
ver = butiabot.getVersion()
 
print ver
 
print ver
</source>
+
</syntaxhighlight>
 +
CERRAR comunicación con el servidor lubot
  
CERRAR comunicación con el servidor lubot
 
<source lang="python">
 
 
butiabot.cerrar()
 
butiabot.cerrar()
</source>
 
 
CONEXIÓN/DESCONEXIÓN CON SERVIDOR:
 
CONEXIÓN/DESCONEXIÓN CON SERVIDOR:
 
Conecta o Reconecta al bobot en address:port
 
Conecta o Reconecta al bobot en address:port

Revisión del 21:27 19 jun 2011

API de Butiá:

Descripción de las funciones y algunos ejemplos.

INSTANCIAR CLASE:

butiabot = butiaAPI.robot()

APERTURA:
<source lang="python">
butiabot.abrirButia()

VERSIÓN:
getVersion
Devuelve la version del firmware de la placa con el que estamos trabajando 
<syntaxhighlight lang="python">
ver = butiabot.getVersion()
print ver
</syntaxhighlight>
CERRAR comunicación con el servidor lubot

butiabot.cerrar()
CONEXIÓN/DESCONEXIÓN CON SERVIDOR:
Conecta o Reconecta al bobot en address:port

butiabot.reconnect (address, port)


MÓDULOS: 

listarModulos:
devuelve la lista de los modulos disponibles en el firmware de la placa
modulos = butiabot.listarModulos()
print modulos

abrirModulo:
Apertura de modulos, abre el modulo "moduloname"
butiabot.abrirModulo (moduloname)

llamarModulo:
Operacion de llamada de una funcion de un modulo (CALL)
butiabot.llamarModulo(modulename, function , params = "")



FUNCIONES VARIAS:

isPresent
Retorna si esta presente el modulo
butiabot.isPresent (moduloname)

abrirLback
Abrir módulo loopBack: modulo de ayuda presente en el butia (open)

butiabot.abrirLback()
datoRet = butiabot.loopBack("hola")


loopBack: 
envia un mensaje a la placa y espera recibir exactamente lo que fue enviado

butiabot.loopBack(data)



MOTORES:
Operaciones solicidatas al driver motores.lua	

abrirMotores:
butiabot.abrirMotores()
butiabot.setVelocidadMotores(self, sentidoIzq = "0", velIzq = "0", sentidoDer = "0", velDer = "0")
butiabot.setVelMotor(self, idMotor = "0", sentido = "0", vel = "0")

datoRet2 = butiabot.setVelocidadMotores("0", "1000", "0", "500")
print datoRet2
time.sleep(1)
datoRet3 = butiabot.setVelocidadMotores("0", "0", "0", "0")
print datoRet3
datoRet4 = butiabot.setVelMotor("0","1","1023")
time.sleep(1)
print datoRet4
datoRet4 = butiabot.setVelMotor("0","1","0")
datoRet4 = butiabot.setVelMotor("1","0","452")
time.sleep(1)
print datoRet4
datoRet4 = butiabot.setVelMotor("1","1","0")


SENSORES:
Operaciones solicitadas al driver de los sensores

abrirSensor()

getValSenAnalog(pinAnalog = "0"):

getValSenDigital(pinDig = "0"):


butiabot.abrirSensor()
sen1 = butiabot.getValSenAnalog("2")
print sen1
sen2 = butiabot.getValSenAnalog("4")
print sen2
sen3 = butiabot.getValSenDigital("5")
print sen3



Operaciones solicitadas al modulo de la placa, driver butia.lua

abrirButia()
ping()

CARGA DE BATERIA
Esta operacion nos devuelve la carga aproximada del pack de pilas del robot con un error de 1 volt.	
getCargaBateria()

carga = butiabot.getCargaBateria()
print carga



		
setVelocidad3(velIzq = 0, velDer = 0)

setPosicion(idMotor = 0, angulo = 0)




Operaciones solicitadas al driver boton4

abrirBoton(self)
		
getBoton(self)
	
getLuzAmbiente(self)

getDistancia(self)
	
getEscalaGris(self)

getTemperature(self)

getVibration(self)

getTilt(self)

getContactoCapacitivo(self)

getInduccionMagnetica(self)

setLed(self, nivel = 255)