コード例 #1
0
    def __init__(self, world):
        GLRealtimeProgram.__init__(self, "Arduino control")
        self.world = world
        self.sim = Simulator(world)
        self.robot = world.robot(0)
        self.controller = self.sim.getController(0)

        if not synthetic:
            self.readthread = ReadArduinoThread()
            self.readthread.start()
            self.readthread.wait_for_data()
        self.calibration = Calibration()
        self.calibration.load()

        self.filter = CompositeFilter(
            [DeadbandFilter(), ExponentialFilter(0.5)])
        self.last_reading = None
        self.qfiltered = None
コード例 #2
0
import messagePublisher
import settings
from filters import *
from klampt import vectorops
import math
import time
import json
import sys

print """syntheticSerialRelay.py: sends wiggling messages to the
   Klamp't objective function server on localhost:3456.  Uses the calibration
   in arduinoCalibrate.txt to map to Klamp't configurations.  Sends a "config"
   type objective.
"""

calibration = Calibration()
calibration.load()

print "***** Using a deadband filter with exponential smoothing *****"
filter = CompositeFilter([DeadbandFilter(),ExponentialFilter(0.5)])

print "***** Running synthetic Arduino stream... *****"

def get_reading():
    #mags = [512,512,512,512,512]
    mags = [256,256,256,256,256]
    periods = [20,13,7,6,22]
    return [512 + mag*math.sin(time.time()/period) for mag,period in zip(mags,periods)]

rate = 30
host = ''