GithubHelp home page GithubHelp logo

Comments (4)

rserban avatar rserban commented on May 27, 2024

One can define collision shapes for the vehicle chassis and enable collision for it (disabled by default). However, none of the sample vehicles and demos in Chrono illustrate that, so I'll look into adding an example.

from chrono.

yankaizhang20 avatar yankaizhang20 commented on May 27, 2024

Thanks for your help! I have the same idea with you and did a simple test based on "demo_VEH_Sedan.cpp". There are three differences in code and they are:

  1. define a box collision shape for the sedan chassis
  // change.1 : add chassis collision shape
    auto chassis_mat = chrono_types::make_shared<chrono::ChMaterialSurfaceNSC>();
    my_sedan.GetChassis()->GetBody()->GetCollisionModel()->ClearModel();
    my_sedan.GetChassis()->GetBody()->GetCollisionModel()->AddBox(chassis_mat, 2, 2, 2, ChVector<>(0.0, 0.0, 0.0));
    my_sedan.GetChassis()->GetBody()->SetCollide(true);
  1. add an obstacle with an easy box collision shape for testing the collision with sedan
// change3 :add box obstacle with collision shape
    auto ground_mat = chrono_types::make_shared<chrono::ChMaterialSurfaceNSC>();
    ground_mat->SetFriction(1.0f);
    auto obstacle = chrono_types::make_shared<chrono::ChBodyEasyBox>(5, 10, 1, 1000, true, true, ground_mat);
    my_sedan.GetSystem()->Add(obstacle);
    obstacle->SetBodyFixed(true);
    obstacle->SetPos(chrono::ChVector<>(-10, 0, 0));
    obstacle->GetVisualShape(0)->SetTexture(chrono::GetChronoDataFile("textures/concrete.jpg"));
    obstacle->SetCollide(true);
  1. add some particles same as in "demo_IRR_assets.cpp" for testing the physics behavior of "Terrain"
// change2 : add particle same as in demo_IRR_assets.cpp
    auto particles    = chrono_types::make_shared<ChParticleCloud>();
    auto particle_mat = chrono_types::make_shared<ChMaterialSurfaceNSC>();
    particles->GetCollisionModel()->ClearModel();
    particles->GetCollisionModel()->AddSphere(particle_mat, 0.05);
    particles->GetCollisionModel()->BuildModel();
    particles->SetCollide(true);

    // Create the random particles
    for (int np = 0; np < 100; ++np)
        particles->AddParticle(ChCoordsys<>(ChVector<>(ChRandom() - 2, ChRandom() + 2, 3)));

    // Mass and inertia properties.
    // This will be shared among all particles in the ChParticleCloud.
    particles->SetMass(0.1);
    particles->SetInertiaXX(ChVector<>(0.001, 0.001, 0.001));

    // Do not forget to add the particle cluster to the system:
    my_sedan.GetSystem()->Add(particles);

    //  ==Asset== Attach a 'sphere' shape asset.. it will be used as a sample
    // shape to display all particles when rendering in 3D!
    auto sphereparticle                     = chrono_types::make_shared<ChSphereShape>();
    sphereparticle->GetSphereGeometry().rad = 0.05;
    particles->AddVisualShape(sphereparticle);

there are two conclusions:

  • it can't take collision check by add collision shape for chassis in my way, as the following picture showing.
  • the particles just go through the terrain and have not collision behavior as the MBS demo.
    image

Are there some errors when i add collision shape for Sedan chassis? Why the particles can’t collision with terrain and how to do it?

from chrono.

rserban avatar rserban commented on May 27, 2024
  1. You did not invoke BuildModel() on the collision model you added to the Sedan chassis. Note that there is a more formal way of adding collision geometry to a vehicle chassis (see below)
  2. You created the particle cloud with an "NSC" contact material, while the system you place it in is of type "SMC" (the two contact formulations cannot be mixed).

I just pushed a demo that illustrates the use of collision geometry on a vehicle chassis. See demo_VEH_HMMWV_Rollover. Look also at the implementation of HMMWV_Chassis; I used a collision shape given as a convex hull (from a simplified mesh), but you could define a collision model composed of primitives (that requires a bit of extra work to properly match the collision model with the visual model)

from chrono.

yankaizhang20 avatar yankaizhang20 commented on May 27, 2024

Got it. Thanks so much!

from chrono.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.