Hello Radu and Dan:
Thank you for your reply。
The information for these questions is as follows:
my configuration: ubuntu 16.04, CPU i7-9700k, gcc --version: 5.5.0 , vscode
2022, use default solver, I both run the code On Release and Debug.
The problems I run the demo_VEH_Sedan.cpp( removed visualization code) are
follows:
1. the step size I set 2ms, while The my_sedan advance spend 100.29ms on
Release and Debug.
2. When I changed the step size to 20ms, the speed increased to nan
rapidly and the system crashed in a short time.
[image: 飞书20221028-131817.png]
The modified demo_VEH_Sendan.cpp is shown in the attached file.
在2022年10月28日星期五 UTC+8 07:52:39<Dan Negrut> 写道:
> Do you mean “Sedan”?
>
> Also, for that RTF, can you share the value of the integration time step,
> who built the solver, what hardware it was run on.
>
> If you mean Sedan, Chrono can run that relatively easily in real time, see
> for instance here:
> https://uwmadison.box.com/s/39107d2577slfg2c54j6xeu5z5va0zes.
>
> 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 *ji li
> *Sent:* Thursday, October 27, 2022 11:01 AM
> *To:* [email protected]
> *Subject:* [chrono] Speed up simulation update times
>
>
>
> Hello,
>
> Recently, when I was doing a Dedan simulation, I found that the value
> of RTF was too large, about 50.23 . I want to know that how to speed up the
> time of advance. In addition, I would like to know if this simulation step
> size can be modified? If the step size is 0.02 s, the system will crash.
>
> --
>
> 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/CAGrNw3cdf8siD8b8nf0m%2BEAdhfzwGfWXRfuAytaoV0m8-W813Q%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/projectchrono/CAGrNw3cdf8siD8b8nf0m%2BEAdhfzwGfWXRfuAytaoV0m8-W813Q%40mail.gmail.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/22bf1182-40cd-4fc8-b591-347e1df36730n%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, Asher Elmquist
// =============================================================================
//
// Main driver function for the Sedan full model.
//
// The vehicle reference frame has Z up, X towards the front of the vehicle, and
// Y pointing to the left.
//
// =============================================================================
#include "chrono/core/ChStream.h"
#include "chrono/utils/ChUtilsInputOutput.h"
#include "chrono/utils/ChFilters.h"
#include "chrono_vehicle/ChConfigVehicle.h"
#include "chrono_vehicle/ChVehicleModelData.h"
#include "chrono_vehicle/terrain/RigidTerrain.h"
#include "chrono_vehicle/driver/ChIrrGuiDriver.h"
#include "chrono_vehicle/driver/ChDataDriver.h"
#include
"chrono_vehicle/wheeled_vehicle/utils/ChWheeledVehicleVisualSystemIrrlicht.h"
#include "chrono_models/vehicle/sedan/Sedan.h"
#include "chrono_thirdparty/filesystem/path.h"
#include <chrono>
using namespace chrono;
using namespace chrono::irrlicht;
using namespace chrono::vehicle;
using namespace chrono::vehicle::sedan;
// =============================================================================
// Initial vehicle location and orientation
ChVector<> initLoc(0, 0, 1.0);
ChQuaternion<> initRot(1, 0, 0, 0);
enum DriverMode { DEFAULT, RECORD, PLAYBACK };
DriverMode driver_mode = DEFAULT;
// Visualization type for vehicle parts (PRIMITIVES, MESH, or NONE)
// VisualizationType chassis_vis_type = VisualizationType::MESH;
// VisualizationType suspension_vis_type = VisualizationType::PRIMITIVES;
// VisualizationType steering_vis_type = VisualizationType::PRIMITIVES;
// VisualizationType wheel_vis_type = VisualizationType::MESH;
// VisualizationType tire_vis_type = VisualizationType::MESH;
// Collision type for chassis (PRIMITIVES, MESH, or NONE)
CollisionType chassis_collision_type = CollisionType::NONE;
// Type of tire model (RIGID, TMEASY, PAC02)
TireModelType tire_model = TireModelType::TMEASY;
// Rigid terrain
RigidTerrain::PatchType terrain_model = RigidTerrain::PatchType::BOX;
double terrainHeight = 0; // terrain height (FLAT terrain only)
double terrainLength = 100.0; // size in X direction
double terrainWidth = 100.0; // size in Y direction
// Point on chassis tracked by the camera
ChVector<> trackPoint(0.0, 0.0, 1.75);
// Contact method
ChContactMethod contact_method = ChContactMethod::SMC;
// Simulation step sizes
double step_size = 2e-3;
double tire_step_size = 1e-3;
// Simulation end time
double t_end = 1000;
// Time interval between two render frames
double render_step_size = 1.0 / 50; // FPS = 50
// Output directories
const std::string out_dir = GetChronoOutputPath() + "Sedan";
const std::string pov_dir = out_dir + "/POVRAY";
// Debug logging
bool debug_output = false;
double debug_step_size = 1.0 / 1; // FPS = 1
// =============================================================================
int main(int argc, char* argv[]) {
GetLog() << "Copyright (c) 2017 projectchrono.org\nChrono version: " <<
CHRONO_VERSION << "\n\n";
// --------------
// Create systems
// --------------
// Create the Sedan vehicle, set parameters, and initialize
Sedan my_sedan;
my_sedan.SetContactMethod(contact_method);
my_sedan.SetChassisCollisionType(chassis_collision_type);
my_sedan.SetChassisFixed(false);
my_sedan.SetInitPosition(ChCoordsys<>(initLoc, initRot));
my_sedan.SetTireType(tire_model);
my_sedan.SetTireStepSize(tire_step_size);
my_sedan.Initialize();
// my_sedan.SetChassisVisualizationType(chassis_vis_type);
// my_sedan.SetSuspensionVisualizationType(suspension_vis_type);
// my_sedan.SetSteeringVisualizationType(steering_vis_type);
// my_sedan.SetWheelVisualizationType(wheel_vis_type);
// my_sedan.SetTireVisualizationType(tire_vis_type);
// Create the terrain
RigidTerrain terrain(my_sedan.GetSystem());
MaterialInfo minfo;
minfo.mu = 0.9f;
minfo.cr = 0.01f;
minfo.Y = 2e7f;
auto patch_mat = minfo.CreateMaterial(contact_method);
std::shared_ptr<RigidTerrain::Patch> patch;
switch (terrain_model) {
case RigidTerrain::PatchType::BOX:
patch = terrain.AddPatch(patch_mat, CSYSNORM, terrainLength,
terrainWidth);
patch->SetTexture(vehicle::GetDataFile("terrain/textures/tile4.jpg"), 200, 200);
break;
case RigidTerrain::PatchType::HEIGHT_MAP:
patch = terrain.AddPatch(patch_mat, CSYSNORM,
vehicle::GetDataFile("terrain/height_maps/test64.bmp"),
128, 128, 0, 4);
patch->SetTexture(vehicle::GetDataFile("terrain/textures/grass.jpg"), 16, 16);
break;
case RigidTerrain::PatchType::MESH:
patch = terrain.AddPatch(patch_mat, CSYSNORM,
vehicle::GetDataFile("terrain/meshes/test.obj"));
patch->SetTexture(vehicle::GetDataFile("terrain/textures/grass.jpg"), 100, 100);
break;
}
patch->SetColor(ChColor(0.8f, 0.8f, 0.5f));
terrain.Initialize();
// Create the vehicle Irrlicht interface
auto vis =
chrono_types::make_shared<ChWheeledVehicleVisualSystemIrrlicht>();
vis->SetWindowTitle("Sedan Demo");
vis->SetChaseCamera(trackPoint, 6.0, 0.5);
vis->Initialize();
vis->AddLightDirectional();
vis->AddSkyBox();
vis->AddLogo();
vis->AttachVehicle(&my_sedan.GetVehicle());
// -----------------
// Initialize output
// -----------------
if (!filesystem::create_directory(filesystem::path(out_dir))) {
std::cout << "Error creating directory " << out_dir << std::endl;
return 1;
}
std::string driver_file = out_dir + "/driver_inputs.txt";
utils::CSV_writer driver_csv(" ");
// ---------------
// Simulation loop
// ---------------
my_sedan.GetVehicle().LogSubsystemTypes();
std::cout << "\nVehicle mass: " << my_sedan.GetVehicle().GetMass() <<
std::endl;
// Initialize simulation frame counters
int step_number = 0;
DriverInputs driver_inputs;
driver_inputs.m_braking = 0.0;
driver_inputs.m_steering = 0.0;
driver_inputs.m_throttle = 0.1;
my_sedan.GetVehicle().EnableRealtime(true);
utils::ChRunningAverage RTF_filter(2);
ChRealtimeStepTimer realtime_timer;
while (1) {
double time = my_sedan.GetSystem()->GetChTime();
// Update modules (process inputs from other modules)
terrain.Synchronize(time);
my_sedan.Synchronize(time, driver_inputs, terrain);
// Advance simulation for one timestep for all modules
terrain.Advance(step_size);
auto tp1 = std::chrono::steady_clock::now();
my_sedan.Advance(step_size);
auto tp2 = std::chrono::steady_clock::now();
ChVector<> r_t = my_sedan.GetChassis()->GetPos() ;
realtime_timer.Spin(step_size);
std::cout << "speed: " << my_sedan.GetChassis()->GetSpeed() <<
std::endl;
std::cout << "R_t: " << r_t.x() << " " << r_t.y() << " " << r_t.z() <<
std::endl;
std::cout << "cost time: " <<
std::chrono::duration_cast<std::chrono::microseconds>(tp2 - tp1).count() /
1000.0 << " ms " << std::endl;
// std::cout << "RTF: " << realtime_timer.RTF <<std::endl;
}
return 0;
}