Skip to content

Commit

Permalink
Merge pull request #179 from robotpy/2024-beta
Browse files Browse the repository at this point in the history
Update to latest Phoenix 5
  • Loading branch information
virtuald authored Nov 12, 2023
2 parents d516cab + 126e0a4 commit 9574e24
Show file tree
Hide file tree
Showing 50 changed files with 287 additions and 193 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ on:

jobs:
ci:
uses: robotpy/build-actions/.github/workflows/package-ci.yml@v2023
uses: robotpy/build-actions/.github/workflows/package-ci.yml@v2024
with:
enable_raspbian: false
enable_sphinx_check: false
artifactory_repo_type: vendor
fail_fast: false
python_versions: >-
["3.9", "3.10", "3.11", "3.12"]
secrets:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_PASSPHRASE: ${{ secrets.SSH_PASSPHRASE }}
META_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
RTD_TOKEN: ${{ secrets.RTD_TOKEN }}
RTD_WEBHOOK: ${{ secrets.RTD_WEBHOOK }}
WPI_ARTIFACTORY_USERNAME: ${{ secrets.WPI_ARTIFACTORY_USERNAME }}
WPI_ARTIFACTORY_TOKEN: ${{ secrets.WPI_ARTIFACTORY_TOKEN }}
PYPI_API_TOKEN: ${{ secrets.PYPI_PASSWORD }}
18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ __pycache__/
*$py.class

# C extensions
/ctre/_init_ctre.py
/ctre/pkgcfg.py
/ctre/rpy-include
/ctre/version.py
/ctre/py.typed

/ctre/_*/_init_*.py
/ctre/_*/pkgcfg.py
/ctre/_*/include
/phoenix5/_init_ctre.py
/phoenix5/pkgcfg.py
/phoenix5/rpy-include
/phoenix5/version.py
/phoenix5/py.typed

/phoenix5/_*/_init_*.py
/phoenix5/_*/pkgcfg.py
/phoenix5/_*/include


# Distribution / packaging
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
robotpy-ctre
============

This is a python wrapper around the CTRE Phoenix library. The RobotPy project
This is a python wrapper around the CTRE Phoenix v5 API. The RobotPy project
is not associated with or endorsed by Cross The Road Electronics.

**NOTE**: CTRE only supports simulation for the following platforms:
Expand Down
6 changes: 3 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ and we'll try to address the problem.

.. toctree::

ctre
ctre.led
ctre.sensors
phoenix5
phoenix5.led
phoenix5.sensors
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from os.path import abspath, join, dirname

import ctre
import phoenix5

# -- RTD configuration ------------------------------------------------

Expand Down Expand Up @@ -136,6 +136,6 @@

root = abspath(dirname(__file__))

gen_package(root, "ctre")
gen_package(root, "ctre.led")
gen_package(root, "ctre.sensors")
gen_package(root, "phoenix5")
gen_package(root, "phoenix5.led")
gen_package(root, "phoenix5.sensors")
4 changes: 2 additions & 2 deletions examples/basic/robot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import wpilib
import ctre
import phoenix5


class MyRobot(wpilib.TimedRobot):
Expand All @@ -11,7 +11,7 @@ class MyRobot(wpilib.TimedRobot):
"""

def robotInit(self):
self.motor = ctre.WPI_TalonSRX(1) # Initialize the TalonSRX on device 1.
self.motor = phoenix5.WPI_TalonSRX(1) # Initialize the TalonSRX on device 1.

def disabledPeriodic(self):
self.motor.disable()
Expand Down
6 changes: 3 additions & 3 deletions examples/getting-started/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import wpilib
import wpilib.drive
import ctre
import phoenix5


class MyRobot(wpilib.TimedRobot):
Expand All @@ -16,8 +16,8 @@ def robotInit(self):
This function is called upon program startup and
should be used for any initialization code.
"""
self.leftDrive = ctre.WPI_TalonFX(1)
self.rightDrive = ctre.WPI_TalonFX(2)
self.leftDrive = phoenix5.WPI_TalonFX(1)
self.rightDrive = phoenix5.WPI_TalonFX(2)
self.robotDrive = wpilib.drive.DifferentialDrive(
self.leftDrive, self.rightDrive
)
Expand Down
2 changes: 1 addition & 1 deletion examples/motion_magic/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* use button1 to motion-magic servo to target position specified by the gamepad stick.
"""

from ctre import WPI_TalonSRX
from phoenix5 import WPI_TalonSRX
import wpilib


Expand Down
12 changes: 6 additions & 6 deletions examples/position_closed_loop/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Tweak the PID gains accordingly.
"""

