Exemplo n.º 1
0
    def test_should_init_with_expected_values(self):
        subject = VehicleCtl(self.mock_config_handler)

        # training manager, auto agent, etc...
        self.assertIsInstance(subject._mode, Mode)

        # Vehicle throttle,steering, etc...
        self.assertTrue(subject._last_cmd_sent.equal(Command()))
        self.assertEqual(Gear.DRIVE, subject._gear)
        self.assertEqual(0, subject._target_acceleration)
        self.assertEqual(subject._last_cmd_sent.get_steering(),
                         subject._target_steering)
Exemplo n.º 2
0
    def test_prepare_new_command_reverse_stationary(self):
        subject = VehicleCtl(self.mock_config_handler)
        subject._gear = Gear.REVERSE
        subject._target_steering = 0.0
        subject._target_acceleration = 0.0
        subject._last_cmd_sent = Command(0.0, 0.0)

        new_cmd = subject.prepare_new_command(self.dt)

        self.assertEqual(new_cmd.get_steering(), 0.0)
        self.assertEqual(new_cmd.get_throttle(), 0.0)
Exemplo n.º 3
0
    def test_prepare_new_command_park_outputs_stationary_command(self):
        subject = VehicleCtl(self.mock_config_handler)
        subject._gear = Gear.PARK
        subject._target_steering = 0.23
        subject._target_acceleration = -0.34
        subject._last_cmd_sent = Command(0.22, -1.0)

        new_cmd = subject.prepare_new_command(self.dt)

        self.assertEqual(new_cmd.get_steering(), 0.0)
        self.assertEqual(new_cmd.get_throttle(), 0.0)
Exemplo n.º 4
0
    def test_prepare_new_command_forward_max_at_1_point_0(self):
        subject = VehicleCtl(self.mock_config_handler)
        subject._gear = Gear.DRIVE
        subject._target_steering = 0.0
        subject._target_acceleration = 1.0
        subject._last_cmd_sent = Command(s=0.0, t=1.0)

        new_cmd = subject.prepare_new_command(self.dt)

        self.assertEqual(new_cmd.get_steering(), 0.0)
        self.assertEqual(new_cmd.get_throttle(), 1.0)
Exemplo n.º 5
0
    def test_prepare_new_command_forward_braking(self):
        subject = VehicleCtl(self.mock_config_handler)
        subject._gear = Gear.DRIVE
        subject._target_steering = 0.0
        subject._target_acceleration = -1.0
        subject._last_cmd_sent = Command(s=0.0, t=1.0)
        expected_instant_acc = -1.0 * self.dt  #this test verifies that instant_acc is not less than -1, before considering dt

        new_cmd = subject.prepare_new_command(self.dt)

        self.assertEqual(new_cmd.get_steering(), 0.0)
        self.assertEqual(new_cmd.get_throttle(), 1.0 + expected_instant_acc)
Exemplo n.º 6
0
    def test_prepare_new_command_forward_coasting(self):
        subject = VehicleCtl(self.mock_config_handler)
        subject._gear = Gear.DRIVE
        subject._target_steering = 0.0
        subject._target_acceleration = 0.0
        subject._last_cmd_sent = Command(s=0.0, t=1.0)
        expected_instant_acc = (0.0 - VehicleCtl.degradation_factor) * self.dt

        new_cmd = subject.prepare_new_command(self.dt)

        self.assertEqual(new_cmd.get_steering(), 0.0)
        self.assertEqual(new_cmd.get_throttle(), 1.0 + expected_instant_acc)
Exemplo n.º 7
0
    def test_prepare_new_command_reverse_coasting(self):
        subject = VehicleCtl(self.mock_config_handler)
        subject._gear = Gear.REVERSE
        subject._target_steering = 0.0
        subject._target_acceleration = 0.0
        subject._last_cmd_sent = Command(0.0, -1.0)
        expectedAcc = (0.0 + VehicleCtl.degradation_factor) * self.dt

        new_cmd = subject.prepare_new_command(self.dt)

        self.assertEqual(new_cmd.get_steering(), 0.0)
        self.assertEqual(new_cmd.get_throttle(), -1.0 + expectedAcc)
Exemplo n.º 8
0
from client.auto_agent import AutoAgent
from client.image_stream_server import ImageStreamServer
from client.telemetry_processor import TelemetryProcessor

if __name__ == "__main__":

    # Set the log level
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    # Setup the image server to receive images from the vehicle. Needs to happen before creating the
    image_stream_server = ImageStreamServer()
    image_stream_server.start()

    # Setup the primary vehicle control class and start it
    vehicle_ctl = VehicleCtl(ConfigHandler.get_instance())
    vehicle_ctl.start()
    # Automatically start up the image stream
    vehicle_ctl.request_stream_start()

    # Create the auto agent
    auto_agent = AutoAgent(vehicle_ctl)
    auto_agent.start()

    # Create the telemetry processor
    telemetry_proc = TelemetryProcessor(auto_agent)
    telemetry_proc.start()

    # Create the Qt application and launch
    app = QtWidgets.QApplication(sys.argv)
    mainWin = MainWindow(vehicle_ctl, image_stream_server)