Esempio n. 1
0
 def start_wheels(self):
     """Start the Wheels Process"""
     self.ns.target_steering = SteeringDirection.NONE
     self.ns.target_throttle = 0
     # Create class and process
     self.wheels = Wheels(self.ns)
     self._start_process("wheels")
Esempio n. 2
0
    def __init__(self, scanInterval=0.1):
        self.sensors = DistanceSensors()
        self.robot = Wheels()

        self.previousDistance = -1.0
        self.previousDirection = Direction.Stop
        self.stuckCount = 0

        # start distance scanning
        if not (self.sensors.StartScanner(scanInterval, True)):
            raise SensorException("Distance sensors not working")
Esempio n. 3
0
 def __init__(self, manufacturer):
     # the names list contains model from Specialized bikes as I am a huge fan of its bikes (I own one! :-))
     names = [
         "Pitch", "Epic", "Source", "Enduro", "Fatboy", "Status", "Demo",
         "Tarmac", "Allez", "Venge", "Shiv", "Roubaix", "Secteur",
         "Diverge", "Awol", "Crux", "Langster", "Sirrus", "Daily",
         "Crosstail", "CossRoads", "Expedition"
     ]
     self.frame = Frames(1)
     self.wheels = Wheels(1)
     self.manufacturer = manufacturer
     self.model_name = choice(names)
     self.weight = (self.frame.frame_weight +
                    2 * self.wheels.wheel_weight) / 1000.0
     self.cost = self.frame.frame_cost + 2 * self.wheels.wheel_cost
Esempio n. 4
0
 def __init__(self):
     self.wheels = Wheels()
     pass
Esempio n. 5
0
import sys
import RPi.GPIO as GPIO
from wheels import Wheels

GPIO.setmode(GPIO.BCM)

robot = Wheels()
robot.Stop()

GPIO.cleanup()
Esempio n. 6
0
        return self.age

    def getSpeed(self):
        return self.speed

    #A method to increase/decrease speed. Time is in seconds
    #Amount is the speed increase per second in km/h
    def accelerate(self, time, amount):
        i = 0

        #increase speed as time X amount
        while i < time:
            self.speed += amount
            if (self.speed >= self.maxSpeed):
                self.speed = self.maxSpeed
                break
            i += 1


newTreds = Wheels()
newTreds.changeTire(0, 10)
newTreds.changeTire(1, 10)
newTreds.changeTire(2, 10)
newTreds.changeTire(3, 10)
lancer = Car("lancer", newTreds, "LPG", "2L", "Auto", "Burgandy", 145)
print(lancer)
lancer.accelerate(10, 20)
print(lancer.getSpeed())
print(lancer.wheels)
newTreds.changeTire(0, -1)
print(lancer.wheels)
Esempio n. 7
0
from boat import Boat
from car import Car
from engine import Engine
from gas_tank import GasTank
from solar_car import SolarCar
from wheels import Wheels


def drive(driveable):
    driveable.get_wheels_count()
    driveable.turn('Right')
    driveable.accelerate()
    driveable.turn('Right')
    driveable.brake()


if __name__ == '__main__':
    car = Car(GasTank(60), Engine(80), Wheels(4))
    solarCar = SolarCar(GasTank(50), Engine(120), Wheels(8))
    boat = Boat(GasTank(900), Engine(200), Wheels(0))

    for i in [boat, car, solarCar]:
        drive(i)
Esempio n. 8
0
from boat import Boat
from car import Car
from engine import Engine
from gas_tank import GasTank
from solar_car import SolarCar
from wheels import Wheels


def test_drive(driveable):
    driveable.get_wheels_count()
    driveable.turn('Ліво')
    driveable.accelerate()
    driveable.turn('Ліво')
    driveable.brake()


if __name__ == '__main__':
    car = Car(GasTank(29), Engine(35), Wheels(4))
    solarCar = SolarCar(GasTank(10), Engine(25), Wheels(4))
    boat = Boat(GasTank(58), Engine(36), Wheels(0))

    vehicles = [boat, car, solarCar]

    for i in vehicles:
        test_drive(i)
