Skip to content

Add support for Candi#12

Merged
AniKashyap merged 9 commits intofrc1678:alpha2from
maceolsweeney:candi
Jan 4, 2026
Merged

Add support for Candi#12
AniKashyap merged 9 commits intofrc1678:alpha2from
maceolsweeney:candi

Conversation

@maceolsweeney
Copy link
Contributor

No description provided.

@maceolsweeney
Copy link
Contributor Author

@AniKashyap

Copy link
Contributor

@AniKashyap AniKashyap left a comment

Choose a reason for hiding this comment

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

Good work making this work! Needs some work on the refactor the make it compatible and easy to integrate into a future codebase.

Comment on lines +36 to +51
public static final CANdi mCandi = getEndeffectorCandi();

public static CANdi getEndeffectorCandi() {
CANdi candi = new CANdi(Ports.CANDI.id, Ports.CANDI.bus);

CANdiConfiguration candiConfiguration = new CANdiConfiguration();
candiConfiguration.DigitalInputs.S1CloseState = S1CloseStateValue.CloseWhenNotHigh;
candiConfiguration.DigitalInputs.S1FloatState = S1FloatStateValue.PullLow;
candiConfiguration.DigitalInputs.S2CloseState = S2CloseStateValue.CloseWhenNotHigh;
candiConfiguration.DigitalInputs.S2FloatState = S2FloatStateValue.PullLow;

candi.getConfigurator().apply(candiConfiguration);

return candi;

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not define the creation of the CANdi and all this supplementary stuff like a beam break, in a different place? Would like a super simple call in Superstructure.java

return new BeamBreakIODigitalIn(
Ports.END_EFFECTOR_CORAL_BREAMBREAK.id,
return BeamBreakIOCANdi.makeInverted(
1,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is bad coding practice to define the channel in this file. This needs to be defined in ports.java

return new BeamBreakIODigitalIn(
Ports.END_EFFECTOR_ALGAE_BEAMBREAK.id,
return BeamBreakIOCANdi.makeInverted(
2,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is bad coding practice to define the channel in this file. This needs to be defined in ports.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AniKashyap can I make the I/O port a boolean because the CANdi only accepts two DI/Os?

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I think it is better to take it as an int as it is possible that in the future, CANDi's will be able to support more DI/O ports and is much eaiser to read as you can tell which port it is on instantly but that is peronal prefences to be honest.

@maceolsweeney
Copy link
Contributor Author

@AniKashyap

Copy link
Member

@JaydenHuang555 JaydenHuang555 left a comment

Choose a reason for hiding this comment

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

The code looks awesome!!! There are a few areas that I would change but it is great overall!!

};
}

public BeamBreakIOCANdi(boolean isChannelOne, Time debounce, String name, CANdi candi) {
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I think this will be more easier to read if we made a BeamBreakCANdiConfig class that stores the params that getted passed in (port, configuration, etc) rather than just passing in all of these params.

this.mCANdi = candi;

this.isChannelOne = isChannelOne;

Copy link
Member

Choose a reason for hiding this comment

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

The caller should pass the config in since the config might not be the same for all candi beambreaks

public static CANdi getCANdi() {
CANdi candi = new CANdi(Ports.CANDI.id, Ports.CANDI.bus);

CANdiConfiguration candiConfiguration = new CANdiConfiguration();
Copy link
Member

Choose a reason for hiding this comment

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

The applying configuration is called twice. Once in this method, the other is in the constructor of the BeamBreakCANdiIO

return new BeamBreakIODigitalIn(
Ports.END_EFFECTOR_ALGAE_BEAMBREAK.id,
return BeamBreakIOCANdi.makeInverted(
2,
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I think it is better to take it as an int as it is possible that in the future, CANDi's will be able to support more DI/O ports and is much eaiser to read as you can tell which port it is on instantly but that is peronal prefences to be honest.

Copy link
Contributor

@AniKashyap AniKashyap left a comment

Choose a reason for hiding this comment

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

Its super close

Comment on lines +27 to +33
import com.ctre.phoenix6.configs.CANdiConfiguration;
import com.ctre.phoenix6.hardware.CANdi;
import com.ctre.phoenix6.signals.S1CloseStateValue;
import com.ctre.phoenix6.signals.S1FloatStateValue;
import com.ctre.phoenix6.signals.S2CloseStateValue;
import com.ctre.phoenix6.signals.S2FloatStateValue;

Copy link
Contributor

Choose a reason for hiding this comment

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

Unneeded imports?

@AniKashyap AniKashyap merged commit b111787 into frc1678:alpha2 Jan 4, 2026
2 checks passed
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.

3 participants