# Gazebo joint->SetForce() call applies forces to the whole model. How to circumvent that?

The following code applies a force to the joint in an update method call. The problem is that the force seems to dissipate / is applied consecutively to other parts of the model, specifically the chassis, which holds the rotating laser. How can I circumvent that?

The chassis shold be a moving vehicle so I can't just fix it to the ground plane, using a fixed joint.

This is my onUpdate() from within the gazebo plugin. Essentially its making the joint rotate back and forth on a specified axis.

public: void OnUpdate(const common::UpdateInfo & /*_info*/){

rotation = this->joint->GetAngle(0);
this->joint->SetStopDissipation(0,0);
double degree = rotation.Degree();
if (degree <= -90) {
this->joint->SetForce(rotationAxis,effort*2);
}
else if (degree >= 90) {
this->joint->SetForce(rotationAxis,-effort*2);
}
std::cerr << degree << "\n"; }


The definition from the model.sdf is this:

    <joint name="back_and_forth_joint" type="revolute">
<child>laser</child>
<parent>chassis</parent>
<axis>
<xyz>1 0 0</xyz>
<limit>
<lower>-1.57079633</lower>
<upper>1.57079633</upper>
</limit>
</axis>
</joint>


Thanks.

Update:

One of the possibilities is to simply add mass to the chassis like so:

        <link name='chassis'>
<pose>0 0 .1 0 0 0</pose>
<inertial>
<mass>10</mass>
</inertial>


As you mentioned in your update,

One of the possibilities is to simply add mass to the chassis

This works because, at some point, you need a reaction force. An applied force (or torque) at any point in a structure will be transmitted through the structure back to a "fixed" object. The fixed object is generally the Earth, and connection to the Earth is through poles or other supports inserted into the Earth (a foundation) or through a friction contact with the surface (such as tires, etc.)

You are correct in that you can't connect a mobile vehicle to the Earth using a fixed joint, but you can use a series of flexible joints to simulate contact with the Earth. How are you simulating motion right now?

What you're experiencing, by the way, is the same behavior you'd see if you applied a force to an object in space where there is no "fixed" object to apply the reaction force.

The Earth is essentially infinitely massive, for the purposes of providing reaction forces for anything you or I would ever do. What you're looking for, if you can't or won't model the connection between the wheels and the ground, is to make the chassis "sufficiently massive" such that it doesn't generate an appreciable acceleration when your external force is applied.

If you've watched Battlebots, then you've probably seen instances where the chassis is NOT sufficiently massive and the robot flips when an actuator is used. There's nothing to absorb the reaction force, so the entire body moves. The effect is more pronounced as ratio of applied force the mass of the "base" body is increased.