/** Go Straight using the IMU */ public ServoHoldHeadingWithImu(PigeonIMU pigeonImu, IDrivetrain driveTrain, Styles.BasicStyle selectedStyle, ServoParameters parameters, float targetHeading, float maxOutput) { _pidgey = pigeonImu; _driveTrain = driveTrain; _selectedStyle = selectedStyle; _targetHeading = targetHeading; _servoParams = parameters; _maxOutput = maxOutput; }
private void Start() { _drivetrain = GetComponentInChildren <IDrivetrain>(); if (_drivetrain == null) { Debug.LogWarning($"Missing {nameof(IDrivetrain)} in children of {transform.name}"); } }
public ShifterTableConfiguration(ShifterTableConfigurationDefault def, IDrivetrain drivetrain, int spdPerGear, float staticMass) { Mode = def; SpdPerGear = spdPerGear; Mass = staticMass; Air = new Ets2Aero(); Drivetrain = drivetrain; MaximumSpeed = 600; switch (def) { case ShifterTableConfigurationDefault.PeakRpm: DefaultByPeakRpm(); break; case ShifterTableConfigurationDefault.Performance: DefaultByPowerPerformance(); break; case ShifterTableConfigurationDefault.Economy: DefaultByPowerEconomy(); break; case ShifterTableConfigurationDefault.Efficiency: DefaultByPowerEfficiency(); break; case ShifterTableConfigurationDefault.AlsEenOpa: DefaultByOpa(); break; case ShifterTableConfigurationDefault.Henk: DefaultByHenk(); break; case ShifterTableConfigurationDefault.PowerEfficiency: DefaultByPowerEfficiency2(); break; } if (spdPerGear > 0) { var spdPerGearReduced = spdPerGear - staticMass/1000/1.25; if (spdPerGearReduced < 1) spdPerGearReduced = 1; Console.WriteLine("Spd per gear:"+spdPerGearReduced); MinimumSpeedPerGear((int)Math.Round(spdPerGearReduced)); } string l = ""; for(var r = 0; r < 2500; r+=10) { var fuel=Drivetrain.CalculateFuelConsumption(r, 1); var ratio = drivetrain.CalculatePower(r, 1)/fuel; l += r + "," + Drivetrain.CalculatePower(r, 1) + "," + Drivetrain.CalculatePower(r, 0) + ","+fuel+","+ratio+"\r\n"; } //File.WriteAllText("./ets2engine.csv", l); }
public SimulationEnvironment() { drivetrain = new Ets2Drivetrain(); Main.Load(drivetrain, "Settings/Drivetrain/eurotrucks2.scania.g7ld6x2.ini"); shifter = new ShifterTableConfiguration(ShifterTableConfigurationDefault.Performance, drivetrain, 1, 0); Speed = 30/3.6; StringBuilder sim = new StringBuilder(); for (int k = 0; k < 10000; k++) { Tick(); sim.AppendLine(k + "," + Speed); } File.WriteAllText("./sim.csv", sim.ToString()); }
public SimulationEnvironment() { drivetrain = new Ets2Drivetrain(); Main.Load(drivetrain, "Settings/Drivetrain/eurotrucks2.scania.g7ld6x2.ini"); shifter = new ShifterTableConfiguration(ShifterTableConfigurationDefault.Performance, drivetrain, 1, 0); Speed = 30 / 3.6; StringBuilder sim = new StringBuilder(); for (int k = 0; k < 10000; k++) { Tick(); sim.AppendLine(k + "," + Speed); } File.WriteAllText("./sim.csv", sim.ToString()); }
/** Go Straight using the IMU */ public ServoHoldHeadingWithImu(PigeonIMU pigeonImu, IDrivetrain driveTrain, Styles.BasicStyle selectedStyle) { _pidgey = pigeonImu; _driveTrain = driveTrain; _selectedStyle = selectedStyle; }
public ShifterTableConfiguration(ShifterTableConfigurationDefault def, IDrivetrain drivetrain, int spdPerGear, float staticMass) { Mode = def; SpdPerGear = spdPerGear; Mass = staticMass; Air = new Ets2Aero(); Drivetrain = drivetrain; MaximumSpeed = 600; switch (def) { case ShifterTableConfigurationDefault.PeakRpm: DefaultByPeakRpm(); break; case ShifterTableConfigurationDefault.Performance: DefaultByPowerPerformance(); break; case ShifterTableConfigurationDefault.Economy: DefaultByPowerEconomy(); break; case ShifterTableConfigurationDefault.Efficiency: DefaultByPowerEfficiency(); break; case ShifterTableConfigurationDefault.AlsEenOpa: DefaultByOpa(); break; case ShifterTableConfigurationDefault.Henk: DefaultByHenk(); break; case ShifterTableConfigurationDefault.PowerEfficiency: DefaultByPowerEfficiency2(); break; } if (spdPerGear > 0) { var spdPerGearReduced = spdPerGear - staticMass / 1000 / 1.25; if (spdPerGearReduced < 1) { spdPerGearReduced = 1; } Console.WriteLine("Spd per gear:" + spdPerGearReduced); MinimumSpeedPerGear((int)Math.Round(spdPerGearReduced)); } string l = ""; for (var r = 0; r < 2500; r += 10) { var fuel = Drivetrain.CalculateFuelConsumption(r, 1); var ratio = drivetrain.CalculatePower(r, 1) / fuel; l += r + "," + Drivetrain.CalculatePower(r, 1) + "," + Drivetrain.CalculatePower(r, 0) + "," + fuel + "," + ratio + "\r\n"; } //File.WriteAllText("./ets2engine.csv", l); }
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; }
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); }