Hi Radu, I don't have any PC installed with Windows, so I couldn't verify it on Windows, maybe I can use a docker container with Ubuntu 20.04 and newer compiler for verification later.
My newest compile command is: cmake -G"Unix Makefiles" -H/root/chrono -B/root/build_chrono -DBUILD_DEMOS=ON -DBUILD_BENCHMARKING=ON -DENABLE_MODULE_IRRLICHT=ON -DENABLE_MODULE_POSTPROCESS=ON -DENABLE_MODULE_VEHICLE=ON -DENABLE_MODULE_OPENGL=ON -DENABLE_MODULE_GPU=ON -DENABLE_MODULE_SYNCHRONO=ON -DCMAKE_BUILD_TYPE=Release --install-prefix=/usr/local/chrono make -j4 make install Now, I have removed all the code related to Irrlicht from demo_VEH_WheeledJSON.cpp, and I provide a constant throttle value (0.5) and print vehicle speed, simulation time and RTF to console in each iteration. In this case, the RTF was reduced from 50-70 to about 0.75, so I feel that Irrlicht cost a huge resource, but I don't know whether my modification is correct, the modified demo_VEH_WheeledJSON.cpp is in attachment. Thanks for help! 在2023年8月9日星期三 UTC+8 19:01:03<Radu Serban> 写道: > Hi Bean, > > > > While you may want to consider upgrading your Ubuntu distribution and GCC > compiler, I don’t see any particular issues with your hardware or software. > > > > I still suspect that you have not really built Chrono in Release mode. > You may want to do a fresh build and also enable CMAKE_VERBOSE_MAKEFILE so > that you can check that the appropriate optimization flags are being used > during the build process. > > > > For reference, demo_VEH_WheeledJSON runs at an RTF of around 0.5 (so twice > faster than real time) on my AMD Ryzen 7 3700X desktop and an Nvidia RTX > 2060 (Windows). Even on my Surface 8 Pro with an Intel Core i7-1185GT and > integrated graphics, I get an RTF of 0.9-1.1 for that demo. By the way, > the reported RTF does not include rendering; an RTF 50-70 points to a > non-release build (I get an RTF of around 55 with Debug code on my desktop). > > > > --Radu > > > > > > > > *From:* [email protected] <[email protected]> *On > Behalf Of *Bean Young > *Sent:* Wednesday, August 9, 2023 9:09 AM > *To:* ProjectChrono <[email protected]> > *Subject:* Re: [chrono] Re: why can't the vehicle in demo_VEH_WheeledJSON > move? > > > > Hi Radu, > > > > I had switched to main branch, and added -DCMAKE_BUILD_TYPE=Release to my > cmake command, after compilation finished, then I ran demo_VEH_WheeledJSON > again, but above problems still remain: > > > > 1. RTF (real time factor) is too large, about 50 - 70 > > 2. frame rate is too low, it looks like Irrlicht doesn't use GPU for > rendering, run nvidia-smi command, there is no demo process in output > > > > My compiling and running env is as follows: > > > > CPU: Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz > > GPU: Quadro RTX 4000 > > OS: Ubuntu 18.04 x86_64 > > cmake: 3.25.2 > > GCC & G++: 7.5.0 > > > > Is there any problem in my env or compilation process? > > > > 在2023年8月9日星期三 UTC+8 13:05:36<Radu Serban> 写道: > > Bean, > > > > You are actually *not *building in Release mode. The default build type > for CMake is the “empty” build type which does *not* use any optimization > flags. > > Add -DCMAKE_BUILD_TYPE=Release to your cmake command. > > > > The delay you see in vehicle response is most likely due to processing and > buffering of keyboard events combined with slow simulation (because the > code was not built in release mode). Unless modified, that demo uses by > default a HMMWV model and that vehicle is a bit more responsive than what > you observe. Having said that, the proper way of testing vehicle > performance (e.g., acceleration performance) is by setting driver inputs > (throttle) programmatically and not interactively. See for example > demo_VEH_HMMWV_Accel. > > > > Finally, unless you have a strong reason not to, I strongly suggest you > checkout the ‘main’ branch of the Chrono repository. We continuously push > fixes and improvements to the code and many of those occurred since the 8.0 > release. Working with the current development code also makes it easier for > people to test and check issues users report (few will keep around a clone > of the released version). > > > > --Radu > > > > *From:* [email protected] <[email protected]> *On > Behalf Of *Bean Young > *Sent:* Wednesday, August 9, 2023 4:26 AM > *To:* ProjectChrono <[email protected]> > *Subject:* Re: [chrono] Re: why can't the vehicle in demo_VEH_WheeledJSON > move? > > > > Hi Dan, > > > > I ran demo_VEH_WheeledJSON on my workstation with 20-core cpu (@2.40 Hz) > and 32 GB RAM, and built the code in release mode, but this demo and others > are running very slowly, and the frame rate is very slow, I don't know what > went wrong. The compile command I used, is as follows: > > > > cmake -G"Unix Makefiles" -H/root/chrono -B/root/build_chrono > -DENABLE_MODULE_IRRLICHT=ON -DENABLE_MODULE_POSTPROCESS=ON > -DENABLE_MODULE_VEHICLE=ON -DENABLE_MODULE_OPENGL=ON -DENABLE_MODULE_GPU=ON > --install-prefix=/usr/local/chrono > make -j4 > make install > > 在2023年8月9日星期三 UTC+8 09:53:24<Dan Negrut> 写道: > > Bean - I think it’s relatively reasonable to expect a vehicle to take 2 > seconds to reach 5.15 m/s. That’s 18.5 km/h – this value depends on the > mass of the vehicle and engine used (HMMWV, it seems). This vehicle > simulation should be real time, unless you have an old laptop or so. Also, > make sure you built the code in release mode, not debug mode. > > Dan > > --------------------------------------------- > > Bernard A. and Frances M. Weideman Professor > > NVIDIA CUDA Fellow > > Department of Mechanical Engineering > > Department of Computer Science > > University of Wisconsin - Madison > > 4150ME, 1513 University Avenue > > Madison, WI 53706-1572 > > 608 772 0914 <(608)%20772-0914> > > http://sbel.wisc.edu/ > > http://projectchrono.org/ > > --------------------------------------------- > > > > *From:* [email protected] <[email protected]> *On > Behalf Of *Bean Young > *Sent:* Tuesday, August 8, 2023 8:45 PM > *To:* ProjectChrono <[email protected]> > *Subject:* [chrono] Re: why can't the vehicle in demo_VEH_WheeledJSON > move? > > > > Hello! > > > > Yes, you are absolutely right! > > After I held down the W key for 2 seconds (in simulation time), I could > see the vehicle get moving at 5.15 m/s: > > > > [image: Image removed by sender. Image removed by sender.] > > > But 2 seconds of simulation time takes too long in real-world, and how can > I make demo_VEH_WheeledJSON run in real time mode? > > Thankds for help! > > 在2023年8月8日星期二 UTC+8 20:45:28<[email protected]> 写道: > > Hello! > > Can you please try pressing the throttle for longer and seeing if the > vehicle still does not move? It is normal that there is a lag between the > application of the throttle and the movement of the vehicle. This can be > due to two reasons > > 1) The torque converter slips (seen as Tconv slip). In the screenshot you > can also see the T conv out RPM is only 10 and so it is expected that the > vehicle does not move forward. This is similar to a vehicle in real life, > even if you slam the throttle there will be a finite lag before the vehicle > starts moving. > > 2) This lag might seem longer than usual because your simulation might not > be running at Real Time. This means that even though you feel that you have > been pressing the keyboard key for a long time, in simulation time, it is > too low (and still within the lag period). From my experience, pressing the > key for about 1 second simulation time is enough to get the vehicle moving. > > If you still face issues after pressing the key for longer, then there > might be some problem and we can try looking at it together :) > > > > Best > > Huzaifa > > > > On Tuesday, August 8, 2023 at 4:46:03 AM UTC-5 [email protected] wrote: > > I have built Chrono 7.0.3 and 8.0.0 in Ubuntu 18.04, when I > ran demo_VEH_WheeledJSON, I pressed A key on the keybord, I could see the > throttle was increasing, but the vehicle was not moving and the speed was > no change, the screenshot is as follows: > > > [image: Image removed by sender. Image removed by sender.] > > Can someone help me explain this problem? > > -- > You received this message because you are subscribed to the Google Groups > "ProjectChrono" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/projectchrono/dccb3b76-e564-4a58-9772-316a97cb5c74n%40googlegroups.com > > <https://groups.google.com/d/msgid/projectchrono/dccb3b76-e564-4a58-9772-316a97cb5c74n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > You received this message because you are subscribed to the Google Groups > "ProjectChrono" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/projectchrono/14f18ff1-90f8-401d-a861-2f1a802136cbn%40googlegroups.com > > <https://groups.google.com/d/msgid/projectchrono/14f18ff1-90f8-401d-a861-2f1a802136cbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > You received this message because you are subscribed to the Google Groups > "ProjectChrono" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/projectchrono/04455699-eb82-4c4b-a438-06d84fcb9e99n%40googlegroups.com > > <https://groups.google.com/d/msgid/projectchrono/04455699-eb82-4c4b-a438-06d84fcb9e99n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "ProjectChrono" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/228e7783-56a1-48ec-ac12-a21d21bd6500n%40googlegroups.com.
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Main driver function for a vehicle specified through JSON files. // // The vehicle reference frame has Z up, X towards the front of the vehicle, and // Y pointing to the left. // // ============================================================================= #include "chrono/solver/ChIterativeSolverLS.h" #include "chrono_vehicle/ChConfigVehicle.h" #include "chrono_vehicle/ChVehicleModelData.h" #include "chrono_vehicle/terrain/RigidTerrain.h" #include "chrono_vehicle/utils/ChUtilsJSON.h" #include "chrono_vehicle/wheeled_vehicle/vehicle/WheeledVehicle.h" #include "chrono_vehicle/wheeled_vehicle/vehicle/WheeledTrailer.h" #include "chrono_thirdparty/filesystem/path.h" using namespace chrono; using namespace chrono::vehicle; // ============================================================================= // Specification of a vehicle model from JSON files // Available models: // HMMWV - High Mobility Multipurpose Wheeled Vehicle // Sedan - Generic sedan vehicle // Audi - Audia A4 // VW microbus - VW T2 microbus // UAZ - UAZ minibus // CityBus - passenger bus // MAN - MAN 10t truck // MTV - MTV truck // ACV - articulated chassis vehicle (skid steer) class Vehicle_Model { public: virtual std::string ModelName() const = 0; virtual std::string VehicleJSON() const = 0; virtual std::string TireJSON() const = 0; virtual std::string EngineJSON() const = 0; virtual std::string TransmissionJSON() const = 0; virtual double CameraDistance() const = 0; virtual ChContactMethod ContactMethod() const = 0; }; class HMMWV_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "HMMWV"; } virtual std::string VehicleJSON() const override { return "hmmwv/vehicle/HMMWV_Vehicle.json"; ////return "hmmwv/vehicle/HMMWV_Vehicle_replica.json"; ////return "hmmwv/vehicle/HMMWV_Vehicle_mapShock.json"; ////return "hmmwv/vehicle/HMMWV_Vehicle_bushings.json"; ////return "hmmwv/vehicle/HMMWV_Vehicle_4WD.json"; } virtual std::string TireJSON() const override { ////return "hmmwv/tire/HMMWV_RigidTire.json"; ////return "hmmwv/tire/HMMWV_FialaTire.json"; return "hmmwv/tire/HMMWV_TMeasyTire.json"; ////return "hmmwv/tire/HMMWV_TMsimpleTire.json"; ////return "hmmwv/tire/HMMWV_Pac89Tire.json"; ////return "hmmwv/tire/HMMWV_Pac02Tire.json"; } virtual std::string EngineJSON() const override { return "hmmwv/powertrain/HMMWV_EngineShafts.json"; ////return "hmmwv/powertrain/HMMWV_EngineSimpleMap.json"; ////return "hmmwv/powertrain/HMMWV_EngineSimple.json"; } virtual std::string TransmissionJSON() const override { return "hmmwv/powertrain/HMMWV_AutomaticTransmissionShafts.json"; ////return "hmmwv/powertrain/HMMWV_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 6.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class Sedan_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "Sedan"; } virtual std::string VehicleJSON() const override { return "sedan/vehicle/Sedan_Vehicle.json"; } virtual std::string TireJSON() const override { ////return "sedan/tire/Sedan_RigidTire.json"; ////return "sedan/tire/Sedan_TMeasyTire.json"; return "sedan/tire/Sedan_Pac02Tire.json"; } virtual std::string EngineJSON() const override { ////return "sedan/powertrain/Sedan_EngineSimpleMap.json"; return "sedan/powertrain/Sedan_EngineShafts.json"; } virtual std::string TransmissionJSON() const override { ////return "sedan/powertrain/Sedan_AutomaticTransmissionSimpleMap.json"; return "sedan/powertrain/Sedan_ManualTransmissionShafts.json"; } virtual double CameraDistance() const override { return 6.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class Audi_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "Audi"; } virtual std::string VehicleJSON() const override { return "audi/json/audi_Vehicle.json"; } virtual std::string TireJSON() const override { ////return "audi/json/audi_TMeasyTire.json"; return "audi/json/audi_Pac02Tire.json"; ////return "audi/json/audi_RigidTire.json.json"; } virtual std::string EngineJSON() const override { return "audi/json/audi_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "audi/json/audi_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 6.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class Polaris_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "Polaris"; } virtual std::string VehicleJSON() const override { return "Polaris/Polaris.json"; } virtual std::string TireJSON() const override { return "Polaris/Polaris_TMeasyTire.json"; ////return "Polaris/Polaris_Pac02Tire.json"; } virtual std::string EngineJSON() const override { return "Polaris/Polaris_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "Polaris/Polaris_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 6.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class UAZ_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "UAZ"; } virtual std::string VehicleJSON() const override { ////return "uaz/vehicle/UAZBUS_Vehicle.json"; ////return "uaz/vehicle/UAZ469_Vehicle.json"; ////return "uaz/vehicle/UAZBUS_VehicleT.json"; return "uaz/vehicle/UAZBUS_SAEVehicle.json"; } virtual std::string TireJSON() const override { ////return "uaz/tire/UAZBUS_TMeasyTireFront.json"; return "uaz/tire/UAZBUS_Pac02Tire.json"; } virtual std::string EngineJSON() const override { return "uaz/powertrain/UAZBUS_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "uaz/powertrain/UAZBUS_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 6.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class VW_Microbus_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "VW_Microbus"; } virtual std::string VehicleJSON() const override { return "VW_microbus/json/van_Vehicle.json"; } virtual std::string TireJSON() const override { ///return "VW_microbus/json/van_TMsimpleTireFull.json"; ///return "VW_microbus/json/van_TMsimpleTire.json"; ///return "VW_microbus/json/van_TMeasyTireFull.json"; ///return "VW_microbus/json/van_TMeasyTire.json"; return "VW_microbus/json/van_Pac02Tire_extTIR.json"; ////return "VW_microbus/json/van_Pac02Tire.json"; } virtual std::string EngineJSON() const override { return "VW_microbus/json/van_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "VW_microbus/json/van_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 7.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class CityBus_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "CityBus"; } virtual std::string VehicleJSON() const override { return "citybus/vehicle/CityBus_Vehicle.json"; } virtual std::string TireJSON() const override { ////return "citybus/tire/CityBus_RigidTire.json"; ////return "citybus/tire/CityBus_TMeasyTire.json"; return "citybus/tire/CityBus_Pac02Tire.json"; } virtual std::string EngineJSON() const override { return "citybus/powertrain/CityBus_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "citybus/powertrain/CityBus_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 14.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class MAN_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "MAN"; } virtual std::string VehicleJSON() const override { ////return "MAN_Kat1/vehicle/MAN_5t_Vehicle_4WD.json"; ////return "MAN_Kat1/vehicle/MAN_7t_Vehicle_6WD.json"; return "MAN_Kat1/vehicle/MAN_10t_Vehicle_8WD.json"; } virtual std::string TireJSON() const override { return "MAN_Kat1/tire/MAN_5t_TMeasyTire.json"; } virtual std::string EngineJSON() const override { return "MAN_Kat1/powertrain/MAN_7t_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "MAN_Kat1/powertrain/MAN_7t_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 15.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class MTV_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "MTV"; } virtual std::string VehicleJSON() const override { return "mtv/vehicle/MTV_Vehicle_WalkingBeam.json"; } virtual std::string TireJSON() const override { return "mtv/tire/FMTV_TMeasyTire.json"; } virtual std::string EngineJSON() const override { return "mtv/powertrain/FMTV_EngineShafts.json"; } virtual std::string TransmissionJSON() const override { return "mtv/powertrain/FMTV_AutomaticTransmissionShafts.json"; } virtual double CameraDistance() const override { return 10.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::SMC; } }; class ACV_Model : public Vehicle_Model { public: virtual std::string ModelName() const override { return "ACV"; } virtual std::string VehicleJSON() const override { return "articulated_chassis/ACV_Vehicle.json"; } virtual std::string TireJSON() const override { return "articulated_chassis/ACV_RigidTire.json"; } virtual std::string EngineJSON() const override { return "articulated_chassis/ACV_EngineSimpleMap.json"; } virtual std::string TransmissionJSON() const override { return "articulated_chassis/ACV_AutomaticTransmissionSimpleMap.json"; } virtual double CameraDistance() const override { return 6.0; } virtual ChContactMethod ContactMethod() const override { return ChContactMethod::NSC; } }; // ============================================================================= // Specification of a trailer model from JSON files // Available models: // Ultra_Tow 40in x 48 in class Trailer_Model { public: virtual std::string ModelName() const = 0; virtual std::string TrailerJSON() const = 0; virtual std::string TireJSON() const = 0; }; class UT_Model : public Trailer_Model { public: virtual std::string ModelName() const override { return "Ultra-Tow"; } virtual std::string TrailerJSON() const override { return "ultra_tow/UT_Trailer.json"; } virtual std::string TireJSON() const override { ////return "ultra_tow/UT_RigidTire.json"; return "ultra_tow/UT_TMeasyTire.json"; } }; // ============================================================================= // Current vehicle model selection // auto vehicle_model = HMMWV_Model(); // auto vehicle_model = Sedan_Model(); auto vehicle_model = Audi_Model(); // auto vehicle_model = Polaris_Model(); // auto vehicle_model = VW_Microbus_Model(); // auto vehicle_model = UAZ_Model(); // auto vehicle_model = CityBus_Model(); // auto vehicle_model = MAN_Model(); // auto vehicle_model = MTV_Model(); // auto vehicle_model = ACV_Model(); // JSON files for terrain std::string rigidterrain_file("terrain/RigidPlane.json"); ////std::string rigidterrain_file("terrain/RigidMesh.json"); ////std::string rigidterrain_file("terrain/RigidHeightMap.json"); ////std::string rigidterrain_file("terrain/RigidSlope10.json"); ////std::string rigidterrain_file("terrain/RigidSlope20.json"); // Initial vehicle position and orientation ChVector<> initLoc(0, 0, 0.5); double initYaw = 20 * CH_C_DEG_TO_RAD; // Simulation step size double step_size = 2e-3; // Output directory const std::string out_dir = GetChronoOutputPath() + "WHEELED_JSON"; // ============================================================================= int main(int argc, char* argv[]) { GetLog() << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n"; // Create the vehicle system WheeledVehicle vehicle(vehicle::GetDataFile(vehicle_model.VehicleJSON()), vehicle_model.ContactMethod()); vehicle.Initialize(ChCoordsys<>(initLoc, Q_from_AngZ(initYaw))); vehicle.GetChassis()->SetFixed(false); vehicle.SetChassisVisualizationType(VisualizationType::MESH); vehicle.SetChassisRearVisualizationType(VisualizationType::PRIMITIVES); vehicle.SetSuspensionVisualizationType(VisualizationType::PRIMITIVES); vehicle.SetSteeringVisualizationType(VisualizationType::PRIMITIVES); vehicle.SetWheelVisualizationType(VisualizationType::MESH); // Create and initialize the powertrain system auto engine = ReadEngineJSON(vehicle::GetDataFile(vehicle_model.EngineJSON())); auto transmission = ReadTransmissionJSON(vehicle::GetDataFile(vehicle_model.TransmissionJSON())); auto powertrain = chrono_types::make_shared<ChPowertrainAssembly>(engine, transmission); vehicle.InitializePowertrain(powertrain); // Create and initialize the tires for (auto& axle : vehicle.GetAxles()) { for (auto& wheel : axle->GetWheels()) { auto tire = ReadTireJSON(vehicle::GetDataFile(vehicle_model.TireJSON())); vehicle.InitializeTire(tire, wheel, VisualizationType::MESH); } } // Containing system auto system = vehicle.GetSystem(); // Create the terrain RigidTerrain terrain(system, vehicle::GetDataFile(rigidterrain_file)); terrain.Initialize(); // Initialize output directories std::string veh_dir = out_dir + "/" + vehicle_model.ModelName(); if (!filesystem::create_directory(filesystem::path(out_dir))) { std::cout << "Error creating directory " << out_dir << std::endl; return 1; } if (!filesystem::create_directory(filesystem::path(veh_dir))) { std::cout << "Error creating directory " << veh_dir << std::endl; return 1; } // Generate JSON information with available output channels std::string out_json = vehicle.ExportComponentList(); std::cout << out_json << std::endl; vehicle.ExportComponentList(veh_dir + "/component_list.json"); vehicle.LogSubsystemTypes(); // Modify solver settings if the vehicle model contains bushings if (vehicle.HasBushings()) { auto solver = chrono_types::make_shared<ChSolverMINRES>(); system->SetSolver(solver); solver->SetMaxIterations(150); solver->SetTolerance(1e-10); solver->EnableDiagonalPreconditioner(true); solver->EnableWarmStart(true); // IMPORTANT for convergence when using EULER_IMPLICIT_LINEARIZED solver->SetVerbose(false); step_size = 2e-4; system->SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); } // Simulation loop vehicle.EnableRealtime(true); while (true) { // Get driver inputs DriverInputs driver_inputs = DriverInputs{0, 1, 0, 0}; // Update modules (process inputs from other modules) double time = vehicle.GetSystem()->GetChTime(); vehicle.Synchronize(time, driver_inputs, terrain); terrain.Synchronize(time); std::cout << "======================================" << std::endl; std::cout << "Speed: " << vehicle.GetSpeed() << "m/s" << std::endl; std::cout << "Time: " << time << "s" << std::endl; std::cout << "RTF: " << vehicle.GetRTF() << std::endl; // Advance simulation for one timestep for all modules vehicle.Advance(step_size); terrain.Advance(step_size); } return 0; }
