def runTest(self): ip_address = TiberiusConfigParser.getIPAddress() try: socket.inet_aton(ip_address) except: self.fail("Invalid IP Address") return
def runTest(self): addr = TiberiusConfigParser.getCompassAddress() minAddress = 0 maxAddress = 255 self.assertTrue(isinstance(addr, (int, long)))
def turnLeft90Degrees(self): # Ensure we have sufficient priviledges to access compass. if not TiberiusConfigParser.isCompassEnabled(): raise SensorNotEnabledError("Compass is disabled, dependant \ function cannot be executed.") old_bearing = self.compass.headingNormalized() desired_bearing = (old_bearing - 90) if(desired_bearing < -180): desired_bearing += 360 print desired_bearing self.turnTo(desired_bearing)
def runTest(self): rl = TiberiusConfigParser.getUltrasonicRearLeftAddress() rr = TiberiusConfigParser.getUltrasonicRearRightAddress() rc = TiberiusConfigParser.getUltrasonicRearCentreAddress() fl = TiberiusConfigParser.getUltrasonicFrontLeftAddress() fr = TiberiusConfigParser.getUltrasonicFrontRightAddress() fc = TiberiusConfigParser.getUltrasonicFrontCentreAddress() minAddress = 0 maxAddress = 255 self.assertTrue(isinstance(rl, (int, long))) self.assertTrue(isinstance(rr, (int, long))) self.assertTrue(isinstance(rc, (int, long))) self.assertTrue(isinstance(fl, (int, long))) self.assertTrue(isinstance(fr, (int, long))) self.assertTrue(isinstance(fc, (int, long)))
#!/usr/bin/env python import time import drivers.cmps11 as cmps11 import drivers.srf08 as srf08 import drivers.gps20 as gps20 import drivers.lidar as rplidar from tiberius.config.config_parser import TiberiusConfigParser #Only import power mon driver if enables, prevents port open error if TiberiusConfigParser.isMonitorEnabled(): import drivers.powermanagement as Powermanagement class PowerManagementSensor: pm = Powermanagement.PowerManagement() def getdata(self): return self.pm.getdata() class Ultrasonic: ''' Contains the ultrasonic sensors, and methods to receive data from them. Data is returned from the sensors in centimeters. ''' # Front Right srffr = srf08.UltrasonicRangefinder( TiberiusConfigParser.getUltrasonicFrontRightAddress()) # Front Centre
def driveStraight(self, speed_percent, duration, sensitivity=1): # Ensure we have sufficient priviledges to access compass. if not TiberiusConfigParser.isCompassEnabled(): raise SensorNotEnabledError("Compass is disabled, dependant \ function cannot be executed.") desired_heading = self.compass.headingNormalized() t = 0 # time gain = 1440 # proportional Error multiplier integral = 0 # Sum of all errors over time i_factor = 1 # integral d_factor = 1 # derivative previous_error = 0 debug = False left_speed = (speed_percent * 255) / 100 # 0-100 -> 0-255 right_speed = (speed_percent * 255) / 100 while t < duration: actual_heading = self.compass.headingNormalized() error_degrees = actual_heading - desired_heading error_degrees = bearing_math.normalize_bearing(error_degrees) '''if desired_heading > 0: if actual_heading > 0: error_degrees = actual_heading - desired_heading elif actual_heading < 0: error_degrees = actual_heading + desired_heading elif desired_heading < 0: if actual_heading > 0: error_degrees = actual_heading + desired_heading elif actual_heading < 0: error_degrees = actual_heading - desired_heading ''' # Make error between 1 and -1 error = error_degrees / float(180.0) error *= sensitivity integral += error derivative = previous_error - error previous_error = error if error_degrees < 0: # Turn Right r = right_speed - (abs(error) * gain) - \ (integral * i_factor) + (derivative * d_factor) l = left_speed + (abs(error) * gain) - \ (integral * i_factor) + (derivative * d_factor) if debug: print 'Turning RIGHT' elif error_degrees > 0: # Turn Left r = right_speed + (abs(error) * gain) - \ (integral * i_factor) + (derivative * d_factor) l = left_speed - (abs(error) * gain) - \ (integral * i_factor) + (derivative * d_factor) if debug: print 'Turning LEFT' else: l = left_speed r = right_speed integral = 0 # Reset integral error when on track if debug: print 'Going STRAIGHT' if debug: print 'Desired Heading (deg): ' + str(desired_heading) print 'Actual Heading (deg): ' + str(actual_heading) print 'Error (deg): ' + str(error_degrees) print 'Error: ' + str(error) print 'Max speed : ' + str(left_speed) print 'Left speed : ' + str(l) print 'Right speed : ' + str(r) print 'Proportional: ' + str(error * gain) print 'Integral : ' + str(integral * i_factor) print 'Derivative : ' + str(derivative * d_factor) self.motors.moveForwardDualSpeed(l, r) time.sleep(0.1) t += 0.1 self.motors.stop()
def turnTo(self, desired_bearing): """Turn the robot until it is facing desired_bearing. Args: desired_bearing (float): The bearing that the robot should be facing upon completion of the function. """ # Ensure we have sufficient priviledges to access compass. if not TiberiusConfigParser.isCompassEnabled(): raise SensorNotEnabledError("Compass is disabled, dependant \ function cannot be executed.") count = 0 while(True): count += 1 print 'Iteration: ' + str(count) if count < 50: time.sleep(0.1) # actual_bearing = self.compass.headingNormalized() actual_bearing = db_q.get_latest(CompassTable) error = actual_bearing - desired_bearing # self.logger.debug('Heading: ' + str(actual_bearing)) # self.logger.debug('Desired: ' + str(desired_bearing)) if(error < 5 and error > -5): # self.logger.debug('At heading: ' + str(actual_bearing)) self.motors.stop() break if(error > 180): #print 'error > 180' error -= 360 if(error < -180): #print 'error < -180' error += 360 if(error > 0): # print 'error < 0 turning left' self.motors.setSpeedPercent(100) self.motors.turnLeft() # Reduce speed on approach to desired bearing # Positive error is a left turn if(error < 60): self.motors.setSpeedPercent(70) self.motors.turnLeft() if(error < 30): self.motors.setSpeedPercent(40) self.motors.turnLeft() if(error < 5): self.motors.setSpeedPercent(20) self.motors.turnLeft() if(error < 0): # print 'error > 0 turning right' self.motors.setSpeedPercent(100) self.motors.turnRight() # Negative error is a right turn if(error > -60): self.motors.setSpeedPercent(70) self.motors.turnRight() if(error > -30): self.motors.setSpeedPercent(40) self.motors.turnRight() if(error > -5): self.motors.setSpeedPercent(20) self.motors.turnRight() # print str(error) else: print '50 Iterations Complete' break
from tiberius.navigation.gps.algorithms import Algorithms from tiberius.config.config_parser import TiberiusConfigParser from tiberius.control_api.middleware import AuthMiddleware # This is the main instance of Control that is used widely throughout this API. c = Control() api = application = falcon.API( media_type='application/json; charset=utf-8', middleware=[AuthMiddleware()] ) sensors = sensors.SensorResource() api.add_route('/sensors', sensors) if TiberiusConfigParser.areMotorsEnabled(): m = c.motors motors = motors.MotorResource(m) api.add_route('/motors', motors) if TiberiusConfigParser.isArmEnabled(): a = c.arm arm = robot_arm.RobotArmResource(a) api.add_route('/arm', arm) debug = debug.DebugResource() api.add_route('/debug', debug) task_controller = task_controller.TaskControllerResource() api.add_route('/task', task_controller)
def runTest(self): val = TiberiusConfigParser.isLidarEnabled() self.assertTrue(isinstance(val, (bool)))
def runTest(self): val = TiberiusConfigParser.getBatteryChemistry() self.assertTrue(val == "LiFe" or val == "LiPo" or val == "Lead")
def runTest(self): val = long(TiberiusConfigParser.getBatteryCapacity()) self.assertTrue(isinstance(val, (int, long))) self.assertTrue(100 <= val <= 10000)
def runTest(self): val = TiberiusConfigParser.getName() self.assertTrue(isinstance(val, (str))) # Max length based on specified max SSID length self.assertTrue(0 <= len(val) <= 32)
def runTest(self): st = TiberiusConfigParser.getSteeringType() self.assertTrue(st == "Skid" or st == "Articulated")
#!/usr/bin/env python from optparse import OptionParser from subprocess import Popen, PIPE from tiberius.database.database_threads import DatabaseThreadCreator from multiprocessing import Process from enum import Enum import sys import time from tiberius.config.config_parser import TiberiusConfigParser import tiberius.database.create as cr import tiberius.database.insert as ins from tiberius.communications import antenna_thread as ant_thread from tiberius.diagnostics.external_hardware_controller import compass_monitor from tiberius.database_wrapper.polyhedra_database import PolyhedraDatabase if TiberiusConfigParser.isEhcEnabled(): from tiberius.diagnostics.external_hardware_controller import ExternalHardwareController class Action(Enum): WEB_SERVER = 0 parser = OptionParser() parser.add_option( "-w", "--web-server", action="store_const", const=Action.WEB_SERVER, dest="action", help="Also start the web interface.")