How to read servo angle?

Hi,
I wonder if there is a way to read the current servo angle of my GoPiGo2.
Thanks,
Borge

2 Likes

Not really. You can save the last commanded angle in a variable, and access that. If you turn off the servo in between commands to save the battery, the angle might have changed, but probably not.

Here is a Python class for GoPiGo3 not GoPiGo2 but you can get the idea I am talking about.

1 Like

That depends on what the servos are connected to and how they’re mounted.

Regular “plain-vanilla” servos neither lock their position setting nor have a way to read it back.

On my robot,

My two servos are attached to a pan-and-tilt mount right at the front of the robot where they can be accidentally moved very easily.

In my case, I never assume that the servos are where I left them because it is too easy for an accidental “bump!” to move them.

Your case might be different.

If knowing the absolute position of your servos is a requirement, then you might need a different kind of servo, (one that locks when set), or some kind of position sensor attached to the servo, or perhaps both.

2 Likes