Diferencia entre revisiones de «Python»

De Proyecto Butiá
Saltar a: navegación, buscar
Línea 8: Línea 8:
 
butiabot = butiaAPI.robot()
 
butiabot = butiaAPI.robot()
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
APERTURA:
 
APERTURA:
  
 +
<syntaxhighlight lang="python">
 
butiabot.abrirButia()
 
butiabot.abrirButia()
 +
</syntaxhighlight>
  
 
VERSIÓN:
 
VERSIÓN:
Línea 16: Línea 19:
 
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  
  
 +
<syntaxhighlight lang="python">
 
ver = butiabot.getVersion()
 
ver = butiabot.getVersion()
 
print ver
 
print ver
 +
</syntaxhighlight>
  
 
CERRAR comunicación con el servidor lubot
 
CERRAR comunicación con el servidor lubot
  
 +
<syntaxhighlight lang="python">
 
butiabot.cerrar()
 
butiabot.cerrar()
 +
</syntaxhighlight>
 +
 
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
  
 +
<syntaxhighlight lang="python">
 
butiabot.reconnect (address, port)
 
butiabot.reconnect (address, port)
 
+
</syntaxhighlight>
  
 
MÓDULOS:  
 
MÓDULOS:  
Línea 32: Línea 41:
 
listarModulos:
 
listarModulos:
 
devuelve la lista de los modulos disponibles en el firmware de la placa
 
devuelve la lista de los modulos disponibles en el firmware de la placa
 +
 +
<syntaxhighlight lang="python">
 
modulos = butiabot.listarModulos()
 
modulos = butiabot.listarModulos()
 
print modulos
 
print modulos
 +
</syntaxhighlight>
  
 
abrirModulo:
 
abrirModulo:
 
Apertura de modulos, abre el modulo "moduloname"
 
Apertura de modulos, abre el modulo "moduloname"
 +
 +
<syntaxhighlight lang="python">
 
butiabot.abrirModulo (moduloname)
 
butiabot.abrirModulo (moduloname)
 +
</syntaxhighlight>
  
 
llamarModulo:
 
llamarModulo:
 
Operacion de llamada de una funcion de un modulo (CALL)
 
Operacion de llamada de una funcion de un modulo (CALL)
butiabot.llamarModulo(modulename, function , params = "")
 
  
 +
<syntaxhighlight lang="python">
 +
butiabot.llamarModulo(modulename, function , params = "")
 +
</syntaxhighlight>
  
  
Línea 54: Línea 71:
 
Abrir módulo loopBack: modulo de ayuda presente en el butia (open)
 
Abrir módulo loopBack: modulo de ayuda presente en el butia (open)
  
 +
<syntaxhighlight lang="python">
 
butiabot.abrirLback()
 
butiabot.abrirLback()
 
datoRet = butiabot.loopBack("hola")
 
datoRet = butiabot.loopBack("hola")
 
+
</syntaxhighlight>
  
 
loopBack:  
 
loopBack:  
 
envia un mensaje a la placa y espera recibir exactamente lo que fue enviado
 
envia un mensaje a la placa y espera recibir exactamente lo que fue enviado
  
 +
<syntaxhighlight lang="python">
 
butiabot.loopBack(data)
 
butiabot.loopBack(data)
 
+
</syntaxhighlight>
  
  
Línea 69: Línea 88:
  
 
abrirMotores:
 
abrirMotores:
 +
 +
<syntaxhighlight lang="python">
 
butiabot.abrirMotores()
 
butiabot.abrirMotores()
 
butiabot.setVelocidadMotores(self, sentidoIzq = "0", velIzq = "0", sentidoDer = "0", velDer = "0")
 
butiabot.setVelocidadMotores(self, sentidoIzq = "0", velIzq = "0", sentidoDer = "0", velDer = "0")
Línea 86: Línea 107:
 
print datoRet4
 
print datoRet4
 
datoRet4 = butiabot.setVelMotor("1","1","0")
 
datoRet4 = butiabot.setVelMotor("1","1","0")
 
+
</syntaxhighlight>
  
 
SENSORES:
 
SENSORES:
Línea 97: Línea 118:
 
getValSenDigital(pinDig = "0"):
 
getValSenDigital(pinDig = "0"):
  
 
+
<syntaxhighlight lang="python">
 
butiabot.abrirSensor()
 
butiabot.abrirSensor()
 
sen1 = butiabot.getValSenAnalog("2")
 
sen1 = butiabot.getValSenAnalog("2")
Línea 105: Línea 126:
 
sen3 = butiabot.getValSenDigital("5")
 
sen3 = butiabot.getValSenDigital("5")
 
print sen3
 
print sen3
 
+
</syntaxhighlight>
 
+
  
 
Operaciones solicitadas al modulo de la placa, driver butia.lua
 
Operaciones solicitadas al modulo de la placa, driver butia.lua
Línea 117: Línea 137:
 
getCargaBateria()
 
getCargaBateria()
  
 +
<syntaxhighlight lang="python">
 
carga = butiabot.getCargaBateria()
 
carga = butiabot.getCargaBateria()
 
print carga
 
print carga
 
+
</syntaxhighlight>
  
  

Revisión del 21:48 19 jun 2011

API de Butiá:

Descripción de las funciones y algunos ejemplos.

INSTANCIAR CLASE:

butiabot = butiaAPI.robot()

APERTURA:

butiabot.abrirButia()

VERSIÓN: getVersion Devuelve la version del firmware de la placa con el que estamos trabajando

ver = butiabot.getVersion()
print ver

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)