My bicicle explodes :(

Hi, I'm trying to get running a bicicle, but when I execute the simulation, it explodes! That's what I got:
Code:
    b2BoxDef caja; //Box attaching the wheels
       caja.extents.Set(30.0f, 5.0f);
       caja.density = 1.0f;
       caja.friction = 1.0f;
   
      b2CircleDef circle1, circle2; //the wheels
      circle1.radius = 10.0;
      circle1.density = 1.0;
      circle1.friction = 1.5;
      circle1.restitution = 0.1;
      
      circle2.radius = 10.0;
      circle2.density = 1.0;
      circle2.friction = 1.5;
      circle2.restitution = 0.1;   
   
   b2BodyDef cuadro;
   b2BodyDef rueda1;
   b2BodyDef rueda2;
   
   cuadro.AddShape(&caja);
        rueda1.AddShape(&circle1);
        rueda2.AddShape(&circle2);   

   cuadro.position.Set(0.0f, 80.0f);
   rueda1.position.Set(-20.0f, 80.0f);
   rueda2.position.Set(20.0f, 80.0f);

   b2Body* bodycuadro = world.CreateBody(&cuadro);
   b2Body* bodyrueda1 = world.CreateBody(&rueda1);
   b2Body* bodyrueda2 = world.CreateBody(&rueda2);

   bodycuadro->AllowSleeping(false);
   bodyrueda1->AllowSleeping(false);
        bodyrueda2->AllowSleeping(false);
   
   b2RevoluteJointDef jointDefRueda1,jointDefRueda2; //The revolute joins
        jointDefRueda1.body1 = bodycuadro;
        jointDefRueda1.body2 = bodyrueda1;
   jointDefRueda1.collideConnected = false;
        jointDefRueda1.anchorPoint = bodyrueda1->GetCenterPosition();
   
   jointDefRueda1.motorTorque = 0.0f;
        jointDefRueda1.motorSpeed = 0.0f;
        jointDefRueda1.enableMotor = true;
   
   jointDefRueda2.body1 = bodycuadro;
        jointDefRueda2.body2 = bodyrueda2;
        jointDefRueda2.collideConnected = false;
   jointDefRueda2.anchorPoint = bodyrueda2->GetCenterPosition();
   
   b2Joint* joint2 = world.CreateJoint(&jointDefRueda2);
   b2Joint* joint1 = world.CreateJoint(&jointDefRueda1);

What I'm missing? 😢
There is a bug with collideConnected. Try using a collision group (negative index) for now. Let me know if that doesn't fix it.
I tried your bicycle, it doesn't explode in my setup... a couple of comments:

- It's huge! Box2d is (currently) tuned to meters-kilograms-seconds, meaning your bike is 30 meters wide and the wheels have a 10m radius. You should probably zoom in your view of the world and use more realistic dimensions.

- Like Erin said, "jointDef.collideConnected=false" doesn't work for bodies that start colliding, you should use a negative groupIndex for now, that'll make your motor start working.
Thanks a lot! I will resize the bicicle and world itself 😉
I have another question, how important is the function "_finite(x)"? Becouse is not implemented in my SDK, and I have not idea about how it works, so I replace it by "always true".
I'm having some strange behaviors, and I don't know if it's becouse of this trick, becouse a poor resolution of fixed point arithmetic or becouse any other thing...
Fixed point ... nice!

Scale is going to be important for fixed point. You should try some simple tests first (like some from the test-bed).

_finite is used to check that the floating point numbers are not Infs or NaNs. In your case you could just check INT_MIN and INT_MAX.

I will soon provide a system for Box2D to adapt to any unit system. This make the tuning work well for any length scale.
At last, I think it's a problem with some incorrect implementation on GP32 libraries of some C++ function used in Box2D... PC version works perfectly, while GP32 version just explodes...
Float to fixed point conversion is done automatically when compiling, as ARM9 doesn't have FPU unit, and I've never had a single problem becouse of low resolution fixed point, so I think is something else...I'll try to find out 🙁

Original thread: https://box2d.org/forum/viewtopic.php?t=58