Diferencia entre revisiones de «API»

De Proyecto Butiá
Saltar a: navegación, buscar
Línea 3: Línea 3:
 
Descripción de las funciones y algunos ejemplos.
 
Descripción de las funciones y algunos ejemplos.
  
INSTANCIAR CLASE:
+
 
 +
'''Instanciar la clase:'''
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot = butiaAPI.robot()
+
robot = butiaAPI.robot()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
APERTURA:
+
'''Apertura:'''
 +
 
 +
abrirButia
 +
 
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.abrirButia()
+
robot.abrirButia()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
VERSIÓN:
+
'''Versión:'''
 +
 
 
getVersion
 
getVersion
Devuelve la version del firmware de la placa con el que estamos trabajando:
+
Devuelve la versión del firmware de la placa con el que estamos trabajando  
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
ver = butiabot.getVersion()
+
ver = robot.getVersion()
 
print ver
 
print ver
 
</syntaxhighlight>
 
</syntaxhighlight>
  
CERRAR comunicación con el servidor bobot
+
 
 +
'''Cerrar:'''
 +
 
 +
cerrar
 +
Cierra la comunicación con el servidor bobot
 +
 
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.cerrar()
+
robot.cerrar()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
CONEXIÓN/DESCONEXIÓN CON SERVIDOR:
+
 
 +
'''Conexión/Desconexión con el servidor:'''
 +
 
 +
reconnect
 
Conecta o Reconecta al bobot en address:port
 
Conecta o Reconecta al bobot en address:port
 +
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.reconnect (address, port)
+
robot.reconnect (address, port)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
MÓDULOS:
 
  
listarModulos:
+
== Módulos ==
 +
 
 +