Esempio n. 9
0
class Car:
    engine = Engine()  # подключаем двигатель
    transmission = Transmission()  # подключаем КП
    wheels = Wheels()  # подключаем колёса

    def __init__(self):
        self.path = 0
        self.power = False
        self.gasoline = 0.0
        self.oil = 0.0
        self.speed = 0.0
        self.__time_start = 0

    def __repr__(self):
        self.transforms()
        return "Данные автомобиля и поездки:\n" \
               "\tзапущен = %s\n" \
               "\tуровень топлива = %s л.\n" \
               "\tуровень масла = %s %%\n" \
               "\tскорость = %s км/ч\n" \
               "\tпройденый путь = %s км" % (self.power, self.gasoline, self.oil, self.speed, self.path)

    def transforms(self):  # соединение классов, получение данных для вывода
        self.engine.time = self.power * (time.time() - self.__time_start)
        self.transmission.turns_engine = self.engine.turns_engine()
        self.wheels.turns_wheels = self.transmission.clutch_pedal()
        self.power = self.engine.power
        self.gasoline = self.engine.gasoline
        self.oil = self.transmission.oil * 100
        self.get_speed()
        self.path = self.wheels.transform_path()

    def turn_on(self):  # включить двигатель, начинаем отсчёт времени
        try:
            self.engine.start_engine()
        except Exception as e:
            print("Авто не поедет, пока есть проблемы:\n %s" % e)
        else:
            self.__time_start = time.time()
            print("Вжжжжжжжж-чух-чух-чух-чух")

    def turn_off(self):  # выключить двигатель
        self.engine.stop_engine()
        print("Двигатель выключен")

    def add_gasoline(self, litres):  # добавить топлива
        self.engine.add_gasoline(litres)
        print("Машина заправлена. Всего в баке %s литров бензина" %
              self.engine.gasoline)

    def add_oil(self):  # восстановить масло
        self.transmission.add_oil()
        print("Ты зашёл на ближайшую СТО и поменял масло. Какой молодец ^_^ ")

    def change_speed(self,
                     gas=engine.gas,
                     gear=transmission.gear):  # изменить скорость
        self.transmission.gear = gear
        self.engine.gas = gas
        print(
            "Теперь ты едешь на %s передаче и нажал газ на %s градусов. Какой молодец ^_^ "
            % (self.transmission.gear, self.engine.gas))

    def get_speed(self):  # расчитать скорость
        try:
            self.speed = self.engine.rpm * self.transmission.gear * self.wheels.wheel * 60
        except Exception:
            self.speed = 0
        return self.speed
Esempio n. 10
0
pig = pigpio.pi()

def input_char(message):
    try:
        win = curses.initscr()
        win.addstr(0, 0, message)
        while True:
            ch = win.getch()
            if ch in range(32, 127): break
            time.sleep(0.05)
    except: raise
    finally:
        curses.endwin()
    return chr(ch)

wheels = Wheels(pig, left_servo_pin, right_servo_pin)

s = 22

def forward():
    set_speeds(s,s)

def backward():
    set_speeds(-s, -s)

def left():
    set_speeds(0, s)

def right():
    set_speeds(s, 0)
Esempio n. 11
0
from sensors import Sensor
from sensors import Sensors
from wheels import Wheel
from wheels import MockWheel
from wheels import Wheels
import RPi.GPIO as GPIO
from runtime import Runtime
from processor import Processor

GPIO.setmode(GPIO.BOARD)

sensor1 = Sensor(11, 13)
sensor3 = Sensor(15, 16)
sensor5 = Sensor(18, 19)
sensor6 = Sensor(21, 22)
sensor8 = Sensor(23, 24)
sensor10 = Sensor(26, 29)

leftMotor = Wheel(5, 3, 7, 7)
rightMotor = Wheel(8, 10, 12, 1)
# rightMotor = MockWheel("rightWheel")

zrobot_runtime = Runtime(
    Sensors([sensor1, sensor3, sensor5, sensor6, sensor8, sensor10]),
    Processor(), Wheels(leftMotor, rightMotor))
zrobot_runtime.start()