mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[robotpy][examples] Split examples and snippets (#8944)
This also updates the bazel scripts to behave more like the C++ and Java examples, and updates the copybara scripts to be able to sync up `mostrobotpy`
This commit is contained in:
@@ -2,7 +2,7 @@ load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
||||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
|
||||
load(":define_examples.bzl", "define_examples")
|
||||
load(":define_examples.bzl", "define_examples", "define_snippets")
|
||||
|
||||
py_binary(
|
||||
name = "generate_bazel_files",
|
||||
@@ -22,7 +22,8 @@ cmd = "$(locations :generate_bazel_files) $(OUTS)"
|
||||
genrule(
|
||||
name = "generate_bazel_files_rule",
|
||||
srcs = [
|
||||
"examples.toml",
|
||||
"examples/examples.toml",
|
||||
"snippets/snippets.toml",
|
||||
],
|
||||
outs = ["gen/example_projects.bzl"],
|
||||
cmd = cmd,
|
||||
@@ -45,3 +46,5 @@ py_console_script_binary(
|
||||
)
|
||||
|
||||
define_examples()
|
||||
|
||||
define_snippets()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
||||
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
|
||||
load("//robotpyExamples:example_projects.bzl", "PROJECTS")
|
||||
load("//robotpyExamples:example_projects.bzl", "EXAMPLE_PROJECTS", "SNIPPET_PROJECTS")
|
||||
|
||||
def define_examples():
|
||||
for example_folder in PROJECTS:
|
||||
def _define_robot_project(projects, project_type):
|
||||
for example_folder in projects:
|
||||
base_name = example_folder.replace("/", "_")
|
||||
common_kwargs = dict(
|
||||
srcs = [":robotpy_entry_point.py"],
|
||||
@@ -42,3 +42,9 @@ def define_examples():
|
||||
deps = common_deps + ["//simulation/halsim_gui:robotpy-halsim-gui"],
|
||||
**common_kwargs
|
||||
)
|
||||
|
||||
def define_examples():
|
||||
_define_robot_project(EXAMPLE_PROJECTS, "example")
|
||||
|
||||
def define_snippets():
|
||||
_define_robot_project(SNIPPET_PROJECTS, "snippet")
|
||||
|
||||
@@ -1,51 +1,53 @@
|
||||
PROJECTS = [
|
||||
"AddressableLED",
|
||||
"AprilTagsVision",
|
||||
"ArcadeDrive",
|
||||
"ArcadeDriveXboxController",
|
||||
"ArmSimulation",
|
||||
"CANPDP",
|
||||
"DifferentialDriveBot",
|
||||
"DifferentialDrivePoseEstimator",
|
||||
"DigitalCommunication",
|
||||
"DriveDistanceOffboard",
|
||||
"DutyCycleEncoder",
|
||||
"DutyCycleInput",
|
||||
"ElevatorExponentialProfile",
|
||||
"ElevatorExponentialSimulation",
|
||||
"ElevatorProfiledPID",
|
||||
"ElevatorSimulation",
|
||||
"ElevatorTrapezoidProfile",
|
||||
"Encoder",
|
||||
"EventLoop",
|
||||
"FlywheelBangBangController",
|
||||
"GettingStarted",
|
||||
"Gyro",
|
||||
"HatchbotInlined",
|
||||
"HatchbotTraditional",
|
||||
"HttpCamera",
|
||||
"I2CCommunication",
|
||||
"IntermediateVision",
|
||||
"MecanumBot",
|
||||
"MecanumDrive",
|
||||
"MecanumDrivePoseEstimator",
|
||||
"Mechanism2d",
|
||||
"MotorControl",
|
||||
"QuickVision",
|
||||
"RapidReactCommandBot",
|
||||
"RomiReference",
|
||||
"SelectCommand",
|
||||
"SimpleDifferentialDriveSimulation",
|
||||
"Solenoid",
|
||||
"StateSpaceArm",
|
||||
"StateSpaceElevator",
|
||||
"StateSpaceFlywheel",
|
||||
"StateSpaceFlywheelSysId",
|
||||
"SwerveBot",
|
||||
"SwerveDrivePoseEstimator",
|
||||
"SysId",
|
||||
"TankDrive",
|
||||
"TankDriveXboxController",
|
||||
"UnitTest",
|
||||
"XrpReference",
|
||||
EXAMPLE_PROJECTS = [
|
||||
"examples/ArcadeDrive",
|
||||
"examples/ArcadeDriveXboxController",
|
||||
"examples/ArmSimulation",
|
||||
"examples/DifferentialDriveBot",
|
||||
"examples/DifferentialDrivePoseEstimator",
|
||||
"examples/DriveDistanceOffboard",
|
||||
"examples/DutyCycleEncoder",
|
||||
"examples/ElevatorExponentialProfile",
|
||||
"examples/ElevatorExponentialSimulation",
|
||||
"examples/ElevatorProfiledPID",
|
||||
"examples/ElevatorSimulation",
|
||||
"examples/ElevatorTrapezoidProfile",
|
||||
"examples/Encoder",
|
||||
"examples/GettingStarted",
|
||||
"examples/Gyro",
|
||||
"examples/HatchbotInlined",
|
||||
"examples/HatchbotTraditional",
|
||||
"examples/MecanumBot",
|
||||
"examples/MecanumDrive",
|
||||
"examples/MecanumDrivePoseEstimator",
|
||||
"examples/Mechanism2d",
|
||||
"examples/RapidReactCommandBot",
|
||||
"examples/RomiReference",
|
||||
"examples/SimpleDifferentialDriveSimulation",
|
||||
"examples/StateSpaceArm",
|
||||
"examples/StateSpaceElevator",
|
||||
"examples/StateSpaceFlywheel",
|
||||
"examples/StateSpaceFlywheelSysId",
|
||||
"examples/SwerveBot",
|
||||
"examples/SwerveDrivePoseEstimator",
|
||||
"examples/SysId",
|
||||
"examples/TankDrive",
|
||||
"examples/TankDriveXboxController",
|
||||
"examples/UnitTest",
|
||||
"examples/XrpReference",
|
||||
]
|
||||
SNIPPET_PROJECTS = [
|
||||
"snippets/AddressableLED",
|
||||
"snippets/AprilTagsVision",
|
||||
"snippets/CANPDP",
|
||||
"snippets/DigitalCommunication",
|
||||
"snippets/DutyCycleInput",
|
||||
"snippets/EventLoop",
|
||||
"snippets/FlywheelBangBangController",
|
||||
"snippets/HttpCamera",
|
||||
"snippets/I2CCommunication",
|
||||
"snippets/IntermediateVision",
|
||||
"snippets/MotorControl",
|
||||
"snippets/QuickVision",
|
||||
"snippets/SelectCommand",
|
||||
"snippets/Solenoid",
|
||||
]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user