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

Add isConnected method to encoders#25

Merged
rcahoon merged 3 commits into
mainfrom
rcahoon/encoder-isconnected
Jan 18, 2025
Merged

Add isConnected method to encoders#25
rcahoon merged 3 commits into
mainfrom
rcahoon/encoder-isconnected

Conversation

@rcahoon
Copy link
Copy Markdown
Member

@rcahoon rcahoon commented Jan 14, 2025

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;
}

Original 2024 PRs: Team766/2024#137 Team766/2024#94

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Be detailed so that your code reviewer can understand exactly how much and what kinds of testing were done, and which might still be worthwhile to do.

  • 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]

@rcahoon rcahoon merged commit 8c60c81 into main Jan 18, 2025
@rcahoon rcahoon deleted the rcahoon/encoder-isconnected branch January 18, 2025 07:22
rajitzg pushed a commit that referenced this pull request Jan 18, 2025
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.
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