本文整理汇总了Python中org.myrobotlab.service.Runtime.createAndStart方法的典型用法代码示例。如果您正苦于以下问题:Python Runtime.createAndStart方法的具体用法?Python Runtime.createAndStart怎么用?Python Runtime.createAndStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.myrobotlab.service.Runtime
的用法示例。
在下文中一共展示了Runtime.createAndStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
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")
示例2:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Runtime
from time import sleep
# create the services
arduino = Runtime.createAndStart("arduino","Arduino")
servo01 = Runtime.createAndStart("servo01","Servo")
# initialize arduino
arduino.connect("/dev/ttyUSB0")
# TODO - set limits
# attach servo
arduino.servoAttach(servo01.getName(), 9)
# fast sweep
servo01.moveTo(179)
sleep(0.5)
servo01.moveTo(10)
sleep(0.5)
servo01.moveTo(179)
sleep(0.5)
servo01.moveTo(10)
sleep(0.5)
示例3:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
##############################################
# 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")
示例4:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
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;
global posx
global posy
global newx
global newy
opencv = Runtime.createAndStart("opencv","OpenCV")
opencv.publishState()
opencv.addFilter("pd","PyramidDown")
opencv.setDisplayFilter("pd")
opencv.addFilter("detector","Detector")
opencv.setDisplayFilter("detector")
opencv.addFilter("findcontours","FindContours")
opencv.setDisplayFilter("findcontours")
tracker = Runtime.create("tracker","Tracking")
# create all the peer services
rotation = Runtime.create("rotation","Servo")
neck = Runtime.create("neck","Servo")
arduino = Runtime.create("arduino","Arduino")
xpid = Runtime.create("xpid","PID");
ypid = Runtime.create("ypid","PID");
示例5:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import WebServer
from org.myrobotlab.net import BareBonesBrowserLaunch
#It creates and starts webserver service
webserver = Runtime.createAndStart("webserver","WebServer")
#Launch your web browser to the URL of localhost, by default port is 19191
#helloworl.htm file is in your MRL main folder
#you can add files there and change the URL below as you desire
BareBonesBrowserLaunch.openURL("http://localhost:19191/helloworld.htm")
示例6: String
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
# the best interface to do finely controlled actuation. But, it is very
# convenient to express high-level (e.g. go to center of the room) commands
#
# FYI - The memory requirements for Sphinx are a bit hefty and depending on the
# platform additional JVM arguments might be necessary e.g. -Xmx256m
# create an ear
ear = Runtime.create("ear","Sphinx")
# create the grammar you would like recognized
# this must be done before the service is started
ear.createGrammar("all open | hand close | pinch mode | open pinch | hand open | hand rest | hand open two ")
ear.startService()
# start the mouth
mouth = Runtime.createAndStart("mouth","Speech")
# 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
# prevent infinite loop - this will suppress the
# recognition when speaking - default behavior
# when attaching an ear to a mouth :)
ear.attach("mouth")
#create an Arduino & name arduino & index
示例7:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
from java.lang import String
from org.myrobotlab.service import Sphinx
from org.myrobotlab.service import Runtime
# create ear and mouth
ear = Runtime.createAndStart("ear","Sphinx")
mouth = Runtime.createAndStart("mouth","MarySpeech")
# start listening for the words we are interested in
ear.addComfirmations("yes","correct","ya")
ear.addNegations("no","wrong","nope","nah")
#ear.startListening("hello world|happy monkey|go forward|stop|yes|correct|ya|no|wrong|nope|nah")
ear.startListening("hello world|happy monkey|go forward|stop")
ear.addCommand("hello world", "python", "helloWorld")
# set up a message route from the ear --to--> python method "heard"
# ear.addListener("recognized", python.name, "heard");
# ear.addComfirmations("yes","correct","yeah","ya")
# ear.addNegations("no","wrong","nope","nah")
# ear.addCommand("hello world", "python", "helloworld")
# set up a message route from the ear --to--> python method "heard"
# ear.addListener("recognized", python.name, "heard");
# this method is invoked when something is
# recognized by the ear - in this case we
# have the mouth "talk back" the word it recognized
示例8: open
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
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)
示例9:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
# 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.")
示例10: input
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
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")
示例11: WorkflowConfiguration
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
######################################
# 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")
示例12:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
#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
joystick.startPolling()
示例13:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
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()
示例14:
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
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
holygrail = Runtime.createAndStart("holygrail", "WebGui")
wksr = Runtime.createAndStart("webkitspeechrecognition", "WebkitSpeechRecognition")
simple = Runtime.createAndStart("simple", "ProgramAB")
simple.startSession("default", "simple")
htmlfilter = Runtime.createAndStart("htmlfilter", "HtmlFilter")
acapelaSpeech = Runtime.createAndStart("speech", "AcapelaSpeech")
voices = acapelaSpeech.getVoices()
for voice in voices:
acapelaSpeech.setVoice("Ryan")
wksr.addTextListener(simple)
simple.addTextListener(htmlfilter)
htmlfilter.addTextListener(acapelaSpeech)
示例15: mail
# 需要导入模块: from org.myrobotlab.service import Runtime [as 别名]
# 或者: from org.myrobotlab.service.Runtime import createAndStart [as 别名]
#from org.myrobotlab.service import Speech
from org.myrobotlab.service import Sphinx
from org.myrobotlab.service import Runtime
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
gmail_user = "[email protected]"
gmail_pwd = "
# create ear and mouth
ear = Runtime.createAndStart("ear","Sphinx")
mouth = Runtime.createAndStart("mouth","Speech")
opencv = Runtime.createAndStart("opencv","OpenCV")
opencv.addFilter("pdown","PyramidDown")
opencv.setDisplayFilter("pdown")
opencv.capture()
mouth.setLanguage("it")
# start listening for the words we are interested in
ear.startListening("hello robot|take photo|send email")
# set up a message route from the ear --to--> python method "heard"
ear.addListener("recognized", python.name, "heard", String().getClass());
def mail(to, subject, text, attach):
msg = MIMEMultipart()