Wheel collision with vertical walls

Hi everybody

I have a problem about the wheel collision with vertical wall. I try to simulate a robot in its environment.
When a wheel hit a wall, instead of detecting collision, the wheel go through the wall until the robot body hits the wall.
At this very moment there is a collision, but it is too late for my simulation because I need my wheel having adherence
with the vertical wall.

Here is a picture of my problem:

The wall is composed by a MeshCollisionShape created with this code
[java]Mesh vertex = new Mesh();
vertex.setBuffer(Type.Position, 3, gVertices);
vertex.setBuffer(Type.Index, 3, gIndices);
vertex.updateBound();
indexVertexArrays = new MeshCollisionShape(vertex);

    Geometry geomVertex = new Geometry("environment", vertex);
    Material m1 = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");


    geomVertex.setMaterial(m1);

    rootNode.attachChild(geomVertex);
    staticBody = new RigidBodyControl(indexVertexArrays, 0);

    bullet.getPhysicsSpace().add(staticBody);  [/java]

And the robot is created by that code

   [java]//Setting up material composing the robot
    Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    mat.setColor("Color", ColorRGBA.Red);

    
    //Setting up robot body
    CompoundCollisionShape compoundShape = new CompoundCollisionShape();
    BoxCollisionShape box = new BoxCollisionShape(new Vector3f(.24f, .12f, .05f));
    compoundShape.addChildShape(box, new Vector3f(0, 0, 0));

    Box vehicleBody = new Box(.24f, .12f, .05f);
    Geometry geomVehicle = new Geometry("corps voiture", vehicleBody);
    geomVehicle.setMaterial(mat);

    //create vehicle node
    Node vehicleNode = new Node("vehicleNode");
    vehicle = new VehicleControl(compoundShape, 400);
    vehicleNode.addControl(vehicle);
    vehicleNode.attachChild(geomVehicle);

    //setting suspension values for wheels, this can be a bit tricky
    //see also https://docs.google.com/Doc?docid=0AXVUZ5xw6XpKZGNuZG56a3FfMzU0Z2NyZnF4Zmo&hl=en
    float stiffness = 60.0f;//200=f1 car
    float compValue = .3f; //(should be lower than damp)
    float dampValue = .4f;
    vehicle.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
    vehicle.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
    vehicle.setSuspensionStiffness(stiffness);
    vehicle.setMaxSuspensionForce(10000.0f);

    //Create four wheels and add them at their locations
    Vector3f wheelDirection = new Vector3f(0, 0, -1); // was 0, -1, 0
    Vector3f wheelAxle = new Vector3f(0, 1, 0); // was -1, 0, 0
    float radius = 0.05f;
    float restLength = 0.03f;
    float zOff = 0.04f;
    float yOff = .1f;
    float xOff = .25f;

    //Structure for wheels
    Cylinder wheelMesh = new Cylinder(16, 16, radius, radius * 0.6f, true);

    //Creating and attaching each wheel to the robot body
    Node node1 = new Node("wheel 1 node");
    Geometry wheels1 = new Geometry("wheel 1", wheelMesh);
    node1.attachChild(wheels1);
    wheels1.rotate(0, FastMath.HALF_PI, 0);
    wheels1.setMaterial(mat);
    vehicle.addWheel(node1, new Vector3f(xOff, yOff, -zOff),
            wheelDirection, wheelAxle, restLength, radius, true);

    Node node2 = new Node("wheel 2 node");
    Geometry wheels2 = new Geometry("wheel 2", wheelMesh);
    node2.attachChild(wheels2);
    wheels2.rotate(0, FastMath.HALF_PI, 0);
    wheels2.setMaterial(mat);
    vehicle.addWheel(node2, new Vector3f(xOff, -yOff, -zOff),
            wheelDirection, wheelAxle, restLength, radius, true);

    Node node3 = new Node("wheel 3 node");
    Geometry wheels3 = new Geometry("wheel 3", wheelMesh);
    node3.attachChild(wheels3);
    wheels3.rotate(0, FastMath.HALF_PI, 0);
    wheels3.setMaterial(mat);
    vehicle.addWheel(node3, new Vector3f(-xOff, yOff, -zOff),
            wheelDirection, wheelAxle, restLength, radius, false);

    Node node4 = new Node("wheel 4 node");
    Geometry wheels4 = new Geometry("wheel 4", wheelMesh);
    node4.attachChild(wheels4);
    wheels4.rotate(0, FastMath.HALF_PI, 0);
    wheels4.setMaterial(mat);
    vehicle.addWheel(node4, new Vector3f(-xOff, -yOff, -zOff),
            wheelDirection, wheelAxle, restLength, radius, false);

    vehicleNode.attachChild(node1);
    vehicleNode.attachChild(node2);
    vehicleNode.attachChild(node3);
    vehicleNode.attachChild(node4);
    vehicleNode.setMaterial(mat);
    rootNode.attachChild(vehicleNode);
    //Adding vehicle in the simulation space
    bullet.getPhysicsSpace().add(vehicle);
    vehicle.setDamping(0.95f, 0.95f);
    vehicle.setPhysicsLocation(new Vector3f(5f, 5f, 50f)); [/java]

`

So is there is something obvious that I missed or anything else that could help me?
Thank’s for reading this and maybe give help :wink: .
and… sorry for my poor english … -_-

The wheel is not a wheel but a ray, as the name of the vehicle indicates. Use a hinge joint and a cylinder instead to build your car if you want actual round wheels.

I think it’s more that the collision box of the car thing does not include the wheels.

It should include the wheels really, so how does he make it do that?

<cite>@zarch said:</cite> I think it's more that the collision box of the car thing does not include the wheels.

It should include the wheels really, so how does he make it do that?

Make the box bigger?

[java]BoxCollisionShape box = new BoxCollisionShape(new Vector3f(.24f, .12f, .05f));[/java]
http://hub.jmonkeyengine.org/javadoc/com/jme3/bullet/collision/shapes/BoxCollisionShape.html

@zarch said: I think it's more that the collision box of the car thing does not include the wheels.

It should include the wheels really, so how does he make it do that?

I thought the fact they’re rays implied that ^^

As I understand it there are wheels modelled into the model. Those modelled wheels (as opposed to the physics wheels which are rays) aren’t colliding but are sticking into things.

It sounds like he wants to throw rays forwards as well tho to decide what to do when he hits a wall so he can stick to it or whatever.

Either increase the size of the collision box to include the wheels or just add wheel collision shapes to the compound collision shape you already have and your done. Right now the physics shape only includes the body.

@normen said: The wheel is not a wheel but a ray, as the name of the vehicle indicates. Use a hinge joint and a cylinder instead to build your car if you want actual round wheels.

For me it works fine, thank you Normen.