Ejemplo n.º 1
0
# Import Webots-specific functions
from controller import Display
from vehicle import Driver

# Import functions from other scripts in controller folder
from util import *
from your_controller import CustomController
from evaluation import evaluation

trajectory = getTrajectory('buggyTrace.csv')

# Instantiate supervisor and functions
driver = Driver()
driver.setDippedBeams(True)
driver.setGear(1)  # Torque control mode
throttleConversion = 15737
msToKmh = 3.6

# Access and set up displays
console = driver.getDisplay("console")
speedometer = driver.getDisplay("speedometer")
console.setFont("Arial Black", 14, True)
speedometerGraphic = speedometer.imageLoad("speedometer.png")
speedometer.imagePaste(speedometerGraphic, 0, 0, True)

consoleObject = DisplayUpdate(console)
speedometerObject = DisplayUpdate(speedometer)

# Get the time step of the current world
timestep = int(driver.getBasicTimeStep())
Ejemplo n.º 2
0
from vehicle import Driver
import os
import pickle

curr_dir = os.getcwd()
par_dir = curr_dir[:curr_dir.rfind('/')]

driver = Driver()

driver.setSteeringAngle(0.0)
driver.setGear(1)
driver.setThrottle(1)
driver.setCruisingSpeed(100)

camera = driver.getCamera('camera')
camera.enable(1)

brake_coeff = 9.0
counter = 0
braking = False
braking_threshold = 0.3
friction_acc = 0.5

ignore_smart_intersection = True  # Set this to True if you want to ignore smart intersection
while driver.step() != -1:
    counter = counter + 1

    speed = driver.getCurrentSpeed() * (5. / 18.)

    while True:
        try: