Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions examples/limit-switch/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ def __init__(self):
self.limitConfig = rev.SparkMaxConfig()
self.limitConfig.limitSwitch.forwardLimitSwitchType(
rev.LimitSwitchConfig.Type.kNormallyClosed
).forwardLimitSwitchEnabled(False).reverseLimitSwitchType(
).forwardLimitSwitchTriggerBehavior(
rev.LimitSwitchConfig.Behavior.kStopMovingMotor
).reverseLimitSwitchType(
rev.LimitSwitchConfig.Type.kNormallyClosed
).reverseLimitSwitchEnabled(
False
).reverseLimitSwitchTriggerBehavior(
rev.LimitSwitchConfig.Behavior.kStopMovingMotor
)
self.motor.configure(
self.limitConfig,
Expand All @@ -47,10 +49,12 @@ def __init__(self):
)

self.prevForwardLimitEnabled = (
self.motor.configAccessor.limitSwitch.getForwardLimitSwitchEnabled()
self.motor.configAccessor.limitSwitch.getForwardLimitSwitchTriggerBehavior()
!= 0
)
self.prevReverseLimitEnabled = (
self.motor.configAccessor.limitSwitch.getReverseLimitSwitchEnabled()
self.motor.configAccessor.limitSwitch.getReverseLimitSwitchTriggerBehavior()
!= 0
)

