Exemple #1
0
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Runtime

from time import sleep

servo1Pin = 12
servo2Pin = 13
servo3Pin = 26
servo4Pin = 4

# comPort = "/dev/ttyUSB0"
comPort = "COM6"

# create the services
arduino = Runtime.start("arduino","Arduino")
servo01 = Runtime.start("servo01","Servo")

# initialize arduino
# arduino.connect("/dev/ttyUSB0")
arduino.connect(comPort)

# TODO - set limits
servo01.setMinMax(60, 120)
  
# attach servo
servo01.attach(arduino.getName(), servo1Pin)

# fast sweep
servo01.moveTo(90)
# these are D6,D7 for 2 PWM motor control
pwmPin = 6
dirPin = 7
# this is "A7" on the Arduino Mega
potPin = 61

# port = "/dev/ttyACM0"
port = "COM31"

# to help avoid buffer overruns when sampling data from the arduino
sampleRate = 25

# Runtime.start("webgui", "WebGui")
# Start the Arduino
arduino = Runtime.start("arduino", "Arduino")
arduino.connect(port)
# a slight pause to let the arduino connect (maybe not necessary)
sleep(2)
# set up the motor control pins to be output
arduino.pinMode(pwmPin, Arduino.OUTPUT)
arduino.pinMode(dirPin, Arduino.OUTPUT)
# set the analog pin to be an input pin
arduino.pinMode(potPin, Arduino.INPUT)
# set the sample rate for the analog pins
arduino.setSampleRate(sampleRate)
arduino.analogReadPollingStart(potPin)
# start the motor service and attach it to the arduino
m1 = Runtime.start("m1", "Motor");
m1.setTypeSimple(pwmPin, dirPin);
m1.attach(arduino)
#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
joystick.startPolling()

# attach servos to Arduino
Exemple #4
0
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Runtime

from time import sleep

servoPin = 4
# comPort = "/dev/ttyUSB0"
comPort = "COM15"

# create the services
arduino = Runtime.start("arduino","Arduino")
servo01 = Runtime.start("servo01","Servo")

# initialize arduino
# arduino.connect("/dev/ttyUSB0")
arduino.connect(comPort)

# TODO - set limits
servo01.setMinMax(0, 180)
  
# attach servo
servo01.attach(arduino.getName(), servoPin)

# fast sweep
servo01.moveTo(179)
sleep(0.5)

servo01.moveTo(10)
sleep(0.5)
Exemple #5
0
from org.myrobotlab.service import Runtime

serial = Runtime.createAndStart("serial", "Serial")
serial.connect('COM4')

joystick = Runtime.start("joystick", "Joystick")
joystick.setController(0)
python.subscribe("joystick", "publishJoystickInput")


def onJoystickInput(data):

    if (data.id == "R" and data.value == 1.0):
        serial.write("255,0,0")

    if (data.id == "G" and data.value == 1.0):
        serial.write("0,255,0")

    if (data.id == "B" and data.value == 1.0):
        serial.write("0,0,255")
Exemple #6
0
#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")
rKnee = Runtime.createAndStart("R Knee", "Servo")
rMidLeg = Runtime.createAndStart("R Mid Leg", "Servo")
Exemple #7
0
# InMoov2 Config : i01
Platform.setVirtual(True)
i01.setVirtual(True)
i01.setMute(False)
##############################################################
## creating 69 services ####
# Although Runtime.start(name,type) both creates and starts services it might be desirable on creation to
# substitute peers, types or references of other sub services before the service is "started"
# e.g. i01 = Runtime.create('i01', 'InMoov') # this will "create" the service and config could be manipulated before starting 
# e.g. i01_left = Runtime.create('i01.left', 'Ssc32UsbServoController')
##############################################################

runtime = Runtime.getInstance()
runtime.setAllLocales('en-US')
#i01_jme = Runtime.start('i01.jme', 'JMonkeyEngine')
i01_servomixer = Runtime.start('i01.servomixer', 'ServoMixer')
i01_leftArm_rotate = Runtime.start('i01.leftArm.rotate', 'Servo')
i01_torso_topStom = Runtime.start('i01.torso.topStom', 'Servo')
i01_rightArm_bicep = Runtime.start('i01.rightArm.bicep', 'Servo')
security = Runtime.start('security', 'Security')
i01_head_rollNeck = Runtime.start('i01.head.rollNeck', 'Servo')
i01_leftHand = Runtime.start('i01.leftHand', 'InMoov2Hand')
i01_rightHand_ringFinger = Runtime.start('i01.rightHand.ringFinger', 'Servo')
MoveEyesTimer = Runtime.start('MoveEyesTimer', 'Clock')
i01_leftHand_majeure = Runtime.start('i01.leftHand.majeure', 'Servo')
i01_leftHand_index = Runtime.start('i01.leftHand.index', 'Servo')
i01_rightHand_majeure = Runtime.start('i01.rightHand.majeure', 'Servo')
i01_head_eyeX = Runtime.start('i01.head.eyeX', 'Servo')
i01_right_serial = Runtime.start('i01.right.serial', 'Serial')
python = Runtime.start('python', 'Python')
i01_rightHand_index = Runtime.start('i01.rightHand.index', 'Servo')
#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")
rKnee = Runtime.createAndStart("R Knee","Servo")
rMidLeg = Runtime.createAndStart("R Mid Leg","Servo")
rUpLeg = Runtime.createAndStart("R Up Leg","Servo")
Exemple #9
0
from org.myrobotlab.service import Runtime

serial = Runtime.createAndStart("serial","Serial")
serial.connect('COM4')

joystick = Runtime.start("joystick","Joystick")
joystick.setController(0)
python.subscribe("joystick","publishJoystickInput")

def onJoystickInput(data):
     

        
    if (data.id=="R" and data.value == 1.0):
        serial.write("255,0,0")  

    if (data.id=="G" and data.value == 1.0):
        serial.write("0,255,0") 

    if (data.id=="B" and data.value == 1.0):
        serial.write("0,0,255") 
#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 SwingGui
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", "SwingGui")
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")
rKnee = Runtime.createAndStart("R Knee","Servo")
rMidLeg = Runtime.createAndStart("R Mid Leg","Servo")
rUpLeg = Runtime.createAndStart("R Up Leg","Servo")
#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 SwingGui
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", "SwingGui")
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")
rKnee = Runtime.createAndStart("R Knee", "Servo")
rMidLeg = Runtime.createAndStart("R Mid Leg", "Servo")
Exemple #12
0
# these are D6,D7 for 2 PWM motor control
pwmPin = 6
dirPin = 7
# this is "A7" on the Arduino Mega
potPin = 61

# port = "/dev/ttyACM0"
port = "COM31"

# to help avoid buffer overruns when sampling data from the arduino
sampleRate = 25

# Runtime.start("webgui", "WebGui")
# Start the Arduino
arduino = Runtime.start("arduino", "Arduino")
arduino.connect(port)
# a slight pause to let the arduino connect (maybe not necessary)
sleep(2)
# set up the motor control pins to be output
arduino.pinMode(pwmPin, Arduino.OUTPUT)
arduino.pinMode(dirPin, Arduino.OUTPUT)
# set the analog pin to be an input pin
arduino.pinMode(potPin, Arduino.INPUT)
# set the sample rate for the analog pins
arduino.setSampleRate(sampleRate)
arduino.analogReadPollingStart(potPin)
# start the motor service and attach it to the arduino
m1 = Runtime.start("m1", "Motor")
m1.setTypeSimple(pwmPin, dirPin)
m1.attach(arduino)
#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
Exemple #14
0
from org.myrobotlab.service import Joystick
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Runtime
from time import sleep
#---------------------------------Create Services----------------------
arduino = Runtime.createAndStart("arduino","Arduino")
joystick = Runtime.createAndStart("joystick","Joystick")
motorleft = Runtime.start("motorleft","Motor")

#----------------------Connect Peripherals-----------------------------------
joystick.setController(0); #PC only - Pi needs new
joystick.addInputListener(python)
# Tell the joystick to turn on
joystick.startPolling()
arduino.connect("/dev/ttyACM0");
arduino.motorAttach("motorleft", 5, 4) 

#----------------------Define callback function for Joystick-----------
def onJoystickInput(data):
  global float(ryValue)
  
  if (data.id == 'A' and float(data.value) == 1.0):
    print "Attatch MotorLeft"
  if (data.id == 'B' and float(data.value) == 1.0):
    print "Detach MotorLeft"
  if (data.id == 'ry'):
    ryValue = float(data.value) 
    printValue(ryValue)
    moveLeftMotor(ryValue)
  
#-----------------------Main Loop----------------------------------------
Exemple #15
0
#script to connect pan and tilt motion of head servos to joystick movement
#instead of the servo motion being tied directly to servo position the servos will hold thier last position when
#control sticks return to center. Thanks to Kwatters for the syntax on the servo sweeping
#Nolan B. 1/4/16

from org.myrobotlab.service import Joystick
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import Servo
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")
servo01 = Runtime.start("servo01","Servo") #Head Tilt Servo
servo02 = Runtime.start("servo02","Servo") #Head Pan Servo

#------------------------Create Static Values-------------------------------
servo01Pin = 10 
servo02Pin = 11 
comPort = "/dev/ttyACM0"
servo01.setMinMax(30, 130)
servo02.setMinMax(30, 130)

#----------------------Connect Peripherals-----------------------------------