Self balancing robot simulation

Hi to everyone I’m trying to simulate a self-balancing robot, I’ve tried to calculate the inertia of each part using the basic formulas for cube and cylinder. Now my problem is the simulation in Gazebo, the way that the robot fall is completely unnatural. The problem seems to be in the differential drive plugin cause when I change the torque of the wheel the robot literally start flying and turning around. What am I missing? The value of the torque that I’ve tried is 0.4 Nm and 0.1Nm I’m using a cheap chinese motor with something around 10kgcm stall torque, 2kgcm max efficency.
When I keep low enough the value of the torque, the robot seems to fall on the ground like a real one. At this point the problem is that also giving high value of velocity with /cmd_vel the robot moves really slowly. What I’m trying to do is a non linear control on the robot so it needs to run fast in order to stand up from the floor. Any help will be really appreciated. Thank you :relaxed:

here there is the xacro file

youtube video with torque = 0.4Nm(and in the same channel you can find the video with Tourque = 0.1Nm)

Hi @lamarcagiuseppe977,

Looking at your file, it seems to me that this is normal physics. your two wheels weigh together 120g, The motors weighing 200g are on the same axis. The rest of the robot only weighs 300g. So if you start accelerating and spinning these wheels very fast, the robot is going to freak out of course. Also it seems the acceleration is very high. Hard to verify for me whether it is realistic with that torque or not. I might be wrong and would suggest playing with the weight ratios. Lighter wheels compared to the body.

1 Like

One more thing I noticed is, that you only specified the moment of inertia around one axis for the wheels and the motors. I might be wrong, but I think you have to add the full inertia matrix, as you have a complexer system.

Hi @simon.steinmann91, thanks for the replay I will try to play more with the parameters. The point is that I don’t know where is possible specify other motor’s parameters cause I guess the torque it refers to the stall torque, but I don’t know where I can specify the speed with no load. The problem is that when you put the robot a little bit faraway from the unstable equilibrium it should fall quite fast but the problem is that It falls like in slow mothion, instead if I put the torque of the motors to 0 it falls normally. This is what I don’t understand, why if the motors are not moving at all the difference of torque give a different simulation result. Thanks for your time :slight_smile:

you have a typo in line 177. That might cause the issues if you are lucky :smiley:

1 Like

hey @simon.steinmann91 I’ve adjusted the misstypo but nothing changed cause I’ve noticed that the inertia is wrong. When I check the inertia of the single urdf element the inertia looks good but when I visualize the inertia of the all robot is something awful. In order to do the test I’ve set the mass of each component to 1kg and this is what I get:
Only base inertia:

Only one motor inertia (deactivating the base’s inertia tag):

Base + motor inertia:

Do you have any idea to know how can I solve this?

Have you adjusted the inertia of wheels and motor? you only had the moment of inertia around one axis, not all 3. Once you have done that, post your urdf again.

The inertia was strange cause I’ve just activated one motor + base, now I’ve add all the other components + the battery and it looks better. Now when I make the robot fall it falls normally also with the torque=1Nm I don’t know if this just depends by the fact that I’ve add the battery or cause I’ve modiefied something else. Anyway really thanks for the support :slight_smile:

@simon.steinmann91 thanks a lot I’ve tried removing battery and other stuffs but the problem was as you said the inertia in the other axis, now it works really good :blush: :blush: :blush: , this is the file in the case someone want play around with it


SOOO cool! Great work! I would highly recommend you to create a ROSject and git to share this project with all the community :wink:

@duckfrost yeah sure, I will add a couple of controllers and I’ll share with the community :wink: