def __init__(self, configPrefix="camera"): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() # Get config config = Config() self.scaling = config.get(f"{configPrefix}.leveling.scaling", 0.012) config.save()
def __init__(self): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() self.vision = VisionAccessFactory.getSingleton() # Get config config = Config() self.points = config.get("display.graph.numpoints", 500) config.save() self.fig, self.ax = plt.subplots() self.x = np.arange(0, self.points, 1) self.lines = \ self.ax.plot(self.x, [0.0]*len(self.x), label="F Joystick")[0], \ self.ax.plot(self.x, [0.0]*len(self.x), label="L motor")[0], \ self.ax.plot(self.x, [0.0]*len(self.x), label="L speed")[0], \ self.ax.plot(self.x, [0.0]*len(self.x), label="R motor")[0], \ self.ax.plot(self.x, [0.0]*len(self.x), label="R speed")[0], \ self.ax.plot(self.x, [0.0]*len(self.x), label="Heading")[0], \ self.ax.plot(self.x, [0.0]*len(self.x), label="Vision")[0] self.values = \ Scaler(self.sensors.joystickAxis(1), scaling=1.0), \ Scaler(self.controls.motor(2), scaling=-1.0), \ Scaler(self.sensors.rateCounter(0), scaling=0.0012), \ Scaler(self.controls.motor(1), scaling=1.0), \ Scaler(self.sensors.rateCounter(1), scaling=0.0012), \ Scaler(self.sensors.yaw(), scaling=1/180.0), \ Scaler(self.vision.getLineHeading(), scaling=1/180.0) plt.ylabel('value') plt.legend(loc=(0.01, 0.75))
def __init__(self, title, menuItems, selected): self.titleFont = ImageFont.truetype("FreeSans.ttf", 14) self.unselectedFont = ImageFont.truetype("Piboto-Regular.ttf", 10) self.selectedFont = ImageFont.truetype("FreeSansBold.ttf", 20) self.title = title self.menuItems = menuItems self.selected = selected # Config config = Config() displayDef = config.get("display.config", MenuDisplay.defaultDisplayConfig) config.save() # create device parser = cmdline.create_parser(description='luma arguments') displayArgs = parser.parse_args(displayDef) try: self.device = cmdline.create_device(displayArgs) except error.Error as e: parser.error(e)
def __init__(self): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() config = Config() self.min = config.get("grabber.open", -0.75) self.max = config.get("grabber.closed", 0.25) self.speed = config.get("grabber.speed", 0.2) config.save()
def __init__(self): # Initialise the IPC classes self.motorsIPC = MotorControlSharedIPC() self.motorsIPC.create() self.currentMotorValues = [0.0]*3 self.servosIPC = ServoControlSharedIPC() self.servosIPC.create() self.currentServoValues = [0.0]*32 self.simpleControlsIPC = SimpleControlSharedIPC() self.simpleControlsIPC.create() self.currentSimpleValues = [0]*32 # Config config = Config() self.pollrate = (1.0 / config.get("redboard.motor.pollrate", 100)) self.delta_torque = self.pollrate * config.get("redboard.motor.accelmax", 4.0) config.save()
def __init__(self): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() # Common controls self.grabberControl = GrabberControl() self.cameraLevellingControl = CameraLevellingControl() self.zGunControl = ZGunControl() # Get config config = Config() self.pidP = config.get("manual.pid.p", 0.015) self.pidI = config.get("manual.pid.i", 0.0) #0.001) self.pidD = config.get("manual.pid.d", 0.0012) self.proportionalOnMeasure = config.get("manual.pid.pom", False) self.maxForward = config.get("manual.forward.max", 1.0) self.maxManualTurn = config.get("manual.turn.max", -15.0) self.maxHeadingTurn = config.get("manual.headingturn.max", 0.6) self.maxSimpleTurn = config.get("manual.simpleturn.max", 0.4) self.cameraTilt = config.get("manual.camera.tilt", 0.15) config.save()
def __init__(self): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() self.vision = VisionAccessFactory.getSingleton() # Common controls self.grabberControl = GrabberControl() self.cameraLevellingControl = CameraLevellingControl() self.zGunControl = ZGunControl() # Get config config = Config() self.pidP = config.get("minesweeper.pid.p", 0.015) self.pidI = config.get("minesweeper.pid.i", 0.0) #0.001) self.pidD = config.get("minesweeper.pid.d", 0.0012) self.proportionalOnMeasure = config.get("minesweeper.pid.pom", False) self.maxForward = config.get("minesweeper.forward.max", 1.0) self.maxHeadingTurn = config.get("minesweeper.headingturn.max", 0.6) self.maxManualTurn = config.get("minesweeper.manualturn.max", -15.0) self.maxFindLightTurn = config.get("minesweeper.findlightturn.max", -15.0) self.autoMaxSpeed = config.get("minesweeper.speed", 0.6) self.cameraTilt = config.get("minesweeper.camera.tilt", 0.22) self.achievedStopTime = config.get("minesweeper.achieved.stoptime", 5.0) # seconds self.minDistanceToStop = config.get("minesweeper.achieved.atdistance", 20.0) self.MoveTimeMin = config.get("minesweeper.movement.mintime", 1.0) # seconds config.save()
def __init__(self): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() self.vision = VisionAccessFactory.getSingleton() # Common controls self.grabberControl = GrabberControl() self.cameraLevellingControl = CameraLevellingControl() self.zGunControl = ZGunControl() # Get config config = Config() self.pidP = config.get("heading.pid.p", 0.06) self.pidI = config.get("heading.pid.i", 0.001) self.pidD = config.get("heading.pid.d", 0.004) self.proportionalOnMeasure = config.get("heading.pid.pom", False) self.maxForward = config.get("heading.forward.max", 1.0) self.maxManualTurn = config.get("heading.manualturn.max", -15.0) self.maxHeadingTurn = config.get("heading.headingturn.max", 0.5) self.constantSpeed = config.get("lava.speed", 0.7) self.cameraTilt = config.get("lava.camera.tilt", 0.5) config.save()
from __future__ import print_function import cv2 as cv import numpy as np import argparse from interfaces.Config import Config # Get the last known config config = Config("calibrationDistance.json") nearest = config.get("distance.analysis.nearest", 130) horizon = config.get("distance.analysis.horizon", 500) cameraHeight = config.get("distance.analysis.cameraHeight", 170) #cameraF = config.get("distance.analysis.camera_f", 1.4) max_value_horizon = 640 window_capture_name = 'Video Capture' window_detection_name = 'Calibration' nearest_name = 'nearest' horizon_name = 'horizon' def on_nearest_trackbar(val): global nearest_name global nearest nearest = val cv.setTrackbarPos(nearest_name, window_detection_name, nearest) def on_horizon_trackbar(val): global horizon global horizon_name global max_value_horizon
def __init__(self): # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-v", "--video", help="path to the (optional) video file") args = vars(ap.parse_args()) self.recordedVideo = args.get("video", False) if self.recordedVideo: self.videoFilenanme = args["video"] # Get config config = Config() self.debugPrint = config.get("minesweeper.analysis.debugPrint", False) self.analysis_width = config.get("minesweeper.analysis.imagewidth", 480) self.blur_radius = config.get("minesweeper.analysis.burrradius", 11) #self.minSize = config.get("minesweeper.analysis.minsize", 10) self.minWidth = config.get("minesweeper.analysis.minWidth", 15) self.minHeight = config.get("minesweeper.analysis.minHeight", 10) # Scale factors for real-world measures self.angleAdjustment = config.get("minesweeper.analysis.anglescale", 2.6) #1.3#0.55 # define the lower and upper boundaries of the target # colour in the HSV color space, then initialize the useCalibrationColours = config.get( "minesweeper.analysis.useCalibrationColours", True) if not useCalibrationColours: useLEDColours = config.get("minesweeper.analysis.useLEDColours", False) if useLEDColours: # For LED: self.colourTargetLower = tuple( config.get("minesweeper.analysis.colourTargetLowerLED", [155, 24, 200 ])) #(165,90,100)#(158,60,90) #(160,128,24) self.colourTargetUpper = tuple( config.get("minesweeper.analysis.colourTargetUpperLED", [175, 255, 255])) #(175,255,255) #(180,255,255) else: # For test biscuit tin lid self.colourTargetLower = tuple( config.get("minesweeper.analysis.colourTargetLowerTest", [165, 94, 69])) self.colourTargetUpper = tuple( config.get("minesweeper.analysis.colourTargetUpperTest", [180, 255, 255])) self.showImage = config.get("minesweeper.display.image", True) self.trailSize = config.get("minesweeper.display.trail", 25) self.frameDelayMs = config.get("minesweeper.analysis.frameDelayMs", 20) # delay after each frame analysis config.save() # Load calibration values configCal = Config("calibrationMinesweeper.json") if useCalibrationColours: self.colourTargetLower = tuple( configCal.get("minesweeper.analysis.colourTargetLower", None)) self.colourTargetUpper = tuple( configCal.get("minesweeper.analysis.colourTargetUpper", None)) self.cameraNearestVisibleDistance = configCal.get( "distance.analysis.nearest", 130) self.cameraNearestVisiblePixels = int( self.cameraNearestVisibleDistance * 3.5) # Rough approximation equivallent!! self.cameraFurthestVisiblePixel = configCal.get( "distance.analysis.horizon", 500) self.cameraHeightDistance = configCal.get( "distance.analysis.cameraHeight", 170) calibrationResolution = configCal.get( "distance.analysis.calibrationResolution", [480, 640]) self.cameraHeightAdjustment = np.sqrt( self.cameraHeightDistance * self.cameraHeightDistance + self.cameraNearestVisibleDistance * self. cameraNearestVisibleDistance) / self.cameraNearestVisibleDistance # Adjust for the analysis picture resolution being different to the calibrator self.cameraFurthestVisiblePixel = self.cameraFurthestVisiblePixel * self.analysis_width // calibrationResolution[ 1] # Results IPC self.resultsIpc = ImageAnalysisSharedIPC() self.resultsIpc.create() # Yaw reading accessor self.sensors = SensorAccessFactory.getSingleton() self.yawAccessor = self.sensors.yaw()
from __future__ import print_function import cv2 as cv import argparse from interfaces.Config import Config # Get the last known config config = Config("calibrationHSV.json") low_H, low_S, low_V = config.get("minesweeper.analysis.colourTargetLowerTest", [165,94,69]) high_H, high_S, high_V = config.get("minesweeper.analysis.colourTargetUpperTest", [180,255,255]) max_value = 255 max_value_H = 360//2 #low_H = 0 #low_S = 0 #low_V = 0 #high_H = max_value_H #high_S = max_value #high_V = max_value window_capture_name = 'Video Capture' window_detection_name = 'Object Detection' low_H_name = 'Low H' low_S_name = 'Low S' low_V_name = 'Low V' high_H_name = 'High H' high_S_name = 'High S' high_V_name = 'High V' def on_low_H_thresh_trackbar(val): global low_H global high_H low_H = val low_H = min(high_H-1, low_H)
def __init__(self, forwardTorque, steerTorque, min=-1.0, max=1.0, scaling=1.0, offset=0.0): SensorInterface.__init__(self) self.forwardTorque = forwardTorque self.steerTorque = steerTorque self.min = min self.max = max self.scaling = scaling self.offset = offset # Get config config = Config() self.speedSlow = config.get("speedsteer.slow", 0.1) self.speedSlowComp = config.get("speedsteer.slow.compensation", 2.0) self.speedMed = config.get("speedsteer.med", 0.8) self.speedMedComp = config.get("speedsteer.med.compensation", 1.0) self.speedHighComp = config.get("speedsteer.high.compensation", 2.0) self.speedHighThresh = config.get("speedsteer.high.decelthresh", 0.05) self.speedHighDecel = config.get("speedsteer.high.decel", 0.6) config.save()
def __init__(self): self.controls = ControlAccessFactory.getSingleton() self.sensors = SensorAccessFactory.getSingleton() #self.vision = VisionAccessFactory.getSingleton() # Common controls self.grabberControl = GrabberControl() self.cameraLevellingControl = CameraLevellingControl() self.zGunControl = ZGunControl() # Get config config = Config() self.pidP = config.get("wall.pid.p", 0.015) self.pidI = config.get("wall.pid.i", 0.0) #0.001) self.pidD = config.get("wall.pid.d", 0.0012) self.proportionalOnMeasure = config.get("wall.pid.pom", False) self.maxForward = config.get("wall.forward.max", 1.0) self.maxManualTurn = config.get("wall.manualturn.max", -15.0) self.maxHeadingTurn = config.get("wall.headingturn.max", 0.5) self.autoMaxSpeed = config.get("wall.speed", 0.6) self.cameraTilt = config.get("wall.camera.tilt", -0.4) self.leftRightMaxDist = config.get("wall.leftright.maxdist", 600) self.forwardTurnDist = config.get("wall.forward.maxdist", 450) self.wallDistTarget = config.get( "wall.targetdist", 305) # 305 ~= 210mm clearance each side self.wallFollowAdjustmentRate = config.get("wall.move.followfactor", 300.0) self.wallFollowMaxAngle = config.get("wall.move.maxfollowangle", 15.0) self.turnAllowedTime = config.get("wall.move.turnspeed", 1.0) self.turnAheadSpeed = config.get("wall.move.turnaheadspeed", 0.4) config.save()