Help with coding ctr CANcoders - Python

Hello everyone, our team recently bought some CTRE CanCoders in place for absolute encoders for our swerve drive. We are having trouble initializing and implementing them into our code from last season.
The CTRE documentation we found is confusing on how to actually initialize the CanCoders. In the previous season we used magnetic encoders.

Has anyone successfully implemented CTRE CanCoders with python? And if so, could we see some example code?

Any advice is appreciated.

Make sure you have the right import, for us it was:
from phoenix6.hardware import CANcoder

then you can just create the object:
encoder = CANcoder(deviceId)

and use this method to get the value:
self.encoder.get_absolute_position().value_as_double

You can find the source for our swerve code here.

Have you looked at CTRE’s Python CANCoder example?

I have not. I did not know one even existed, but I will now. Thank you!

Thank you! We will test it out