当前位置: 首页>>代码示例>>Python>>正文


Python service.Runtime类代码示例

本文整理汇总了Python中org.myrobotlab.service.Runtime的典型用法代码示例。如果您正苦于以下问题:Python Runtime类的具体用法?Python Runtime怎么用?Python Runtime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Runtime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

from org.myrobotlab.service import Runtime
from org.myrobotlab.service import AudioCapture
from time import sleep
audiocapture = Runtime.createAndStart("audiocapture","AudioCapture")
#it starts capturing audio
audiocapture.captureAudio()
# it will record for 5 seconds
sleep(5)
#then it stops recording audio
audiocapture.stopAudioCapture()
#it plays audio recorded
audiocapture.playAudio()
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:12,代码来源:AudioCapture.py

示例2:

from time import sleep
from org.myrobotlab.service import Speech
from org.myrobotlab.service import Runtime
 
#Starting the required Services
 
serial = Runtime.createAndStart("serial","Serial")
chessgame = Runtime.createAndStart("chessgame", "ChessGame")
log = Runtime.createAndStart("log", "Log")
speech = Runtime.create("speech","Speech")
 
#Configureing Speech Service
 
speech.startService()
speech.setLanguage("en")
speech.speak("Game Begins!")
 
count = 0
chessMove = ""
 
#Connecting Arduino via Serial
 
if not serial.isConnected():
    serial.connect("COM9")
 
# Adding Listeners
serial.addListener("publishByte", python.name, "input") 
chessgame.addListener("computerMoved", python.name, "voice") 
chessgame.addListener("computerMoved", log.name, "log")
chessgame.addListener("makeMove", serial.name, "write") 
 
开发者ID:ronaldobianchini,项目名称:myrobotlab,代码行数:30,代码来源:ChessGame.mehtaatur.py

示例3: BT

import random
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Runtime
from java.lang import String
from time import sleep
from org.myrobotlab.net import BareBonesBrowserLaunch
wdf = Runtime.createAndStart("wikiDataFetcher", "WikiDataFetcher")
holygrail = Runtime.createAndStart("holygrail", "WebGui")
wksr = Runtime.createAndStart("webkitspeechrecognition", "WebkitSpeechRecognition")
elias = Runtime.createAndStart("elias", "ProgramAB")
elias.startSession("elias")
htmlfilter = Runtime.createAndStart("htmlfilter", "HtmlFilter")
acapelaSpeech = Runtime.createAndStart("speech", "AcapelaSpeech")
voices = acapelaSpeech.getVoices()
for voice in voices:
    acapelaSpeech.setVoice("Graham")
wksr.addTextListener(elias)
elias.addTextListener(htmlfilter)
htmlfilter.addTextListener(acapelaSpeech)

def BT():
    global c
    c = b - a
    sleep(2)
    print c
    if (c == 2):
       resp = elias.getResponse("AUTORESPOND1")          
    if (c == 4):
	  resp = elias.getResponse("AUTORESPOND2")           
    if (c == 6):
开发者ID:Bodo11,项目名称:pyrobotlab,代码行数:31,代码来源:start.py

示例4: heard

from java.lang import String
from org.myrobotlab.service import Speech
from org.myrobotlab.service import Sphinx
from org.myrobotlab.service import Runtime
  
# create mouth arduino and servo
ear = Runtime.createAndStart("ear","Sphinx")
arduino = Runtime.createAndStart("arduino","Arduino")
arduino.connect("COM4")
servo = Runtime.createAndStart("servo","Servo")
servo.attach(arduino, 10)
  
# start listening for the words we are interested in
ear.startListening("go forward|go backwards|stop")
  
# set up a message route from the ear --to--> python method "heard"
ear.addListener("recognized", python.name, "heard", String().getClass()); 
  