'''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">
 
<syntaxhighlight lang="python">
modulos = butiabot.listarModulos()
+
modulos = robot.listarModulos()
 
print modulos
 
print modulos
 
</syntaxhighlight>
 
</syntaxhighlight>
  
abrirModulo:
+
 
 +
'''abrirModulo:'''
 +
 
 
Apertura de modulos, abre el modulo "moduloname"
 
Apertura de modulos, abre el modulo "moduloname"
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.abrirModulo (moduloname)
+
robot.abrirModulo (moduloname)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
llamarModulo:
+
'''llamarModulo:'''
 +
 
 
Operacion de llamada de una funcion de un modulo (CALL)
 
Operacion de llamada de una funcion de un modulo (CALL)
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.llamarModulo(modulename, function , params = "")
+
robot.llamarModulo(modulename, function , params = "")
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
Para conocer la lista de funciones de un módulo y sus parametros puede ejecutarse en un terminal:<br>
 
Para conocer la lista de funciones de un módulo y sus parametros puede ejecutarse en un terminal:<br>
Línea 71: Línea 92:
 
A futuro hay que exportar este servicio en la API<br>
 
A futuro hay que exportar este servicio en la API<br>
  
FUNCIONES VARIAS:
 
  
isPresent
+
== Funciones Varias ==
 +
 
 +
'''isPresent'''
 +
 
 
Retorna si esta presente el modulo<br>
 
Retorna si esta presente el modulo<br>
 +
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.isPresent (moduloname)
+
robot.isPresent (moduloname)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
abrirLback
+
'''abrirLback'''
 +
 
 
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">
 
<syntaxhighlight lang="python">
butiabot.abrirLback()
+
robot.abrirLback()
 
datoRet = butiabot.loopBack("hola")
 
datoRet = butiabot.loopBack("hola")
 
</syntaxhighlight>
 
</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">
 
<syntaxhighlight lang="python">
butiabot.loopBack(data)
+
robot.loopBack(data)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
MOTORES:
+
== Motores ==
 +
 
 
Operaciones solicidatas al driver motores.lua
 
Operaciones solicidatas al driver motores.lua
  
abrirMotores:
+
 
 +
'''abrirMotores:'''
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
butiabot.abrirMotores()
+
robot.abrirMotores()
butiabot.setVelocidadMotores(self, sentidoIzq = "0", velIzq = "0", sentidoDer = "0", velDer = "0")
+
robot.setVelocidadMotores(self, sentidoIzq = "0", velIzq = "0", sentidoDer = "0", velDer = "0")
butiabot.setVelMotor(self, idMotor = "0", sentido = "0", vel = "0")
+
robot.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")
 
</syntaxhighlight>
 
  
SENSORES:
+
 
 +
 
 +
== Sensores ==
 +
 
 
Operaciones solicitadas al driver de los sensores
 
Operaciones solicitadas al driver de los sensores
  
abrirSensor()
 
  
getValSenAnalog(pinAnalog = "0"):
+
'''abrirSensor()'''
 +
 
 +
'''getValSenAnalog(pinAnalog = "0")'''
 +
 
 +
'''getValSenDigital(pinDig = "0")'''
  
getValSenDigital(pinDig = "0"):
 
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
butiabot.abrirSensor()
 
butiabot.abrirSensor()
sen1 = butiabot.getValSenAnalog("2")
+
sen1 = robot.getValSenAnalog("2")
 
print sen1
 
print sen1
sen2 = butiabot.getValSenAnalog("4")
+
sen2 = robot.getValSenAnalog("4")
 
print sen2
 
print sen2
sen3 = butiabot.getValSenDigital("5")
+
sen3 = robot.getValSenDigital("5")
 
print sen3
 
print sen3
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
Operaciones solicitadas al modulo de la placa, driver butia.lua
 
Operaciones solicitadas al modulo de la placa, driver butia.lua
Línea 146: Línea 169:
 
ping()
 
ping()
  
CARGA DE BATERIA
+
 
 +
== Carga de batería ==
 +
 
 
Esta operacion nos devuelve la carga aproximada del pack de pilas del robot con un error de 1 volt.
 
Esta operacion nos devuelve la carga aproximada del pack de pilas del robot con un error de 1 volt.
getCargaBateria()
+
 
 +
'''getCargaBateria()'''
 +
 
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
carga = butiabot.getCargaBateria()
+
carga = robot.getCargaBateria()
 
print carga
 
print carga
 
</syntaxhighlight>
 
</syntaxhighlight>

Revisión del 20:34 21 jun 2011

API del Butiá

Descripción de las funciones y algunos ejemplos.


Instanciar la clase:

robot = butiaAPI.robot()

Apertura:

abrirButia


robot.abrirButia()


Versión:

getVersion Devuelve la versión del firmware de la placa con el que estamos trabajando

ver = robot.getVersion()
print ver


Cerrar:

cerrar Cierra la comunicación con el servidor bobot


robot.cerrar()


Conexión/Desconexión con el servidor:

reconnect Conecta o Reconecta al bobot en address:port


robot.reconnect (address, port)


Módulos

listarModulos:

devuelve la lista de los modulos disponibles en el firmware de la placa


modulos = robot.listarModulos()
print modulos


abrirModulo:

Apertura de modulos, abre el modulo "moduloname"

robot.abrirModulo (moduloname)


llamarModulo:

Operacion de llamada de una funcion de un modulo (CALL)

robot.llamarModulo(modulename, function , params = "")


Para conocer la lista de funciones de un módulo y sus parametros puede ejecutarse en un terminal:

telnet localhost 2009 
DESCRIBE nombre_de_modulo

A futuro hay que exportar este servicio en la API


Funciones Varias

isPresent

Retorna si esta presente el modulo


robot.isPresent (moduloname)


abrirLback

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


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


loopBack:

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


robot.loopBack(data)


Motores

Operaciones solicidatas al driver motores.lua


abrirMotores:

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




== Sensores ==

Operaciones solicitadas al driver de los sensores


'''abrirSensor()'''

'''getValSenAnalog(pinAnalog = "0")'''

'''getValSenDigital(pinDig = "0")'''


<syntaxhighlight lang="python">
butiabot.abrirSensor()
sen1 = robot.getValSenAnalog("2")
print sen1
sen2 = robot.getValSenAnalog("4")
print sen2
sen3 = robot.getValSenDigital("5")
print sen3


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

abrirButia() ping()


Carga de batería

Esta operacion nos devuelve la carga aproximada del pack de pilas del robot con un error de 1 volt.

getCargaBateria()


carga = robot.getCargaBateria()
print carga


setVelocidad3(velIzq = 0, velDer = 0)

setPosicion(idMotor = 0, angulo = 0)



Operaciones solicitadas al driver boton

abrirBoton(self)

getBoton(self)

getLuzAmbiente(self)

getDistancia(self)

getEscalaGris(self)

getTemperature(self)

getVibration(self)

getTilt(self)

getContactoCapacitivo(self)

getInduccionMagnetica(self)

setLed(self, nivel = 255)