import ctre
import phoenix5
import wpilib


Expand All @@ -37,7 +37,7 @@ class Robot(wpilib.TimedRobot):
kTimeoutMs = 10

def robotInit(self):
self.talon = ctre.WPI_TalonSRX(3)
self.talon = phoenix5.WPI_TalonSRX(3)
self.joy = wpilib.Joystick(0)

self.loops = 0
Expand All @@ -46,7 +46,7 @@ def robotInit(self):

# choose the sensor and sensor direction
self.talon.configSelectedFeedbackSensor(
ctre.FeedbackDevice.CTRE_MagEncoder_Relative,
phoenix5.FeedbackDevice.CTRE_MagEncoder_Relative,
self.kPIDLoopIdx,
self.kTimeoutMs,
)
Expand Down Expand Up @@ -106,14 +106,14 @@ def teleopPeriodic(self):

# 10 Rotations * 4096 u/rev in either direction
self.targetPos = leftYstick * 4096 * 10.0
self.talon.set(ctre.ControlMode.Position, self.targetPos)
self.talon.set(phoenix5.ControlMode.Position, self.targetPos)

# on button2 just straight drive
if button2:
# Percent voltage mode
self.talon.set(ctre.ControlMode.PercentOutput, leftYstick)
self.talon.set(phoenix5.ControlMode.PercentOutput, leftYstick)

if self.talon.getControlMode() == ctre.ControlMode.Position:
if self.talon.getControlMode() == phoenix5.ControlMode.Position:
# append more signals to print when in speed mode.
sb.append("\terr: %s" % self.talon.getClosedLoopError(self.kPIDLoopIdx))
sb.append("\ttrg: %.3f" % self.targetPos)
Expand Down
3 changes: 2 additions & 1 deletion gen/BaseMotorController.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classes:
overloads:
"":
rename: __str__
std::string&:
const std::string&:
FilterConfiguration:
shared_ptr: true
attributes:
Expand Down Expand Up @@ -322,6 +322,7 @@ classes:
GetSlotConfigs:
GetFilterConfigs:
GetHandle:
ignore: true
GetVictorSPXSimCollection:
BaseConfigAllSettings:
BaseGetAllConfigs:
Expand Down
3 changes: 1 addition & 2 deletions gen/BasePigeon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ classes:
GetCompassHeading:
GetCompassFieldStrength:
GetTemp:
overloads:
'[const]':
GetUpTime:
GetRawMagnetometer:
GetBiasedMagnetometer:
Expand All @@ -79,6 +77,7 @@ classes:
GetFirmwareVersion:
ClearStickyFaults:
GetLowLevelHandle:
ignore: true
ConfigAllSettings:
GetAllConfigs:
ConfigFactoryDefault:
Expand Down
5 changes: 3 additions & 2 deletions gen/BufferedTrajectoryPointStream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ classes:
Clear:
Write:
overloads:
TrajectoryPoint&:
TrajectoryPoint*, uint32_t:
const TrajectoryPoint&:
const TrajectoryPoint*, uint32_t:
GetHandle:
ignore: true
21 changes: 7 additions & 14 deletions gen/CANdleConfiguration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ classes:
force_no_trampoline: true
base_qualnames:
CustomParamConfiguration: ctre::phoenix::CustomParamConfiguration
attributes:
stripType:
brightnessScalar:
disableWhenLOS:
statusLedOffWhenActive:
vBatOutputMode:
v5Enabled:
methods:
CANdleConfiguration:
toString:
rename: __str__