# this method is invoked when something is 
# recognized by the ear - in this case we
# have the mouth "talk back" the word it recognized
def heard(phrase):
      print("I heard ", phrase)
      if phrase == "go forward":
        servo.moveTo(170)
      elif phrase == "go backwards":
        servo.moveTo(10)
      elif phrase == "stop":
        servo.moveTo(90)
      
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:29,代码来源:Continuous.py

示例5:

from org.myrobotlab.service import Runtime
from org.myrobotlab.service import Roomba
from time import sleep
 
roomba = Runtime.create("roomba","Roomba")
roomba.connect( "COM9" )
roomba.startService()
roomba.startup()
roomba.control()
roomba.playNote( 72, 10 )
roomba.sleep( 200 )
roomba.goForward()
roomba.sleep( 1000 )
roomba.goBackward()
roomba.sleep( 1000 )
roomba.spinRight()
roomba.sleep( 1000 )
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:17,代码来源:Roomba.py

示例6:

from java.lang import Class
from java.awt import Rectangle
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import OpenCV
from org.myrobotlab.opencv import OpenCVData
from com.googlecode.javacv.cpp.opencv_core import CvPoint;
from org.myrobotlab.service import OpenCV
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from time import sleep

# system specif variables
actservox = 90
actservoy = 90

xpid = Runtime.createAndStart("xpid","PID")
ypid = Runtime.createAndStart("ypid","PID")
xpid.setMode(1)
xpid.setOutputRange(-3, 3)
xpid.setPID(10.0, 0, 1.0)
xpid.setControllerDirection(1)
xpid.setSetpoint(160) # we want the target in the middle of the x
ypid.setMode(1)
ypid.setOutputRange(-3, 3)
ypid.setPID(10.0, 0, 1.0)
ypid.setControllerDirection(1)
ypid.setSetpoint(120)

arduino = Runtime.createAndStart("arduino","Arduino")
pan 	= Runtime.createAndStart("pan","Servo")
tilt	= Runtime.createAndStart("tilt","Servo")
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:31,代码来源:Tracking.face.py

示例7:

##############################################
# This script creates 2 servos of a pan / tilt kit
# attaches them to an Arduino and attaches
# a joystick to control the servos

from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Joystick
from org.myrobotlab.service import Runtime
from time import sleep

# create the services
arduino = Runtime.createAndStart("arduino","Arduino")
pan 	= Runtime.createAndStart("pan","Servo")
tilt	= Runtime.createAndStart("tilt","Servo")
joystick = Runtime.createAndStart("joystick","Joystick")

arduino.connect("COM10", 57600, 8, 1, 0)

sleep(2)

# attach servos to Arduino
pan.attach(arduino.getName(), 9)
tilt.attach(arduino.getName(), 10)

# attach joystick to servos
joystick.attach(pan, Joystick.Z_AXIS)
joystick.attach(tilt, Joystick.Z_ROTATION)
joystick.setController(2);
joystick.startPolling();	
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:30,代码来源:panTilt.py

示例8: input

from java.lang import String
from java.lang import Class
from java.awt import Rectangle
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import OpenCV
from org.myrobotlab.opencv import OpenCVData
from com.googlecode.javacv.cpp.opencv_core import CvPoint;
from org.myrobotlab.service import OpenCV

# create or get a handle to an OpenCV service
opencv = Runtime.create("opencv","OpenCV")
opencv.startService()
# reduce the size - face tracking doesn't need much detail
# the smaller the faster
opencv.addFilter("PyramidDown1", "PyramidDown")
# add the face detect filter
opencv.addFilter("FaceDetect1", "FaceDetect")

# ----------------------------------
# input
# ----------------------------------
# the "input" method is where Messages are sent to
# from other Services. The data from these messages can
# be accessed on based on these rules:
# Details of a Message structure can be found here
# http://myrobotlab.org/doc/org/myrobotlab/framework/Message.html 
# When a message comes in - the input function will be called
# the name of the message will be msg_+<sending service name>+_+<sending method name>
# In this particular case when the service named "opencv" finds a face it will publish
# a CvPoint.  The CvPoint can be access by msg_opencv_publish.data[0]
def input():
开发者ID:DarkRebel,项目名称:myrobotlab,代码行数:31,代码来源:faceDetector.py

示例9:

# sayThings.py
# example script for MRL showing various methods
# of the Speech Service 
# http://myrobotlab.org/doc/org/myrobotlab/service/Speech.html

# The preferred method for creating services is
# through the Runtime. This will allow
# the script to be rerun without creating a new
# Service each time. The initial delay from Service
# creation and caching voice files can be large, however
# after creation and caching methods should return 
# immediately

# Create a running instance of the Speech Service.
# Name it "speech". And start it right away.
speech = Runtime.createAndStart("speech","Speech")


# Speak with initial defaults - Google en
speech.speak("hello brave new world")

# Google must have network connectivity
# the back-end will cache a sound file
# once it is pulled from Goole.  So the 
# first time it is slow but subsequent times its very 
# quick and can be run without network connectivity.
speech.setBackendType("GOOGLE") 
speech.setLanguage("en")
speech.speak("Hello World From Google.")
speech.setLanguage("pt") # Google supports some language codes
speech.speak("Hello World From Google.")
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:31,代码来源:sayThings.py

示例10: WorkflowConfiguration

######################################
# Example Document Processing pipeline
######################################
from org.myrobotlab.service import Runtime
from org.myrobotlab.document.transformer import WorkflowConfiguration
from org.myrobotlab.document.transformer import StageConfiguration
# create the pipeline service
pipeline = Runtime.createAndStart("docproc", "DocumentPipeline")
# create a pipeline
# pipeline.workflowName = "default";
# create a workflow to load into that pipeline service
workflowConfig = WorkflowConfiguration();
workflowConfig.setName("default");
staticFieldStageConfig = StageConfiguration();
staticFieldStageConfig.setStageClass("org.myrobotlab.document.transformer.SetStaticFieldValue");
staticFieldStageConfig.setStageName("SetTableField");
# statically assign the value of "MRL" to the field "table" on the document
staticFieldStageConfig.setStringParam("table", "MRL");
workflowConfig.addStage(staticFieldStageConfig);
# a stage that sends a document to solr

openNLPConfig = StageConfiguration()
openNLPConfig.setStageClass("org.myrobotlab.document.transformer.OpenNLP")
openNLPConfig.setStageName("OpenNLP")
openNLPConfig.setStringParam("textField","description")
workflowConfig.addStage(openNLPConfig)

sendToSolrConfig = StageConfiguration();
sendToSolrConfig.setStageClass("org.myrobotlab.document.transformer.SendToSolr")
sendToSolrConfig.setStageName("SendToSolr")
sendToSolrConfig.setStringParam("solrUrl", "http://www.skizatch.org:8983/solr/graph")
开发者ID:MyRobotLab,项目名称:pyrobotlab,代码行数:31,代码来源:DocumentPipeline.py

示例11: open

try:
	mp3file = urllib2.urlopen('http://www.inmoov.fr/wp-content/uploads/2015/05/starting-mouth.mp3')
	output = open(soundfilename,'wb')
	output.write(mp3file.read())
	output.close()
except IOError:
	print "Check access right on the directory"
except Exception:
	print "Can't get the sound File ! Check internet Connexion"



leftPort = "COM20"  #modify port according to your board

i01 = Runtime.createAndStart("i01", "InMoov")
i01.startEar()

mouth = Runtime.createAndStart("mouth","Speech")
i01.startMouth()
##############
torso = i01.startTorso("COM20")  #modify port according to your board
# tweaking default torso settings
torso.topStom.setMinMax(0,180)
torso.topStom.map(0,180,67,110)
torso.midStom.setMinMax(0,180)
torso.midStom.map(0,180,60,120)
#torso.lowStom.setMinMax(0,180)
#torso.lowStom.map(0,180,60,110)
#torso.topStom.setRest(90)
#torso.midStom.setRest(90)
开发者ID:MyRobotLab,项目名称:pyrobotlab,代码行数:30,代码来源:InMoov2.minimalTorso.py

