Source code for scenic.simulators.newtonian.driving_model

"""Scenic world model for traffic scenarios in the Newtonian simulator.

This model implements the basic :obj:`` class from the
:obj:`` domain.
Vehicles support the basic actions and behaviors from the driving domain.

A path to a map file for the scenario should be provided as the ``map`` global parameter;
see the driving domain's documentation for details.

from scenic.simulators.newtonian.model import *

from import *  # includes basic actions and behaviors

from scenic.simulators.utils.colors import Color

simulator NewtonianSimulator(network, render=render)

class NewtonianActor(DrivingObject):
    throttle: 0
    steer: 0
    brake: 0
    hand_brake: 0
    reverse: 0

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._control = None    # used internally to accumulate control updates

    def setPosition(self, pos, elevation):
        self.position = pos

    def setVelocity(self, vel):
        self.velocity = vel

    def setThrottle(self, throttle):
        self.throttle = throttle

    def setSteering(self, steering):
        self.steer = steering

    def setBraking(self, braking):
        self.brake = braking

    def setHandbrake(self, handbrake):
        self.hand_brake = handbrake

    def setReverse(self, reverse):
        self.reverse = reverse

class Vehicle(Vehicle, NewtonianActor):

class Car(Vehicle, Steers):
    def isCar(self):
        return True

class Pedestrian(Pedestrian, NewtonianActor, Walks):

[docs]class Debris: """Abstract class for debris scattered randomly in the workspace.""" position: new Point in workspace yaw: Range(0, 360) deg