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>