Servo getAngle

I want to getAngle from servo but when i want to use it in smartdashboard it nothing show. How to do this?

What is your code base? CPP, Java, Labview,Python?

The text based variants will have something along the lines of:

Smartdashboard.putNumber("Servo Angle", myservo.getAngle());

Then on the smart dashboard you will find a variable with the key value of “Servo Angle” that can be displayed using a variety of widgets.

Find more information looking at the WPI Tools section. Particularly the ShuffleBoard and Smart Dashboard sections.

PS: also be sure Team numbers are set up so the Networktables has a clue where to look for the data.

we open servo there’s no encoder inside :wink:

The servo is a write only device. It is intended to move based on the signal sent to it so there is no way to “know” what is a servo is set to.

Since you know what signal the servo is being sent, the software, at best, assumes the servo is working and responding to its control signal and therefore is at it’s commanded position.

You can’t have the servo tell you its angle but you instead tell it want angle you want it to be.

The method you mentioned returns a cached value from the library which corresponds to the angle the associated servo is being commanded to move to - it’s not a confirmation from the servo as it’s a one-way only device (no feedback)

If you want to confirm the angle independently, you’ll need an additional sensor / encoder.

1 Like

There usually is an encoder of some sort inside the servo but it is for internal use by the servo logic and not externally accessible.

So that won’t help us :frowning:

Just to be pedantic, this is true for FRC legal servos. However, it is not true for all servos. There exist a lot of smart servos that communicate over things other than PWM.

100% correct - since we’re on CD, I took the scope to be pretty tight but there are much more capable devices out there.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.