Hi, I am modelling a MAN5T truck going over a deformable terrain. I started with the example script provided (demo_VEH_HMMWV_DefSoil.cpp). In the example script I just changed the vehicle to MAN5t. I was able to build and run the project successfully. but the vehicle keeps falling down below the terrain infinitely instead of going over the terrain. I reckon this is mainly because of the vehicle weight which is around 9 tons. when I referred the other example script(demo_VEH_M113_DefSoil.cpp), the M113 vehicle mass is seems t to be zero as I noticed this from the output panel while running the exe.
So, Is there a way to set MAN5t truck mass? or How this problem could be resolved? I tried changing the terrain parameters as well. Doesn't help. Thanks, Prabanjan -- 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/a7b9eb66-2f2f-4ef8-91b3-d72ddaa84f98n%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. // // ============================================================================= // Author: Radu Serban // ============================================================================= // // Chrono::Vehicle + Chrono::Multicore demo program for simulating a HMMWV vehicle // over rigid or granular material. // // Contact uses the SMC (penalty) formulation. // // The global reference frame has Z up. // All units SI. // ============================================================================= #include <cstdio> #include <cmath> #include <vector> #include "chrono/utils/ChUtilsInputOutput.h" #include "chrono_vehicle/ChVehicleModelData.h" #include "chrono_vehicle/ChDriver.h" #include "chrono_vehicle/driver/ChDataDriver.h" #include "chrono_vehicle/driver/ChIrrGuiDriver.h" #include "chrono_vehicle/terrain/SCMDeformableTerrain.h" #include "chrono_vehicle/terrain/RigidTerrain.h" #include "chrono_vehicle/wheeled_vehicle/utils/ChWheeledVehicleVisualSystemIrrlicht.h" #include "chrono_models/vehicle/man/MAN_5t.h" //include "chrono_models/vehicle/hmmwv/HMMWV.h" //#include "chrono_models/vehicle/sedan/Sedan.h" #include "chrono_thirdparty/filesystem/path.h" using namespace chrono; using namespace chrono::collision; using namespace chrono::irrlicht; using namespace chrono::vehicle; using namespace chrono::vehicle::man; //using namespace chrono::vehicle::sedan; //using namespace chrono::vehicle::hmmwv; using std::cout; using std::endl; // ============================================================================= // USER SETTINGS // ============================================================================= // ----------------------------------------------------------------------------- // Terrain parameters // ----------------------------------------------------------------------------- double terrainLength = 16.0; // size in X direction double terrainWidth = 8.0; // size in Y direction double delta = 0.05; // SCM grid spacing // ----------------------------------------------------------------------------- // Vehicle parameters // ----------------------------------------------------------------------------- // Type of tire (controls both contact and visualization) enum class TireType { CYLINDRICAL, LUGGED }; TireType tire_type = TireType::LUGGED; // Tire contact material properties float Y_t = 1.0e6f; float cr_t = 0.1f; float mu_t = 0.8f; // Initial vehicle location and orientation ChVector<> initLoc(0, 0, 1.7); ChQuaternion<> initRot(1, 0, 0, 0); enum DriverMode { DEFAULT, RECORD, PLAYBACK }; DriverMode driver_mode = DEFAULT; // ----------------------------------------------------------------------------- // Simulation parameters // ----------------------------------------------------------------------------- // Simulation step size double step_size = 3e-4; // Time interval between two render frames (1/FPS) double render_step_size = 1.0 / 100; // Point on chassis tracked by the camera ChVector<> trackPoint(0.0, 0.0, 1.75); // Output directories const std::string out_dir = GetChronoOutputPath() + "HMMWV_DEF_SOIL"; const std::string img_dir = out_dir + "/IMG"; // Visualization output bool img_output = false; // ============================================================================= class MyDriver : public ChDriver { public: MyDriver(ChVehicle& vehicle, double delay) : ChDriver(vehicle), m_delay(delay) {} ~MyDriver() {} virtual void Synchronize(double time) override { m_throttle = 0; m_steering = 0; m_braking = 0; double eff_time = time - m_delay; // Do not generate any driver inputs for a duration equal to m_delay. if (eff_time < 0) return; if (eff_time > 0.2) m_throttle = 0.7; else m_throttle = 3.5 * eff_time; if (eff_time < 2) m_steering = 0; else m_steering = 0.6 * std::sin(CH_C_2PI * (eff_time - 2) / 6); } private: double m_delay; }; // ============================================================================= void CreateLuggedGeometry(std::shared_ptr<ChBody> wheel_body, std::shared_ptr<ChMaterialSurfaceSMC> wheel_material) { std::string lugged_file("hmmwv/lugged_wheel_section.obj"); geometry::ChTriangleMeshConnected lugged_mesh; ChConvexDecompositionHACDv2 lugged_convex; utils::LoadConvexMesh(vehicle::GetDataFile(lugged_file), lugged_mesh, lugged_convex); int num_hulls = lugged_convex.GetHullCount(); auto coll_model = wheel_body->GetCollisionModel(); coll_model->ClearModel(); // Assemble the tire contact from 15 segments, properly offset. // Each segment is further decomposed in convex hulls. for (int iseg = 0; iseg < 15; iseg++) { ChQuaternion<> rot = Q_from_AngAxis(iseg * 24 * CH_C_DEG_TO_RAD, VECT_Y); for (int ihull = 0; ihull < num_hulls; ihull++) { std::vector<ChVector<> > convexhull; lugged_convex.GetConvexHullResult(ihull, convexhull); coll_model->AddConvexHull(wheel_material, convexhull, VNULL, rot); } } // Add a cylinder to represent the wheel hub. coll_model->AddCylinder(wheel_material, 0.223, 0.223, 0.126); coll_model->BuildModel(); // Visualization auto trimesh = geometry::ChTriangleMeshConnected::CreateFromWavefrontFile( vehicle::GetDataFile("hmmwv/lugged_wheel.obj"), false, false); auto trimesh_shape = chrono_types::make_shared<ChTriangleMeshShape>(); trimesh_shape->SetMesh(trimesh); trimesh_shape->SetMutable(false); trimesh_shape->SetName("lugged_wheel"); trimesh_shape->SetColor(ChColor(0.3f, 0.3f, 0.3f)); wheel_body->AddVisualShape(trimesh_shape); } // ============================================================================= int main(int argc, char* argv[]) { GetLog() << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n"; // -------------------- // Create HMMWV vehicle // -------------------- //Sedan my_truck; MAN_5t my_truck; my_truck.SetContactMethod(ChContactMethod::SMC); my_truck.SetChassisFixed(false); my_truck.SetInitPosition(ChCoordsys<>(initLoc, initRot)); //my_truck.SetPowertrainType(PowertrainModelType::SHAFTS); //my_truck.SetDriveType(DrivelineTypeWV::AWD); switch (tire_type) { case TireType::CYLINDRICAL: my_truck.SetTireType(TireModelType::RIGID_MESH); break; case TireType::LUGGED: my_truck.SetTireType(TireModelType::RIGID); break; } my_truck.Initialize(); my_truck.SetChassisVisualizationType(VisualizationType::NONE); // ----------------------------------------------------------- // Set tire contact material, contact model, and visualization // ----------------------------------------------------------- auto wheel_material = chrono_types::make_shared<ChMaterialSurfaceSMC>(); wheel_material->SetFriction(mu_t); wheel_material->SetYoungModulus(Y_t); wheel_material->SetRestitution(cr_t); switch (tire_type) { case TireType::CYLINDRICAL: my_truck.SetTireVisualizationType(VisualizationType::MESH); break; case TireType::LUGGED: my_truck.SetTireVisualizationType(VisualizationType::NONE); for (auto& axle : my_truck.GetVehicle().GetAxles()) { CreateLuggedGeometry(axle->m_wheels[0]->GetSpindle(), wheel_material); CreateLuggedGeometry(axle->m_wheels[1]->GetSpindle(), wheel_material); } } // -------------------- // Create driver system // -------------------- MyDriver driver(my_truck.GetVehicle(), 5); driver.Initialize(); // ------------------ // Create the terrain // ------------------ ChSystem* system = my_truck.GetSystem(); system->SetNumThreads(std::min(8, ChOMP::GetNumProcs())); SCMDeformableTerrain terrain(system); terrain.SetSoilParameters(2e7, // Bekker Kphi 0, // Bekker Kc 1.1, // Bekker n exponent 0, // Mohr cohesive limit (Pa) 20, // Mohr friction limit (degrees) 0.01, // Janosi shear coefficient (m) 2e8, // Elastic stiffness (Pa/m), before plastic yield 3e4 // Damping (Pa s/m), proportional to negative vertical speed (optional) ); ////terrain.EnableBulldozing(true); // inflate soil at the border of the rut ////terrain.SetBulldozingParameters(55, // angle of friction for erosion of displaced material at rut border //// 0.8, // displaced material vs downward pressed material. //// 5, // number of erosion refinements per timestep //// 10); // number of concentric vertex selections subject to erosion // Optionally, enable moving patch feature (single patch around vehicle chassis) terrain.AddMovingPatch(my_truck.GetChassisBody(), ChVector<>(0, 0, 0), ChVector<>(5, 3, 1)); // Optionally, enable moving patch feature (multiple patches around each wheel) ////for (auto& axle : my_truck.GetVehicle().GetAxles()) { //// terrain.AddMovingPatch(axle->m_wheels[0]->GetSpindle(), ChVector<>(0, 0, 0), ChVector<>(1, 0.5, 1)); //// terrain.AddMovingPatch(axle->m_wheels[1]->GetSpindle(), ChVector<>(0, 0, 0), ChVector<>(1, 0.5, 1)); ////} ////terrain.SetTexture(vehicle::GetDataFile("terrain/textures/grass.jpg"), 80, 16); ////terrain.SetPlotType(vehicle::SCMDeformableTerrain::PLOT_PRESSURE_YELD, 0, 30000.2); terrain.SetPlotType(vehicle::SCMDeformableTerrain::PLOT_SINKAGE, 0, 0.1); terrain.Initialize(terrainLength, terrainWidth, delta); // --------------------------------------- // Create the vehicle Irrlicht application // --------------------------------------- auto vis = chrono_types::make_shared<ChWheeledVehicleVisualSystemIrrlicht>(); vis->SetWindowTitle("HMMWV Deformable Soil Demo"); vis->SetChaseCamera(trackPoint, 6.0, 0.5); vis->Initialize(); vis->AddLightDirectional(); vis->AddSkyBox(); vis->AddLogo(); vis->AttachVehicle(&my_truck.GetVehicle()); // ------------------------ // Create the driver system // ------------------------ // Create the interactive driver system // ChIrrGuiDriver driver(*vis); // // Set the time response for steering and throttle keyboard inputs. // double steering_time = 1.0; // time to go from 0 to +1 (or from 0 to -1) // double throttle_time = 0.4; // time to go from 0 to +1 // double braking_time = 0.3; // time to go from 0 to +1 // driver.SetSteeringDelta(render_step_size / steering_time); // driver.SetThrottleDelta(render_step_size / throttle_time); // driver.SetBrakingDelta(render_step_size / braking_time); // driver.Initialize(); // ----------------- // Initialize output // ----------------- if (!filesystem::create_directory(filesystem::path(out_dir))) { std::cout << "Error creating directory " << out_dir << std::endl; return 1; } if (img_output) { if (!filesystem::create_directory(filesystem::path(img_dir))) { std::cout << "Error creating directory " << img_dir << std::endl; return 1; } } // --------------- // Simulation loop // --------------- std::cout << "Total vehicle mass: " << my_truck.GetVehicle().GetMass() << std::endl; // Solver settings. system->SetSolverMaxIterations(50); // Number of simulation steps between two 3D view render frames int render_steps = (int)std::ceil(render_step_size / step_size); // Initialize simulation frame counter int step_number = 0; int render_frame = 0; ChTimer<> timer; while (vis->Run()) { double time = system->GetChTime(); if (step_number == 800) { std::cout << "\nstart timer at t = " << time << std::endl; timer.start(); } if (step_number == 1400) { timer.stop(); std::cout << "stop timer at t = " << time << std::endl; std::cout << "elapsed: " << timer() << std::endl; std::cout << "\nSCM stats for last step:" << std::endl; terrain.PrintStepStatistics(std::cout); } // Render scene vis->BeginScene(); vis->Render(); tools::drawColorbar(vis.get(), 0, 0.1, "Sinkage", 30, 200); vis->EndScene(); if (img_output && step_number % render_steps == 0) { char filename[100]; sprintf(filename, "%s/img_%03d.jpg", img_dir.c_str(), render_frame + 1); vis->WriteImageToFile(filename); render_frame++; } // Driver inputs DriverInputs driver_inputs = driver.GetInputs(); // Update modules driver.Synchronize(time); terrain.Synchronize(time); my_truck.Synchronize(time, driver_inputs, terrain); vis->Synchronize("", driver_inputs); // Advance dynamics system->DoStepDynamics(step_size); vis->Advance(step_size); // Increment frame number step_number++; } return 0; }
