Metadata-Version: 2.4
Name: lib_6107
Version: 2027.0.0.1
Summary: Python helper library focused on the CyberJagzz FRC Team 6107 robot requirements
Author-email: Chip Boling <chip@bcsw.net>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://cyberjagzz.org
Project-URL: Source, https://github.com/6107/frclib-6107
Project-URL: Documentation, https://github.com/6107/frclib-6107/tree/main/docs
Project-URL: Changelog, https://github.com/6107/frclib-6107/blob/main/CHANGELOG.md
Keywords: FRC,robot,robotpy,FIRST,Jemison,CyberJagzz,6107
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: wpilib>=2027.0.0a8
Requires-Dist: robotpy>=2027.0.0a8
Requires-Dist: robotpy-hal>=2027.0.0a8
Requires-Dist: robotpy-apriltag>=2027.0.0a8
Requires-Dist: robotpy-fields>=2027.0.0a8
Requires-Dist: robotpy-navx>=2027.0.0a1
Requires-Dist: robotpy-commands-v2>=2027.0.0a8
Requires-Dist: robotpy-cli>=2027.0.1b2
Requires-Dist: robotpy-rev>=2027.0.0a8
Requires-Dist: robotpy-cscore>=2027.0.0a8
Requires-Dist: pyntcore>=2027.0.0a8
Requires-Dist: phoenix6>=26.70.0a2
Requires-Dist: photonlibpy>=2026.3.4
Requires-Dist: limelightlib-python>=0.9.6
Requires-Dist: opencv-python>=4.10.0
Requires-Dist: cpy6107>=2027.0.0a8.post14
Dynamic: license-file

# frclib-6107

