How do you simulate a servo motor in Gazebo
Is there a guide or example for simulating a servo (specifically a Dynamixel-style servo that provides position feedback)? I know how to create a joint and apply a force to the joint, but I'm not sure how to control this as I would a servo motor, by simply specifying a position and then a plugin would intermittently apply force to keep the servo at that position. I suppose I could mock something up using Joint::GetAngle, but I don't want to reinvent the wheel.
Asked by Cerin on 2015-04-12 19:57:15 UTC
Answers
As you suggested, you'll have to write a plugin to model the behavior of a specific servo.
Asked by nkoenig on 2015-04-13 11:43:29 UTC
Comments
Is there any tutorial or example plugin I can reference?
Asked by Cerin on 2015-04-29 19:39:49 UTC
Im not sure if there is a tutorial but you can write a sensor plugin based from the ForceTorquePlugin that can be assigned to joints. If you download the gazebo code (in this case I am using version 5.0.1) you can find sample code of the ForceTorquePlugin inside the plugin folder, to get the position/angle you can use the parent sensor as in the following example:
this->parentSensor->GetJoint()->GetAngle(1).Degree()
or
this->parentSensor->GetJoint()->GetAngle(1).Radian()
Now you can apply a scaling factor to that value to correspond to the reading your servo should be providing and publish it to a topic with a message of type msgs::Joint.
Asked by PML on 2015-06-29 14:09:02 UTC
Comments
Hi PML! can you please elaborate? I ran into the same issue: I need to simulate a servo but even after browsing for a while, I'm lost... thanks!
Asked by ellerenad on 2015-11-13 02:09:24 UTC
Comments
you can use a PID controller
Asked by djou07 on 2015-04-13 02:08:17 UTC