Lift Controller Plugin
Hi,
I created a model of a Fork-Lifter. The Chassis and the forks are separated links, connected with a prismatic joint. This joint is controlled by a plug-in that handles the fork height.
When I'm spawning the model, sometimes I have the issue that the fork is spawned a few meters away from the chassis. When I'm excluding the fork lift plug-in it seems stable.
Another issue is that sometimes when I'm spawning the model, it seems that it gets a force kick and than it flies away. I already adjusted the inertia, but it doesn't helped. The reproductivity of both errors are quite strange, sometimes it works, sometimes the forks are displaced and sometime the whole model flies away.
Can someone have a look on my model.sdf and the lift/fork control plug-in? I'm really running out of ideas where the error could be.
[UPDATE]:
The solution for me was to use SetForce() instead of using the model SetJointPosition() method. I followed the ElevatorPlugin example and implemented it like that:
this->liftPID.Init(1600, 0, 1600);
double error = this->liftJoint->GetAngle(2).Radian() - (setpoint_height);
double force = this->liftPID.Update(error, _info.simTime - this->prevSimTime);
this->prevSimTime = _info.simTime;
this->liftJoint->SetForce(0, force);
Also an approach over a JointController and setting up a pid over SetPositionPID() was avoiding my problem. But now I'm encountering another one, when I'm trying to lift something with the fork, a pallet or a box, its either flying away or the vehicle starts to shake.... I updated already my model added the same parameters like in the elevator example for the lift joint, but no success.
Thanks a lot, Rob
What's the gazebo version you're using?
That happens to me also, when using factory message to spawn a model, one part of the model goes to the correct place, the other goes to a completly different position ... Gazebo is very buggy sometimes, it doesnt handle model spawn/delete on the fly very well, at least for me tho
I'm using 7.3.1
So i narrowed it down to the lift control plugin. I changed the initial fork height from 0.163 to 0. I actually assumed that the method SetJointPosition is not influencing the physics engine, but it doesn't help anyway. I also changed the order of the subscriber init and the update events init and now its done at the end of the load method. But still 1 of 4 times the fork is displaced.
May be, we (you and i) should use boost::mutex * GetSetWorldPoseMutex () const before making any changes to a model ... In my plugin i also dynamically change the sdf of the robot and odd behaviours occur.
So i played around a little and in my case the following line is causing the problem: this->model->SetJointPosition(lift_joint->GetScopedName(), this->lift_height);
I don't think setJointPosition does a teleportation like you expect. The easy solution is to send a JointCmd message, which uses PID to control joint position