def generate_path(self, new_destination=None): """ Find (or not) the path to the given (or not) destination. """ # Set the destination if isinstance(new_destination, __roundabout__.Roundabout ) and new_destination in __track__.track.roundabouts: destination = new_destination else: # EXPERIMENTAL : leaving nodes only destination = choice([ roundabout for roundabout in self.track.roundabouts if len(roundabout.leaving_roads) == 0 ]) # Compute the path # Each car needs its own gps instance to avoid collisions and clean pathfinding self.gps = __gps__.Gps() self.path = self.gps.find_path(self.road.start, destination) self.destination = None if self.path: if len(self.path) > 0: self.destination = destination
def __init__(self): self.gps = gps.Gps() self.radio = radio.radio() #開始時間の記録 self.startTime = time.time() self.timer = 0
def __init__(self): #オブジェクトの生成 #self.rightmotor = motor.motor(ct.const.RIGHT_MOTOR_VREF_PIN,ct.const.RIGHT_MOTOR_IN1_PIN,ct.const.RIGHT_MOTOR_IN2_PIN) #self.leftmotor = motor.motor(ct.const.LEFT_MOTOR_VREF_PIN,ct.const.LEFT_MOTOR_IN1_PIN,ct.const.LEFT_MOTOR_IN2_PIN) self.gps = gps.Gps() #self.bno055 = bno055.BNO() self.radio = radio.radio() #self.ultrasonic = ultrasonic.Ultrasonic() #self.RED_LED = led.led(ct.const.RED_LED_PIN) #self.BLUE_LED = led.led(ct.const.BLUE_LED_PIN) #self.GREEN_LED = led.led(ct.const.GREEN_LED_PIN) #開始時間の記録 self.startTime = time.time() self.timer = 0 """
def __init__(self, i2c_bus=100, i2c_sensors_addr=[0x10, 0x26, 0x61], gps_port='/dev/ttyACM100', gps_rate=9600, gprs_port='/dev/ttyACM200', gprs_rate=9600, gprs_apn='tim.com.br'): self.light_sensor = i2c_sensors.LightSensor(i2c_sensors_addr[0], i2c_bus) self.distance_sensor = i2c_sensors.DistanceSensor( i2c_sensors_addr[1], i2c_bus) self.battery_sensor = i2c_sensors.BatterySensor( i2c_sensors_addr[2], i2c_bus) self.gps_sensor = gps.Gps(gps_port, gps_rate) self.modem = gprs.Gprs(gprs_port, gprs_rate) self.modem.open_connection(gprs_apn)
""" import time import board import busio import air_quality import gps import adafruit_bme280 import aio import adafruit_logging as logging logger = logging.getLogger('main') logger.setLevel(logging.INFO) gps_uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=3.000) gps_interface = gps.Gps(gps_uart) gps_interface.begin() logger.debug('GPS started') aio_interface = aio.AIO() if aio_interface.onboard_esp: air_uart = busio.UART(board.D5, board.D7, baudrate=9600) else: air_uart = busio.UART(board.A2, board.A3, baudrate=9600) air = air_quality.AirQualitySensor(air_uart) logger.debug('Air quality sensor started') i2c = busio.I2C(board.SCL, board.SDA)
def main(): print("Affichage de la distance à la destination et les longitudes.") myGps = gps.Gps() myGps.read_next() myGps.read_next() print(myGps.longitude()) print(myGps.latitude()) longDest = 1.465776 latDest = 43.561068 lastLong = myGps.longitude() lastLat = myGps.latitude() myMotor = mn.Motor() lastLongDD = gpsD.DmToDD(lastLong[0], lastLong[1]) lastLatDD = gpsD.DmToDD(lastLat[0], lastLat[1]) lastLatDD_minus1 = lastLatDD lastLongDD_minus1 = lastLongDD while (gpsD.haversine(lastLongDD, lastLatDD, longDest, latDest) > 5): distance = gpsD.haversine(lastLongDD, lastLatDD, longDest, latDest) print('########################################################') print('# Distance à la destination: ' + str(distance) + ' métres') print('# Longitude actuelle: ' + str(lastLongDD) + ' Latitude actuelle: ' + str(lastLatDD) + '\n# Longitude destination: ' + str(longDest) + ' Latitude destination: ' + str(latDest)) print('########################################################') myMotor.forward(102) # Correction de la trajectoire orientationActuelle = gpsD.DegreeBearing(lastLatDD_minus1, lastLongDD_minus1, lastLatDD, lastLongDD) orientationNeeded = gpsD.DegreeBearing(lastLatDD, lastLongDD, latDest, longDest) deltaToCorrect = (orientationNeeded + 360 - orientationActuelle) % 360 print("--------------------------------------------------------") print(" Orientation ACTUELLE : " + str(orientationActuelle)) print(" Orientation Dont ON a besoin : " + str(orientationNeeded)) print(" Difference à Corriger " + str(deltaToCorrect)) print("--------------------------------------------------------") angleDefaut = orientationActuelle - orientationNeeded if angleDefaut > 180: angleDefaut = angleDefaut - 360 elif angleDefaut < -180: angleDefaut = angleDefaut + 360 angleDeltaErreur = 10 if angleDefaut > 0 and angleDefaut > angleDeltaErreur: #-tourner a gauche myMotor.left() time.sleep(0.5) pass elif angleDefaut < 0 and angleDefaut > -angleDeltaErreur: # Tourner a droite myMotor.right() time.sleep(0.5) else: myMotor.straigth_wheel() time.sleep(0.5) time.sleep(1) # Interogation du gps myGps.read_next() # Récupération de nouvelles coordonnées lastLong = myGps.longitude() lastLat = myGps.latitude() # Sauvegade des ancienne coordonnée pour connaitre ma direction à l'instant t lastLongDD_minus1 = lastLongDD lastLatDD_minus1 = lastLatDD # COnvertion en Degrées décimaux lastLongDD = gpsD.DmToDD(lastLong[0], lastLong[1]) lastLatDD = gpsD.DmToDD(lastLat[0], lastLat[1]) myMotor.stop() print(myGps.longitude()) print(myGps.latitude())
def __init__(self): self.gps = gps.Gps()