# Self balancing robot problem in simulation

Hi to everyone, I’m trying to simulate a self balancing robot, and what I would like to do is take the controller that I create for the simulated robot and use it with just few modification on the real one. Now I think that for this kind of robot the parameters have to be as close as possible to the real one in order to get the correct dynamics. The real robot is 3D printed so for what concern dimensions of the parts, the parameter are close enough to the real one, also the weight should be close enough, the problem is about inertia matrix, motor parameters and frictions. Inertia matrix I’ve looked for the instruction that I’ve found here: http://gazebosim.org/tutorials?tut=in...

so the steps are:

- load the .stl file
- clear duplicated faces and vertex
- scale of 0.001 (cause the unit of meshlab is m I guess while in freecad is mm)
- computer the geometric filter so I get the Volume
- The inertial matrix I get is a 0 matrix, so I execute the instructions of “Scaling to increase numerical precision” and “Rescaling the moment of inertia values” paragraphs
- I didn’t checked if the matrix is positive definite and if its diagonal satisfy the triangle inequality.

So after all these steps I think and hope that the Inertial matrix are close to the real one

Motor parameters:

- The motor is a real cheap one so it doesn’t have any datasheet for parameters
- The holding torque should be around 2/3 kg*cm or 0.2/0.3 Nm (I found that through experimental tests)
- The maximum velocity should be around 100rpm
- about the joint of the motor I’ve set the effort to 0.2 and the velocity to 210

I’ll add the link of banggood where I bought the motor just in case someone has the same and can help me setting the parameters for this kind of motor that I use quite often https://www.banggood.com/6V-210RPM-En...

Friction:

- The wheels are in rubber so I’ve used a friction of 0.8 for mu1 and mu2
- The friction and the damping of the motor’s joint I’ve no idea of what insert.

Now the problem is that the moviment is really strange, and I think is fault of the effort of the motor and of inertia.

- If I increase the effort to 1 and then load the model, I notice that when the robot touch the ground literally start bouncing (I don’t have the same problem when the effort is around 0.3)
- Keeping the effort to 0.3 and putting the robot upside down, and imposing a position of let’s say 1rad the robot fall and this isn’t normal at all.

Here you can find my ros folder with the xacro file: https://github.com/roboticisfun/self_...

In the stl folder there are all the stl file I’ve used to ...