示例12: input

from jarray import array
from java.lang import String
from java.lang import Class
from org.myrobotlab.service import Runtime
from org.myrobotlab.framework import Message

catcher = Runtime.createAndStart("catcher", "TestCatcher")
thrower = Runtime.createAndStart("thrower", "TestThrower")


def input():
    # python catches data from thrower - then throws to catcher
    print "thrower sent me ", msg_thrower_send.data[0]
    print "modifying the ball"
    msg_thrower_send.data[0] = "throw from python->catcher"
    print "throwing to catcher now"
    python.send("catcher", "catchString", msg_thrower_send.data[0])


# thrower sends data to python
thrower.throwString("python", "input", "throw from thrower->python")
开发者ID:wramey82,项目名称:myrobotlab,代码行数:21,代码来源:messageToAndFromJythonScript.py

示例13:

#script to control the TrashyBot platform through remote control via Xbox 360 wireless remote
#
#
#Nolan B. 1/8/16


from org.myrobotlab.service import Joystick
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Runtime
from time import sleep

#----------------------------------Web Gui--------------------------
webgui = Runtime.create("webgui", "WebGui")
webgui.autoStartBrowser(False)
Runtime.start("webgui", "WebGui")


#---------------------------------Create Services----------------------
arduino = Runtime.createAndStart("arduino","Arduino")
joystick = Runtime.createAndStart("joystick","Joystick")
motorL = Runtime.start("motorL","Motor")
motorR = Runtime.start("motorR","Motor")
log = Runtime.start("log","Log")



#----------------------Connect Peripherals-----------------------------------
joystick.setController(0); #PC only - Pi needs new
joystick.addInputListener(python)
arduino.connect("/dev/ttyACM0");
# Tell the joystick to turn on
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:31,代码来源:Trashy_Platform_RC.py

示例14: range

from org.myrobotlab.service import Arduino
from org.myrobotlab.service import MagaBot
from org.myrobotlab.service import Runtime

from time import sleep

# Create a running instance of the MagaBot Service.

magabot = Runtime.create("magabot","MagaBot")
magabot.startService()
magabot.init("COM8")  # initalize arduino on port specified to 9600 8n1

for x in range(0,20):
  magabot.sendOrder('a')
  sleep(0.5)
  
#magabot.sendOrder('a')
#sleep(0.5)
#magabot.sendOrder('a')
#sleep(0.5)
#magabot.sendOrder('a')
#sleep(0.5)


开发者ID:ronaldobianchini,项目名称:myrobotlab,代码行数:22,代码来源:magabotTest.py

示例15:

##############################################
# This script creates the parts of a ROFI and 
# attaches them to MRL
#from org.myrobotlab.service import UltrasonicSensor
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import GUIService
from org.myrobotlab.service import Speech
from time import sleep

# we need a dictionary of arrays which store calibration data for each servo/joint
calib = {}

# create the services
speech = Runtime.createAndStart("speech","Speech") # For voice feedback
#ear = Runtime.createAndStart("listen","Sphinx") # For hearing spoken commands

gui = Runtime.start("gui", "GUIService")
keyboard = Runtime.start("keyboard", "Keyboard") # For getting user confirmation

#keyboard.addKeyListener(python)

# Arduino to connect everything to like a spinal cord
arduino = Runtime.createAndStart("arduino","Arduino")

#sr04 = Runtime.start("sr04", "UltrasonicSensor") # For an ultrasonic view of the world

# 6 joints in the Right leg
rAnkle = Runtime.createAndStart("R Ankle","Servo")
rLowLeg = Runtime.createAndStart("R Low Leg","Servo")
开发者ID:ADVALAIN596,项目名称:pyrobotlab,代码行数:31,代码来源:rofi-calibration.py


注:本文中的org.myrobotlab.service.Runtime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。