YAGSL-Example icon indicating copy to clipboard operation
YAGSL-Example copied to clipboard

Add support to Talon SRX for an integrated absolute encoder

Open WispySparks opened this issue 1 year ago • 7 comments

First time working around the codebase, I went this route because I don't think you can really have a reference to a talon's sensor like you can with revlib. Not sure if this all looks right

WispySparks avatar May 17 '24 20:05 WispySparks

This shouldnt work, you didnt create the wrapper for a psuedo absolute encoder like we discussed.

It is a good attempt but I would not accept it in its current state. The other issue is you seem to forget that the absolute encoder is ALWAYS right, the absolute encoder can change the position, NOT the motor controller.

An acceptable trade off which i may consider is implementing both abstractions for motor controllers and absolute encoders in one class but i dont think that will work out well.

thenetworkgrinch avatar May 17 '24 21:05 thenetworkgrinch

You can rely on the TalonSRX sensor which is an attached absolute encoder. You just need to create a wrapper which stores the same motor object (NOT CREATE A NEW ONE) and exclusively polls the encoder position in the correct units.

thenetworkgrinch avatar May 17 '24 21:05 thenetworkgrinch

You're getting closer!! Good job!

thenetworkgrinch avatar May 18 '24 13:05 thenetworkgrinch

Last thing is, since this is a larger change than normal, please test this on an actual robot and let us know when you do! Once it is tested it can be merged. (Note: This does NOT need to be tested by you, just an actual robot)

thenetworkgrinch avatar May 19 '24 18:05 thenetworkgrinch

Okay it might be a while until this is able to be tested but I'll let you know

WispySparks avatar May 20 '24 00:05 WispySparks

Any updates on this?

thenetworkgrinch avatar Jul 29 '24 14:07 thenetworkgrinch

Our swerve is in the process of being built over the summer, we still need to make a belly plate and wire stuff up but we only meet once a week. I'll let you know once we're testing stuff

WispySparks avatar Jul 29 '24 21:07 WispySparks

Any updates in regards to testing? :D

thenetworkgrinch avatar Oct 15 '24 20:10 thenetworkgrinch

Still working through haha, at the point of tuning PID now I believe

WispySparks avatar Oct 15 '24 23:10 WispySparks

Currently we're doing a bandaid fix for selecting the current sensor into the TalonSRX because for some reason it's getting set to QuadEncoder instead of PulseWidth. I've looked through my pr'ed code and YAGSL code for a while but still haven't found the issue so we're doing this for now to get swerve up and running.

swerveDrive = parser.createSwerveDrive(SwerveK.maxRobotSpeed.in(MetersPerSecond), angleConversionFactor, driveConversionFactor);
for (var mod : swerveDrive.getModules()) { // Bandaid Solution
    var motor = (WPI_TalonSRX) mod.getAngleMotor().getMotor();
    motor.configSelectedFeedbackSensor(FeedbackDevice.PulseWidthEncodedPosition);
}

WispySparks avatar Oct 15 '24 23:10 WispySparks

Huh thats odd, you shouldnt need to, maybe you should make that checkc not use .getMotor instead check if its a wrapper type

thenetworkgrinch avatar Oct 19 '24 04:10 thenetworkgrinch

If you need a swerve bot with talons to test on I have access to am swerve with talon srxs on turning and would happily test code for it

cmdada avatar Nov 29 '24 22:11 cmdada

I'll be in the shop tomorrow testing that last change for the sensor being selected (I only did it in sim so far) and then this should be good to go.

WispySparks avatar Nov 30 '24 00:11 WispySparks

Everything looks good on my end, this should be good to merge.

WispySparks avatar Nov 30 '24 17:11 WispySparks

Almost i need to merge beta into dev then add a new function i recently added to the SwerveMotor.java

thenetworkgrinch avatar Nov 30 '24 20:11 thenetworkgrinch

Could you resolve the conflicts when you get a chance?

thenetworkgrinch avatar Dec 03 '24 23:12 thenetworkgrinch

Just in time for the 2025 release!

thenetworkgrinch avatar Dec 04 '24 01:12 thenetworkgrinch