inline_code: |
cls_CANdleConfiguration
.def_readwrite("stripType", &ctre::phoenix::led::CANdleConfiguration::stripType,
py::doc("What type of LEDs the CANdle controls"))
.def_readwrite("brightnessScalar", &ctre::phoenix::led::CANdleConfiguration::brightnessScalar,
py::doc("Brightness scalar for all LEDs controlled"))
.def_readwrite("disableWhenLOS", &ctre::phoenix::led::CANdleConfiguration::disableWhenLOS,
py::doc("True to turn off LEDs when Loss of Signal occurrs"))
.def_readwrite("statusLedOffWhenActive", &ctre::phoenix::led::CANdleConfiguration::statusLedOffWhenActive,
py::doc("True to turn off Status LED when CANdle is actively being controlled"))
.def_readwrite("vBatOutputMode", &ctre::phoenix::led::CANdleConfiguration::vBatOutputMode,
py::doc("The behavior of VBat output"))
;
2 changes: 0 additions & 2 deletions gen/ColorFlowAnimation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
classes:
ColorFlowAnimation:
subpackage: led
typealias:
- ctre::phoenix::led::ColorFlowAnimation::Direction
enums:
Direction:
methods:
Expand Down
2 changes: 0 additions & 2 deletions gen/LarsonAnimation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
classes:
LarsonAnimation:
subpackage: led
typealias:
- ctre::phoenix::led::LarsonAnimation::BounceMode
enums:
BounceMode:
methods:
Expand Down
6 changes: 3 additions & 3 deletions gen/LimitSwitchType.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ classes:
IsRemote:
toString:
overloads:
ctre::phoenix::motorcontrol::LimitSwitchSource:
LimitSwitchSource:
ignore: true
ctre::phoenix::motorcontrol::RemoteLimitSwitchSource:
RemoteLimitSwitchSource:
ignore: true
ctre::phoenix::motorcontrol::LimitSwitchNormal:
LimitSwitchNormal:
ignore: true
12 changes: 11 additions & 1 deletion gen/Pigeon2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ classes:
force_no_trampoline: true
base_qualnames:
CustomParamConfiguration: ctre::phoenix::CustomParamConfiguration
attributes:
MountPoseYaw:
MountPosePitch:
MountPoseRoll:
EnableCompass:
DisableTemperatureCompensation:
DisableNoMotionCalibration:
XAxisGyroError:
YAxisGyroError:
ZAxisGyroError:
methods:
Pigeon2Configuration:
toString:
Expand Down Expand Up @@ -44,7 +54,7 @@ classes:
GetStickyFaults:
ConfigMountPose:
overloads:
ctre::phoenix::sensors::AxisDirection, ctre::phoenix::sensors::AxisDirection, int:
AxisDirection, AxisDirection, int:
double, double, double, int:
ConfigMountPoseYaw:
ConfigMountPosePitch:
Expand Down
6 changes: 3 additions & 3 deletions gen/PigeonIMU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ classes:
default: "{0,0,0}"
GetFusedHeading:
overloads:
PigeonIMU::FusionStatus&:
FusionStatus&:
"[const]":
GetResetCount:
GetResetFlags:
GetFirmVers:
HasResetOccurred:
ToString:
overloads:
ctre::phoenix::sensors::PigeonIMU::PigeonState:
ctre::phoenix::sensors::PigeonIMU::CalibrationMode:
PigeonIMU::PigeonState:
CalibrationMode:
ConfigSetCustomParam:
ConfigGetCustomParam:
ignore: true
Expand Down
2 changes: 1 addition & 1 deletion gen/StatorCurrentLimitConfiguration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ classes:
StatorCurrentLimitConfiguration:
overloads:
"":
double*, int:
const double*, int:
ignore: true # unsafe array
bool, double, double, double:
ToString:
Expand Down
2 changes: 1 addition & 1 deletion gen/SupplyCurrentLimitConfiguration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classes:
overloads:
"":
bool, double, double, double:
double*, int:
const double*, int:
ignore: true # unsafe array
ToString:
rename: __str__
Expand Down
2 changes: 1 addition & 1 deletion gen/TalonSRX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ classes:
TalonSRX:
overloads:
int:
int, std::string&:
int, const std::string&:
"":
ignore: true
ConfigSelectedFeedbackSensor:
Expand Down
2 changes: 0 additions & 2 deletions gen/TwinkleAnimation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
classes:
TwinkleAnimation:
subpackage: led
typealias:
- ctre::phoenix::led::TwinkleAnimation::TwinklePercent
enums:
TwinklePercent:
methods:
Expand Down
2 changes: 0 additions & 2 deletions gen/TwinkleOffAnimation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
classes:
TwinkleOffAnimation:
subpackage: led
typealias:
- ctre::phoenix::led::TwinkleOffAnimation::TwinkleOffPercent
enums:
TwinkleOffPercent:
methods:
Expand Down
2 changes: 1 addition & 1 deletion gen/VictorSPX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ classes:
VictorSPX:
overloads:
int:
int, std::string&:
int, const std::string&:
GetPIDConfigs:
ConfigAllSettings:
GetAllConfigs:
Expand Down
1 change: 1 addition & 0 deletions ctre/__init__.py → phoenix5/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import _init_phoenix6
from . import _init_ctre

# autogenerated by 'robotpy-build create-imports ctre'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions phoenix5/_init_phoenix6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from phoenix6.phoenix_native import Native

Native.instance()
Loading

0 comments on commit 9574e24

Please sign in to comment.