wpilib.SmartDashboard.putBoolean(
Expand All @@ -71,8 +75,10 @@ def teleopPeriodic(self):
self.prevForwardLimitEnabled = wpilib.SmartDashboard.getBoolean(
"Forward Limit Enabled", False
)
self.limitConfig.limitSwitch.forwardLimitSwitchEnabled(
self.prevForwardLimitEnabled
self.limitConfig.limitSwitch.forwardLimitSwitchTriggerBehavior(
rev.LimitSwitchConfig.Behavior.kStopMovingMotor
if self.prevForwardLimitEnabled
else rev.LimitSwitchConfig.Behavior.kKeepMovingMotor
)
self.motor.configure(
self.limitConfig,
Expand All @@ -85,8 +91,10 @@ def teleopPeriodic(self):
self.prevReverseLimitEnabled = wpilib.SmartDashboard.getBoolean(
"Reverse Limit Enabled", False
)
self.limitConfig.limitSwitch.reverseLimitSwitchEnabled(
self.prevReverseLimitEnabled
self.limitConfig.limitSwitch.reverseLimitSwitchTriggerBehavior(
rev.LimitSwitchConfig.Behavior.kStopMovingMotor
if self.prevReverseLimitEnabled
else rev.LimitSwitchConfig.Behavior.kKeepMovingMotor
)
self.motor.configure(
self.limitConfig,
Expand Down
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ packages = ["rev"]
artifact_id = "REVLib-cpp"
group_id = "com.revrobotics.frc"
repo_url = "https://maven.revrobotics.com"
version = "2027.0.0-alpha-3"
version = "2027.0.0-alpha-4"
staticlibs = ["REVLib"]
extract_to = "lib"

[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
artifact_id = "REVLib-driver"
group_id = "com.revrobotics.frc"
repo_url = "https://maven.revrobotics.com"
version = "2027.0.0-alpha-3"
version = "2027.0.0-alpha-4"
staticlibs = [ "REVLibDriver"]
extract_to = "lib"

[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
artifact_id = "RevLibBackendDriver"
group_id = "com.revrobotics.frc"
repo_url = "https://maven.revrobotics.com"
version = "2027.0.0-alpha-3"
version = "2027.0.0-alpha-4"
staticlibs = [
"BackendDriver",
]
Expand All @@ -71,7 +71,7 @@ use_headers = false
artifact_id = "RevLibWpiBackendDriver"
group_id = "com.revrobotics.frc"
repo_url = "https://maven.revrobotics.com"
version = "2027.0.0-alpha-3"
version = "2027.0.0-alpha-4"
staticlibs = [
"REVLibWpi",
]
Expand All @@ -92,6 +92,11 @@ use_headers = false
[tool.semiwrap]
update_init = ["rev"]
scan_headers_ignore = [
#first
"first/CANA301Driver.h",
"first/CANA301Frames.h",
"first/SimA301.h",

# rev
"rev/CANCommonParameters.h",
"rev/CANDetachedEncoderDriver.h",
Expand Down
52 changes: 42 additions & 10 deletions semiwrap/A301.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ extra_includes_first:

classes:
first::a301::A301:
enums:
GearboxRPM:
methods:
GetFirmwareVersion:
overloads:
"":
bool&:
GetFirmwareString:
A301:
GetBusId:
GetDeviceId:
GetFirmwareVersion:
GetFirmwareString:
HasActiveFault:
HasStickyFault:
HasActiveWarning:
Expand All @@ -21,34 +21,64 @@ classes:
GetStickyWarnings:
GetBusVoltage:
GetAppliedOutput:
GetMotorCurrent:
GetMotorTemperature:
GetGearboxRPM:
GetRelativeEncoderPosition:
GetEncoderVelocity:
GetAbsoluteEncoderPosition:
SetRelativeEncoderPosition:
SetAbsoluteEncoderPosition:
ClearFaults:
SetVelocity:
SetPosition:
SetRelativePosition:
SetRelativePositionWithSpeed:
SetAbsolutePosition:
SetAbsolutePositionWithSpeed:
EnableAbsolutePositionContinuousInput:
DisableAbsolutePositionContinuousInput:
IsAbsolutePositionContinuousInputEnabled:
SetCurrent:
SetThrottle:
GetThrottle:
SetVoltage:
SetInverted:
GetInverted:
Disable:
A301:
GetMotorCurrent:
SetRelativeEncoderPosition:
FaultsPeriodMs:
GetFaultsPeriodMs:
WarningsPeriodMs:
GetWarningsPeriodMs:
BusVoltagePeriodMs:
GetBusVoltagePeriodMs:
AppliedOutputPeriodMs:
GetAppliedOutputPeriodMs:
MotorCurrentPeriodMs:
GetMotorCurrentPeriodMs:
MotorTemperaturePeriodMs:
GetMotorTemperaturePeriodMs:
RelativeEncoderPositionPeriodMs:
GetRelativeEncoderPositionPeriodMs:
EncoderVelocityPeriodMs:
GetEncoderVelocityPeriodMs:
AbsoluteEncoderPositionPeriodMs:
GetAbsoluteEncoderPositionPeriodMs:
first::a301::A301::FirmwareVersion:
attributes:
major:
minor:
patch:
prerelease:
first::a301::A301::Faults:
attributes:
other:
motorType:
sensor:
can:
temperature:
gateDriver:
escEeprom:
firmware:
motorStartup:
rawBits:
methods:
Faults:
Expand All @@ -57,6 +87,8 @@ classes:
uint16_t:
first::a301::A301::Warnings:
attributes:
overvoltage:
motorLoopSpeed:
brownout:
overcurrent:
escEeprom:
Expand Down
4 changes: 4 additions & 0 deletions semiwrap/Signal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,7 @@ templates:
qualname: rev::util::Signal
params:
- first::a301::A301::Warnings
Signal_A301GearboxRPM:
qualname: rev::util::Signal
params:
- first::a301::A301::GearboxRPM
4 changes: 2 additions & 2 deletions tests/test_cana301.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ def test_set_velocity():
a301.setVelocity(12.34)


def test_set_position():
def test_set_relative_position():
a301 = rev.A301(0, 0)
a301.setPosition(12.34)
a301.setRelativePositionWithSpeed(12.34, 350.0)
2 changes: 1 addition & 1 deletion tests/test_cansparkmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ def test_pid_set():
pid = sm.getClosedLoopController()
# pid.setOutputRange(-1, 1)
# pid.setP(0.005)
pid.setReference(5, rev.SparkBase.ControlType.kPosition)
pid.setSetpoint(5, rev.SparkBase.ControlType.kPosition)
Loading