Source code for scenic.simulators.newtonian.driving_model

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

This model implements the basic :obj:`~scenic.domains.driving.model.Car` class from the
:obj:`scenic.domains.driving` 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.

Global Parameters:
    debugRender (bool): If ``True``, enables a debug view that draws simple
        polygons for objects in the Newtonian window. Default is ``False``.
"""

from scenic.simulators.newtonian.model import *

from scenic.domains.driving.model import *  # includes basic actions and behaviors

from scenic.simulators.utils.colors import Color

param debugRender = False

simulator NewtonianSimulator(network, render=render, debug_render=globalParameters.debugRender)

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):
    pass

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

class Pedestrian(Pedestrian, NewtonianActor, Walks):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.control = {'heading': None, 'speed': None}

    def setWalkingDirection(self, heading):
        self.control['heading'] = heading

    def setWalkingSpeed(self, speed):
        self.control['speed'] = speed

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