Skip to content
Open
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
85 changes: 85 additions & 0 deletions examples/robot/DSGamepadChooser/robot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
#
# Copyright (c) FIRST and other WPILib contributors.
# Open Source Software; you can modify and/or share it under the terms of
# the WPILib BSD license file in the root directory of this project.
#

from hal import RobotMode
import wpilib
from wpilib.opmoderobot import OpModeRobot


class DoNothingTeleop(wpilib.PeriodicOpMode):
"""A teleop opmode that intentionally does nothing."""


class ScoreAuto(wpilib.PeriodicOpMode):
"""An autonomous opmode with selectable scoring parameters."""

def __init__(self) -> None:
super().__init__()
wpilib.DriverStationDisplay.setMode(wpilib.DriverStationDisplay.Mode.Line)
self.chooser = wpilib.DSGamepadChooser(0)
self.chooser.addOptions("Target", ["High", "Mid", "Low"])
self.chooser.addIntegerOptions("Delay", 0, 5, 1)
self.chooser.addDoubleOptions("Speed", 0.25, 1.0, 0.25)
self.target = "High"
self.delay = 0
self.speed = 0.25

def disabledPeriodic(self) -> None:
self.chooser.update()
wpilib.DriverStationDisplay.updateLines()

def start(self) -> None:
self.target = self.chooser.getSelected("Target")
self.delay = self.chooser.getSelectedInteger("Delay")
self.speed = self.chooser.getSelectedDouble("Speed")

def periodic(self) -> None:
wpilib.DriverStationDisplay.addData("Selected Auto", "Score")
wpilib.DriverStationDisplay.addData("Target", self.target)
wpilib.DriverStationDisplay.addData("Delay", self.delay)
wpilib.DriverStationDisplay.addData("Speed", self.speed)
wpilib.DriverStationDisplay.updateLines()


class BalanceAuto(wpilib.PeriodicOpMode):
"""An autonomous opmode with selectable balance parameters."""

def __init__(self) -> None:
super().__init__()
wpilib.DriverStationDisplay.setMode(wpilib.DriverStationDisplay.Mode.Line)
self.chooser = wpilib.DSGamepadChooser(0)
self.chooser.addOptions("Approach", ["Left", "Center", "Right"])
self.chooser.addIntegerOptions("Attempts", 1, 3, 1)
self.chooser.addDoubleOptions("Turn Scale", 0.2, 1.0, 0.2)
self.approach = "Center"
self.attempts = 1
self.turnScale = 0.5

def disabledPeriodic(self) -> None:
self.chooser.update()
wpilib.DriverStationDisplay.updateLines()

def start(self) -> None:
self.approach = self.chooser.getSelected("Approach")
self.attempts = self.chooser.getSelectedInteger("Attempts")
self.turnScale = self.chooser.getSelectedDouble("Turn Scale")

def periodic(self) -> None:
wpilib.DriverStationDisplay.addData("Selected Auto", "Balance")
wpilib.DriverStationDisplay.addData("Approach", self.approach)
wpilib.DriverStationDisplay.addData("Attempts", self.attempts)
wpilib.DriverStationDisplay.addData("Turn Scale", self.turnScale)
wpilib.DriverStationDisplay.updateLines()


class MyRobot(OpModeRobot):
def __init__(self) -> None:
super().__init__()
self.add_opmode(DoNothingTeleop, RobotMode.TELEOPERATED, "Do Nothing Teleop")
self.add_opmode(ScoreAuto, RobotMode.AUTONOMOUS, "Score Auto")
self.add_opmode(BalanceAuto, RobotMode.AUTONOMOUS, "Balance Auto")
self.publish_opmodes()
1 change: 1 addition & 0 deletions examples/robot/examples.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ base = [
"Encoder",
"GettingStarted",
"Gyro",
"DSGamepadChooser",
"HatchbotInlined",
"HatchbotTraditional",
"MecanumBot",
Expand Down
2 changes: 1 addition & 1 deletion rdev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ wrapper = "2027.0.0a6.post4"

[params]

wpilib_bin_version = "2027.0.0-alpha-6-139-g34fee9a73"
wpilib_bin_version = "2027.0.0-alpha-6-167-gdb3a9c428"
wpilib_bin_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
# wpilib_bin_url = "https://frcmaven.wpi.edu/artifactory/development-2027"

Expand Down
5 changes: 3 additions & 2 deletions subprojects/pyntcore/ntcore/src/py2value.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <fmt/format.h>
#include <format>

#include <semiwrap.h>

#include "wpi/nt/NetworkTableType.hpp"
Expand All @@ -18,7 +19,7 @@ py::function valueFactoryByType(wpi::nt::NetworkTableType type);

inline void ensure_value_is(NT_Type expected, wpi::nt::Value* v) {
if (v->type() != expected) {
throw py::value_error(fmt::format("Value type is {}, not {}",
throw py::value_error(std::format("Value type is {}, not {}",
nttype2str(v->type()),
nttype2str(expected)));
}
Expand Down
2 changes: 0 additions & 2 deletions subprojects/robotpy-commands-v2/commands2/commandscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ def __init__(self) -> None:

self._in_run_loop = False
self._to_schedule: Dict[Command, None] = {}
# python: to_cancel_interruptors stored in _to_cancel dict
self._to_cancel: Dict[Command, Optional[Command]] = {}
# self._to_cancel_interruptors: List[Optional[Command]] = []
self._ending_commands: Set[Command] = set()

self._watchdog = Watchdog(TimedRobot.DEFAULT_PERIOD, lambda: None)
Expand Down
4 changes: 2 additions & 2 deletions subprojects/robotpy-commands-v2/tools/hids/first_ds_hids.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
},
{
"ClassName": "GameCube",
"HIDType": "STANDARD",
"HIDType": "GAMECUBE",
"axes": {
"leftX": 0,
"leftY": 1,
Expand Down Expand Up @@ -335,7 +335,7 @@
},
{
"ClassName": "Steam",
"HIDType": "STANDARD",
"HIDType": "STEAM",
"axes": {
"leftX": 0,
"leftY": 1,
Expand Down
4 changes: 2 additions & 2 deletions subprojects/robotpy-cscore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ version_file = "cscore/version.py"
artifact_id = "cscore-cpp"
group_id = "org.wpilib.cscore"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

staticlibs = ["cscore"]
extract_to = "lib"
Expand All @@ -53,7 +53,7 @@ extract_to = "lib"
artifact_id = "cameraserver-cpp"
group_id = "org.wpilib.cameraserver"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

staticlibs = ["cameraserver"]
extract_to = "lib"
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-halsim-ds-socket/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ version_file = "halsim_ds_socket/version.py"
artifact_id = "halsim_ds_socket"
group_id = "org.wpilib.halsim"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"
use_headers = false

extract_to = "halsim_ds_socket"
Expand Down
4 changes: 2 additions & 2 deletions subprojects/robotpy-halsim-ws/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ version_file = "halsim_ws/version.py"
artifact_id = "halsim_ws_server"
group_id = "org.wpilib.halsim"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"
use_headers = false

extract_to = "halsim_ws/server"
Expand All @@ -45,7 +45,7 @@ libs = ["halsim_ws_server"]
artifact_id = "halsim_ws_client"
group_id = "org.wpilib.halsim"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"
use_headers = false

extract_to = "halsim_ws/client"
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-apriltag/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ packages = ["src/native"]
artifact_id = "apriltag-cpp"
group_id = "org.wpilib.apriltag"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/apriltag"
libs = ["apriltag"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-datalog/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ packages = ["src/native"]
artifact_id = "datalog-cpp"
group_id = "org.wpilib.datalog"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/datalog"
libs = ["datalog"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-halsim-gui/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ packages = ["src/native"]
artifact_id = "halsim_gui"
group_id = "org.wpilib.halsim"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"
use_headers = true

extract_to = "src/native/halsim_gui"
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-ntcore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ packages = ["src/native"]
artifact_id = "ntcore-cpp"
group_id = "org.wpilib.ntcore"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/ntcore"
libs = ["ntcore"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-romi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ packages = ["src/native"]
artifact_id = "romiVendordep-cpp"
group_id = "org.wpilib.romiVendordep"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/romi"
libs = ["romiVendordep"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-wpihal/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ packages = ["src/native"]
artifact_id = "hal-cpp"
group_id = "org.wpilib.hal"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/wpihal"
libs = ["wpiHal"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-wpilib/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ packages = ["src/native"]
artifact_id = "wpilibc-cpp"
group_id = "org.wpilib.wpilibc"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/wpilib"
libs = ["wpilibc"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-wpimath/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ packages = ["src/native"]
artifact_id = "wpimath-cpp"
group_id = "org.wpilib.wpimath"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/wpimath"
libs = ["wpimath"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-wpinet/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ packages = ["src/native"]
artifact_id = "wpinet-cpp"
group_id = "org.wpilib.wpinet"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/wpinet"
libs = ["wpinet"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-wpiutil/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages = ["src/native"]
artifact_id = "wpiutil-cpp"
group_id = "org.wpilib.wpiutil"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/wpiutil"
libs = ["wpiutil"]
Expand Down
2 changes: 1 addition & 1 deletion subprojects/robotpy-native-xrp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ packages = ["src/native"]
artifact_id = "xrpVendordep-cpp"
group_id = "org.wpilib.xrpVendordep"
repo_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
version = "2027.0.0-alpha-6-139-g34fee9a73"
version = "2027.0.0-alpha-6-167-gdb3a9c428"

extract_to = "src/native/xrp"
libs = ["xrpVendordep"]
Expand Down
1 change: 1 addition & 0 deletions subprojects/robotpy-wpilib/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ POVDirection = "wpi/driverstation/POVDirection.hpp"
RobotState = "wpi/driverstation/RobotState.hpp"
TouchpadFinger = "wpi/driverstation/TouchpadFinger.hpp"
Gamepad = "wpi/driverstation/Gamepad.hpp"
DSGamepadChooser = "wpi/driverstation/DSGamepadChooser.hpp"
GenericHID = "wpi/driverstation/GenericHID.hpp"
HIDDevice = "wpi/driverstation/HIDDevice.hpp"
Joystick = "wpi/driverstation/Joystick.hpp"
Expand Down
48 changes: 48 additions & 0 deletions subprojects/robotpy-wpilib/semiwrap/DSGamepadChooser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
extra_includes:
- pybind11/stl.h
- wpi/driverstation/Gamepad.hpp

classes:
wpi::DSGamepadChooser:
methods:
DSGamepadChooser:
overloads:
int:
Gamepad&:
keepalive:
- [1, 2]
GetGamepad:
overloads:
"":
return_value_policy: reference_internal
'[const]':
ignore: true
AddOptions:
overloads:
std::string_view, std::vector<std::string>:
return_value_policy: reference_internal
std::string_view, std::initializer_list<std::string_view>:
ignore: true
AddIntegerOptions:
return_value_policy: reference_internal
AddDoubleOptions:
return_value_policy: reference_internal
Update:
GetSelected:
GetSelectedInteger:
GetSelectedDouble:
GetSelectedIndex:
GetSelectableNames:
GetSelectedSelectable:
overloads:
"":
return_value_policy: reference_internal
'[const]':
ignore: true

wpi::DSGamepadChooser::GamepadSelectable:
methods:
GetName:
GetOptions:
GetSelected:
GetSelectedIndex:
6 changes: 3 additions & 3 deletions subprojects/robotpy-wpilib/semiwrap/ExpansionHubMotor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ classes:
SetPositionSetpoint:
SetVelocitySetpoint:
SetEnabled:
SetFloatOn0:
rename: set_float_on_0
GetCurrent:
SetDistancePerCount:
GetEncoderVelocity:
Expand All @@ -17,8 +15,10 @@ classes:
ResetEncoder:
IsHubConnected:
Follow:
Unfollow:
GetVelocityConstants:
GetPositionConstants:
Unfollow:
SetNeutralMode:
enums:
NeutralMode:
FollowDirection:
6 changes: 3 additions & 3 deletions subprojects/robotpy-wpilib/semiwrap/FieldObject2d.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extra_includes:
- wpi/math/trajectory/DifferentialTrajectory.hpp
- wpi/math/trajectory/SplineTrajectory.hpp
- wpi/math/trajectory/DrivetrainSplineTrajectory.hpp
- wpi/math/trajectory/HolonomicTrajectory.hpp
- wpi/math/trajectory/Trajectory.hpp

Expand All @@ -22,9 +22,9 @@ classes:
ignore: true
SetTrajectory:
template_impls:
- [wpi::math::SplineSample]
- [wpi::math::DifferentialSample]
- [wpi::math::TrajectorySample]
- [wpi::math::DrivetrainSplineSample]
- [wpi::math::HolonomicSample]
GetPoses:
overloads:
'[const]':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ classes:
cpp_code: |
[](wpi::sim::AddressableLEDSim &self, std::span<wpi::AddressableLED::LEDData> &data) {
if (static_cast<int>(data.size()) != self.GetLength()) {
std::string msg = fmt::format("data must have length {} (got {})", self.GetLength(), data.size());
std::string msg = std::format("data must have length {} (got {})", self.GetLength(), data.size());
throw py::value_error(msg);
}
self.SetData(data.data());
Expand Down
Loading