Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Add isConnected method to encoders#137

Open
rcahoon wants to merge 1 commit into
mainfrom
rcahoon/encoder-isconnected
Open

Add isConnected method to encoders#137
rcahoon wants to merge 1 commit into
mainfrom
rcahoon/encoder-isconnected

Conversation

@rcahoon
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants