Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isConnected method to encoders #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rcahoon
Copy link
Member

@rcahoon rcahoon commented Sep 21, 2024

Description

isConnected() should return true iff the software is receiving up-to-date and correct information from the encoder. This is primarily useful with the Rev absolute encoders, but also is applicable to CANcoders.

example use:

if (!initialized && absoluteEncoder.isConnected()) {
final double absoluteEncoderPosition =
Math.IEEEremainder(
absoluteEncoder.getPosition() + absoluteEncoderOffset.get(), 1.0);
SmartDashboard.putNumber(
"[ARM] AbsoluteEncoder Init Position", absoluteEncoderPosition);
motor.setSensorPosition(
absoluteEncoderPosition
* ABSOLUTE_ENCODER_TO_ARM_ANGLE
/ MOTOR_ROTATIONS_TO_ARM_ANGLE);
initialized = true;
}

How Has This Been Tested?

  • Unit tests: [Add your description here]
  • Simulator testing: [Add your description here]
  • On-robot bench testing: Tested on m-ayhem demo bot
  • On-robot field testing: [Add your description here]

Copy link
Contributor

@dejabot dejabot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, excited about this!

can be follow-on, but I think we'll also want to fix REVThroughBoreDutyCycleEncoder to work with this, too, eg:

   public REVThroughBoreDutyCycleEncoder(int channel) {
        super(channel);
        setDutyCycleRange(1. / 1025., 1024. / 1025.);
=>      setConnectedFrequencyThreshold(975 /* 975.6 on spec sheet */);
    }

(picking up from #94 - which requires some testing.)

@rcahoon
Copy link
Member Author

rcahoon commented Sep 21, 2024

I think we'll also want to fix REVThroughBoreDutyCycleEncoder to work with this, too

agreed! REVThroughBoreDutyCycleEncoder adopts the isConnected() implementation from its parent class, so it ought to work once #94 merges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants