Experimental module using computer vision to steer vehicle within motorway lanes. This module is NOT functional at all. The module was aimed at ETS2 to maintain focus on the vehicle's mirrors, and adjusting the heading error and lateral error of the white road side lines to desired values. Some struggles: - Computer vision can be hard for various road conditions (dark, fog, rain) - Some ETS2 mods mess up mirror positions and scale. - FOV - Measuring heading and lateral error was inaccurate, partly due to computer vision troubles. - Control of lateral/heading error was instable. This module needs a lot more work to (ever) work properly.
Наследование: IControlChainObj
Пример #1
0
        public static bool Setup()
        {
            if (requiresSetup)
            {
                requiresSetup = false;

                JoystickInput deskCtrl, g25Wheel, ps4Ctrl;

                // Joysticks
                var dskObj = JoystickInputDevice.Search("Hotas").FirstOrDefault();
                deskCtrl = dskObj == null ? default(JoystickInput) : new JoystickInput(dskObj);

                var ps4Obj = JoystickInputDevice.Search("Wireless Controller").FirstOrDefault();
                ps4Ctrl = ps4Obj== null ? default(JoystickInput) : new JoystickInput(ps4Obj);

                var g25Obj = JoystickInputDevice.Search("G25").FirstOrDefault();
                g25Wheel = g25Obj == null ? default(JoystickInput) : new JoystickInput(g25Obj);
                var vJoy = new JoystickOutput();

                // add main controller:
                if (dskCtlActive)
                    RawJoysticksIn.Add(deskCtrl);
                else if (ps4CtlActive)
                    RawJoysticksIn.Add(ps4Ctrl);
                else
                    RawJoysticksIn.Add(default(JoystickInput));
                RawJoysticksIn.Add(g25Wheel);
                RawJoysticksOut.Add(vJoy);

                // Data source
                Data = new DataArbiter();

                Data.CarChanged += (s, e) =>
                                       {
                                           if (Data.Active.Application == "eurotrucks2")
                                               Drivetrain = new Ets2Drivetrain();
                                           else
                                               Drivetrain = new GenericDrivetrain();

                                           // reset all modules
                                           Antistall.ResetParameters();
                                           CruiseControl.ResetParameters();
                                           Drivetrain.ResetParameters();
                                           Transmission.ResetParameters();
                                           TractionControl.ResetParameters();
                                           Speedlimiter.ResetParameters();

                                           CarProfile = new Profiles(Data.Active.Application, Data.Telemetry.Car);
                                           LoadNextProfile(10000);
                                       };

                // TODO: Temporary..
                Data.AppActive += (s, e) =>
                                      {
                                          CameraHorizon.CameraHackEnabled = Data.Active.Application == "TestDrive2";
                                      };

                if (deskCtrl == null && g25Wheel == null && ps4Ctrl == null)
                {
                    //MessageBox.Show("No controllers found");
                    return false;
                }

                // Modules
                Antistall = new Antistall();
                ACC = new ACC();
                CruiseControl = new CruiseControl();
                Drivetrain = new GenericDrivetrain();
                Transmission = new Transmission();
                TractionControl = new TractionControl();
                ProfileSwitcher = new ProfileSwitcher();
                Speedlimiter = new Speedlimiter();
                LaunchControl = new LaunchControl();
                DrivetrainCalibrator = new DrivetrainCalibrator();
                TransmissionCalibrator = new TransmissionCalibrator();
                LaneAssistance = new LaneAssistance();
                VariableSpeedControl = new VariableSpeedTransmission();
                CameraHorizon = new CameraHorizon();

                // Controls
                Controls = new ControlChain();

                Data.Run();
                return true;

            }
            return false;
        }
Пример #2
0
        public static bool Setup()
        {
            if (requiresSetup)
            {
                requiresSetup = false;

                JoystickInput deskCtrl, g25Wheel, ps4Ctrl;

                // Joysticks
                var dskObj = JoystickInputDevice.Search("Hotas").FirstOrDefault();
                deskCtrl = dskObj == null ? default(JoystickInput) : new JoystickInput(dskObj);

                var ps4Obj = JoystickInputDevice.Search("Wireless Controller").FirstOrDefault();
                ps4Ctrl = ps4Obj == null ? default(JoystickInput) : new JoystickInput(ps4Obj);

                var g25Obj = JoystickInputDevice.Search("G25").FirstOrDefault();
                g25Wheel = g25Obj == null ? default(JoystickInput) : new JoystickInput(g25Obj);
                var vJoy = new JoystickOutput();

                // add main controller:
                if (dskCtlActive)
                {
                    RawJoysticksIn.Add(deskCtrl);
                }
                else if (ps4CtlActive)
                {
                    RawJoysticksIn.Add(ps4Ctrl);
                }
                else
                {
                    RawJoysticksIn.Add(default(JoystickInput));
                }
                RawJoysticksIn.Add(g25Wheel);
                RawJoysticksOut.Add(vJoy);

                // Data source
                Data = new DataArbiter();

                Data.CarChanged += (s, e) =>
                {
                    if (Data.Active.Application == "eurotrucks2")
                    {
                        Drivetrain = new Ets2Drivetrain();
                    }
                    else
                    {
                        Drivetrain = new GenericDrivetrain();
                    }

                    // reset all modules
                    Antistall.ResetParameters();
                    CruiseControl.ResetParameters();
                    Drivetrain.ResetParameters();
                    Transmission.ResetParameters();
                    TractionControl.ResetParameters();
                    Speedlimiter.ResetParameters();

                    CarProfile = new Profiles(Data.Active.Application, Data.Telemetry.Car);
                    LoadNextProfile(10000);
                };

                // TODO: Temporary..
                Data.AppActive += (s, e) =>
                {
                    CameraHorizon.CameraHackEnabled = Data.Active.Application == "TestDrive2";
                };


                if (deskCtrl == null && g25Wheel == null && ps4Ctrl == null)
                {
                    //MessageBox.Show("No controllers found");
                    return(false);
                }

                // Modules
                Antistall              = new Antistall();
                ACC                    = new ACC();
                CruiseControl          = new CruiseControl();
                Drivetrain             = new GenericDrivetrain();
                Transmission           = new Transmission();
                TractionControl        = new TractionControl();
                ProfileSwitcher        = new ProfileSwitcher();
                Speedlimiter           = new Speedlimiter();
                LaunchControl          = new LaunchControl();
                DrivetrainCalibrator   = new DrivetrainCalibrator();
                TransmissionCalibrator = new TransmissionCalibrator();
                LaneAssistance         = new LaneAssistance();
                VariableSpeedControl   = new VariableSpeedTransmission();
                CameraHorizon          = new CameraHorizon();

                // Controls
                Controls = new ControlChain();

                Data.Run();
                return(true);
            }
            return(false);
        }