# Revision history [back]

### Offset Center of Gravity on a parsed model?

Hello, I have a physics::Model (i.e. not just its SDF representation, but the parsed model). I want to offset the center of gravity of one of its links during runtime (and reset the world afterwards to run a simulation with a different CoG).

I've tried virtually anything, and without success. I start with *link->GetInertial() = original_inertial_with_shifted_cog, then I call link->UpdateMass(). All of this is called inside the Load method of a model plugin. The robot shows correctly in the first step of the paused simulation, but after stepping further, the whole body goes wrong, flies away, or the CoG "tries" to get to its original position (shifting the link to an incorrect position and leaving large joint positional errors).

I tried "repairing" the relative pose of the link, relative parent pose of its joints (this is protected, but nevermind), virtually anything (before the call to UpdateMass). Always the same behavior.

If I modify the <inertial><pose> tag in the SDF, the model loads correctly with the CoG shifted, and the simulation can be run normally. The problem is I don't want to reload (delete, spawn) the model every time I want to move the CoG.

It seems to me there is some "ghost force" acting on the link that pushes its CoG always to the same position.

Is there a way to achieve this at runtime?

### Offset Center of Gravity on a parsed model?

Hello, I have a physics::Model (i.e. not just its SDF representation, but the parsed model). I want to offset the center of gravity of one of its links during runtime (and reset the world afterwards to run a simulation with a different CoG).

I've tried virtually anything, and without success. I start with *link->GetInertial() = original_inertial_with_shifted_cog, then I call link->UpdateMass(). All of this is called inside the Load method of a model plugin. The robot shows correctly in the first step of the paused simulation, but after stepping further, the whole body goes wrong, flies away, or the CoG "tries" to get to its original position (shifting the link to an incorrect position and leaving large joint positional errors).

I tried "repairing" the relative pose of the link, relative parent pose of its joints (this is protected, but nevermind), virtually anything (before the call to UpdateMass). Always the same behavior.

If I modify the <inertial><pose> tag in the SDF, the model loads correctly with the CoG shifted, and the simulation can be run normally. The problem is I don't want to reload (delete, spawn) the model every time I want to move the CoG.

It seems to me there is some "ghost force" acting on the link that pushes its CoG always to the same position.

Is there a way to achieve this at runtime?

Before the first step of the simulation (everything's like I'd want):

After a few simulation steps (the CoG moved to its original position, shifting the main body):