[![CI](https://github.com/6107/frclib-6107/actions/workflows/ci.yml/badge.svg)](https://github.com/6107/frclib-6107/actions/workflows/ci.yml)
[![Code Quality](https://github.com/6107/frclib-6107/actions/workflows/code-quality.yml/badge.svg)](https://github.com/6107/frclib-6107/actions/workflows/code-quality.yml)

Python helper library focused on the CyberJagzz FRC Team 6107 robot requirements

## Table of Contents

 * [Background and Intended Direction](#background-and-intended-direction)
 * [Key Interfaces](#key-interfaces)
 * [Commands](#commands)
   * [Drivetrain](#drivetrain)
   * [Vision](#vision)
   * [Pykit](#pykit)
 * [Subsystems](#subsystems)
   * [Gyro](#gyro)
   * [Pykit](#pykit-1)
   * [RPM](#rpm)
   * [Vision](#vision-1)
 * [Utilities](#util)

# 2026

This library is now targeting the 2027 FRC season. The 2026 season is over and the latest source can be found
in the 2026 branch. Since the RoboRio is still useful for practice and testing, I plan to continue to support
the 2026 version and provide improvements and bug fixes as needed.

# Background and Intended Direction

During the initial FRC python effort for the 2026 Rebuilt build-season, several useful
utilities were identified along with much common functionality between some subsystems. On top of this, the pykit module
had a few bugs identified and the source for pykit was brought into the Team's product code to allow for quick fixes
during competition.

All of this work was performed under the _**lib_6107**_ subdirectory of our
[2026 Rebuilt](https://github.com/6107/2026-Rebuilt) project, and now that build season
is over, it sure would be nice to pull this into a loadable module, clean up and document the interfaces, and get some
decent coverage under some sort of unit tests.

If this is successful, the hope is that the main robot-loadable source for 2026 and our
future robots is greatly reduced. Then reality hit. While a switch to SystemCore was known,
the deprecation and restructuring of the WPILib python implementation (robotpy) was not.
That restructuring was excessive and has caused a lot of work to be done to incorporate
the changes into our code. The good news is that the new structure is much better and
more efficient, but it will take time to shake out. The first work is being done in
simulation since the SystemCore is not yet available. As such, focus on the drivetrain and
logging/replay is the first priority.

Another key focus is to speed the periodic code by at least 25%. The current loop is taking
about 23 mS, and we need this under 20. While the new controller for 2027 will probably be
significantly faster, saving time to run new functionality (vision w/ dynamic collision
avoidance) will most likely take this time up.

# Key Interfaces

Below are the main areas (often subdirectories) contained in this project.

# commands

## drivetrain

## vision

# pykit

# subsystems

## gyro

## pykit

## rpm

## vision

# util

# Fast uv one-liners commands

Unit Tests:
```shell
uv sync                                                    # install dev dependencies first, if needed
uv run pytest                                              # tests only, no coverage
uv run pytest --cov=src/lib_6107 --timeout=30              # tests with coverage report with 30 second timeout
uv run pytest --cov=src/lib_6107 --cov-report=html --cov-report=term --cov-report=lcov # tests with coverage report in multiple formats
uv run pytest tests/pykit/test_logtracer.py --cov=src/lib_6107.pykit.logtracer   # one file
uv run pytest -n0 --cov=src/lib_6107                       # disable xdist parallelism, which can make coverage more reliable

```

Security via 'bandit':
```shell
uv sync                                                    # install dev dependencies first, if needed
uv run bandit -r src/lib_6107
```

# Planned Releases and Improvements

The first 'beta' release will be 2026.1.0.0 and will primarily be a move of the
current [2026-Rebuilt](https://github.com/6107/2026-Rebuilt) project into an installable module. Following that
_release_, the start of several improvements based on the prioritized list below. Note that priorities may change
without notice.

The format of the version number is _YYYY.MAJOR.MINOR.patch_. While the YYYY.MAJOR.MINOR portion is all zeros, expect
that this code is really very pre-alpha. Once it stabalizes and has a good portion of what I want, will begin to bump
the MINOR version up. Once it is **beta** or better quality, I will increment the MAJOR version. At that point, the
patch number will be used for bug fixes and minor improvements and the MINOR version will be used to indicate new
functionality. The MAJOR version will be used to indicate a significant change in the module that may require changes to
the robot code that uses this module.

|       Improvement       |      Task      | Description                                                                                                                                                  |
|:-----------------------:|:--------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <input type="checkbox"> |  build-part-2  | [automation] Support automated release via GitHub actions                                                                                                    |
| <input type="checkbox"> |  improvement  | Provide _is_simulation() attribute in Robot, RobotContainer, and SubSystems base classes and clean up calls to RobotBase.is_simulation()                                                                                                    |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |   telemetry    | Add subsystems for the SystemCore, PDH so that we can do temperature and other telemetry logging                                                    |
| <input type="checkbox"> |   thread-safety    | Examine Section 2 of private 2027 Telemetry & Tunables tutorial and look into current code thread-safety. Also do a good scan for any thread-safety issues.                                                    |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |  performance   | [performance] Review existing code so far and address and areas for increasing code efficiency. Create items for the improvement                             |
| <input type="checkbox"> | fault handling | [fault handling] Review existing code so far and address and areas for increasing code stability and recovery.C reate items for the improvement              |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |    CTRE/REV    | Provide customized/customizable subsystem support for CTRE and Rev Robotics based subsystems                                                                 |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |   pykit meta   | Support subsystem metadata. Auto-save firmware versions, model numbers, vendor info, and other status we can scrap from devices and their APIs.              |
| <input type="checkbox"> | canbus logging | [telemetry] Support Canbus logging to pykit (option to disable via logged chooser)                                                                         |
| <input type="checkbox"> |  system logging  | [telemetry] akit has LoggedSystemStats. Convert over and use that to centralize the system related stuff|
| <input type="checkbox"> |  other logging  | [telemetry] Besides canbus, examine built-in telemetry new 2027 classes and refactoring. Search for "in robotpy frc 2027 code, do some of the classes have built in telemetry"|
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> | Performance  | Use pyspy and other techniques to figure out what areas need to be optimized. We know that telemetry/logging/pykit which is so central is a good candidate.                                                                                                                  |
| <input type="checkbox"> |  c/c++ bindings  | [Performance] Use pybind/nanobind or other techniques to move some code into c/c++. Look at what akit did in 2026 and later in 2027 sesson for ideas. Also use previous Performance task for other candidates.                                                                                                         |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |  vision sim 1  | Support vision simulation (PhotonVision)                                                                                                                     |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |    example     | Create an example project that can be used by other to examine how to use this module.<br/>Also may be able to use it in some automated unit-tests.          |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |  vision sim 2  | Support vision simulation (Limelight)                                                                                                                        |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> | unit-test-80%  | Reach at least 80% or better unit-test coverage                                                                                                             |
| <input type="checkbox"> | unit-test-90%  | Reach at least 90% or better unit-test coverage                                                                                                              |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |     autolog      | [telemetry] look at supporting autolog decorators. I currently do not use them |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |     pkit receiver thread      | [nice to have] akit has ReceiverThread. Can also support that|
| <input type="checkbox"> |     conduit API      | [nice to have] akit has a ConduitAPI to streamline and flatten snapshots. Can this help us|
| <input type="checkbox"> |     opmode robot      | [nice to have] 2027 WPILIB introduces an OpModeRobot class. Is this useful or can we pull in good ideas from it for our own C++ based LoggedRobot |
| <input type="checkbox"> |     radio logger      | [nice to have] akit has a radio logger|
| <input type="checkbox"> |     3rd party loggers      | [nice to have] akit can log Rev log messages, can we do that with Rev and/or CTRE as well?|
| <input type="checkbox"> |     GC Statistics      | [nice to have] akit has a GC stats collector (see Logger class)|
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |     tools      | Generate a list of possible tools to improve or automate some of the steps we go through                                                                     |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |   thread-safety    | Part 2: Examine Section 2 of private 2027 Telemetry & Tunables tutorial and look into current code thread-safety. Also do a good scan for any thread-safety issues.                                                    |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |  log exporter  | [tools] Auto-log export into a database (mongodb?)<br/>Include additional match/circumstance type metadata and have settable via UI.                         |
| <input type="checkbox"> |      otel      | [tools] [performance] OpenTelemetry support investigation                                                                                                    |
| <input type="checkbox"> |    elastic     | [example] In the 'example' robot project.<br/>Include an _elastic_ JSON layout file that shows how some of the module NT4 data can be displayed/manipulated. |
| <input type="checkbox"> |       -        |                                                                                                                                                              |
| <input type="checkbox"> |    debugging     | If running on a non-windows platform, SIGUSR2 can be called to dump all of your current stacks. This can be really useful for figuring out things like deadlocks. |
| <input type="checkbox"> |       -        |                                                                                                                                                              |

**Completed Tasks **

|            Complete             | Release    |      Task       | Description                                                                                                                                 |
|:-------------------------------:|:-----------|:---------------:|:--------------------------------------------------------------------------------------------------------------------------------------------|
| <input type="checkbox" checked> | 2026.0.0.1 |  lib_2026 move  | Successful move into an installable module. Little or no added functionality                                                                |
|               ---               | ---------- |                 |                                                                                                                                             |
| <input type="checkbox" checked> | 2026.0.0.2 |   lint-part-1   | [automation] Support lint via Makefile                                                                                                      |
| <input type="checkbox" checked> | 2026.0.0.2 |  bandit-part-1  | [automation] Support bandit via Makefile                                                                                                    |
| <input type="checkbox" checked> | 2026.0.0.2 |     period      | Support an easy way to set/manipulate the period with the default being the 20 mS standard value                                            |
|               ---               | ---------- |                 |                                                                                                                                             |
| <input type="checkbox" checked> | 2026.0.0.3 |    constants    | Do constants better so initial value are in lib_6107 but easy to override by developers                                                     |
| <input type="checkbox" checked> | 2026.0.0.3 |   robot base    | Base class for the robot that is responsible for at least the initial logging setup and determining if this is a replay                     |
| <input type="checkbox" checked> | 2026.0.0.3 | simulation base | A base class for simulation (physics.py)                                                                                                    |
| <input type="checkbox" checked> | 2026.0.0.6 | subsystem base  | Base subsystem class that supports pykit, simulation, and sysId overridable methods                                                         |
| <input type="checkbox" checked> | 2026.0.0.7 | drivesubsystem  | A base subsystem for a drivetrain (focus on swerve initially)                                                                               |
| <input type="checkbox" checked> | 2026.0.0.7 |  build-part-1   | [automation] Support automated release via Makefile                                                                                         |
| <input type="checkbox" checked> | 2026.0.0.7 |   lint-part-2   | [automation] Support ruff via GitHub actions                                                                                                |
| <input type="checkbox" checked> | 2026.0.0.7 |      2027       | [guidance] Review what is changing in 2027 with new systemcore and create a plan to get rid of any deprecated items (Dashboard, ...)        |
| <input type="checkbox" checked> | 2026.0.0.7 | github copilot  | Investigate what github copilot may help us with                                                                                            |
| <input type="checkbox" checked> | 2026.0.0.7 | pykit unit-test | [fault handling] Get to >70% unit test coverage of pykit logging functionality<br/>Focus on performance measurements. Keep track of results |
| <input type="checkbox" checked> | 2026.0.0.7 |    ut-part-1    | [automation] Support unit-tests via makefile                                                                                                |
| <input type="checkbox" checked> | 2026.0.0.7 |    ut-part-2    | [automation] Support unit-tests via GitHub actions                                                                                          |
| <input type="checkbox" checked> | 2026.0.0.7 |  unit-test-10%  | Reach at least 10% or better unit-test coverage                                                                                             |
| <input type="checkbox" checked> | 2026.0.0.7 |  unit-test-30%  | Reach at least 30% or better unit-test coverage. Supports github action/workflow. AT 47% coverage                                           |
| <input type="checkbox" checked> | 2026.0.0.7 |   pykit slots   | [performance] Support @DataClass(slots=True) for pykit logging if it can help with performance                                              |
| <input type="checkbox" checked> | 2026.0.0.7 |  pykit asyncio  | [performance] Support asyncio or background threading in pykit to improve performance                                                       |
|               ---               | ---------- |                 |                                                                                                                                             |
| <input type="checkbox" checked> | 2027.0.0.1 |  bandit-part-2  | [automation] Support bandit via GitHub actions                                                                                              |
| <input type="checkbox" checked> | 2027.0.0.1 |  unit-test-50%  | Reach at least 50% or better unit-test coverage.                                                                                            |
| <input type="checkbox" checked> | 2027.0.0.1 | unit-test-70%  | Reach at least 70% or better unit-test coverage                                                                                                              |
| <input type="checkbox" checked> | 2027.0.0.1|  elastic   | [mgmt] any changes here to take into account.  Programatic or other access that will help us|

# NOTICE
As with many _FRC_ projects, the code in this module draws from many other repositories
belonging to different teams. As I begin to extract code and move it into this repo,
I hope to provide credit below. If I miss anyone, my apologies, it is not intentional.

Also, we use:
    - both Rev and CTRE motors
    - pathplanner
    - pykit
    - PhotonVision (and maybe Limelight soon)

So those modules will be downloaded if you install this module as well. Maybe a little
code bloat, but it should not be much of an impact in 2027 where this is being targeted.

## Westwood Robotics - 1757

- The original work on pykit and of course their robots tha provide good examples of how to use pykit

## Team 714

- Gene Panov's (Team 714) CommandRevSwerve project and so many good videos of how to use robotpy...
- Misc vision videos by other team members
