3061 Lib v2024.0.0

Huskie Robotics, FRC Team 3061’s, starter project and library focused on a swerve-based drivetrain. Supports SDS MK4/MK4i swerve modules using 2 Falcon 500 motors and a CTRE CANCoder, a CTRE Pigeon Gyro, and REV Robotics power distribution hub and pneumatics hub. However, due to the hardware abstraction layer, this code can be adapted to other motor controllers, encoders, and gyros as well as different swerve module designs.

Is 3061-lib a Good Fit for Your Team?

  • If you just want to get your new serve drive up and running, there are less complicated options. For example, if you are using all Cross The Road Electronics hardware, you should use their Swerve Project Generator.
  • While 3061-lib has the potential to support Rev motors and sensors, that requires some work on your part. You may find AdvantageKit’s Swerve Drive Projects more helpful.
  • If your team is interested in incorporating the following features, 3061-lib may be a good fit for your team.

Features

  • multiple robots with different configurations, including a simulated robot with basic simulation of swerve modules
  • logging and replay via AdvantageKit
  • vision subsystem supporting multiple Photonvision-based cameras to update pose estimation
  • move-to-pose command that generates on-the-fly paths using a field model defined by a set of regions and transition points between regions
  • CAN FD (CANivore) to reduce CAN bus utilization
  • monitoring and reporting of hardware faults
  • integrated system tests
  • commands
    • drive-to-pose (closed-loop straight-line motion to pose)
    • rotate-to-angle (closed-loop rotational setpoint with optional driver-controlled translational motion)
  • swerve-specific features
    • robot-relative and field-relative driving modes
    • slow mode for fine-tuned motion
    • acceleration limiting when not in “turbo” mode
    • current limiting configuration for motors
    • x-stance
    • leave wheels rotated in last direction when not driving to enable smooth continuation of motion
    • switch drive motors to coast mode when robot is disabled and has stopped moving for a period of time to facilitate manual pushing

3061 Lib v2024.0.0

This is our initial release for the 2024 Crescendo season based on 2024 software components.

We will continue to develop, test, and tune 3061-lib for a couple of weeks before moving to the frc-software-2024 repository, which is also publicly accessible. The intention is that 3061-lib contains features that may be relevant to any FRC game, while frc-software-2024 will contain features specific to Crescendo.

The changes since the v2023.2.0 release are categorized by topic in rough order of significance.

Drivetrain Subsystem

  • these changes are in addition to the Phoenix 6 changes released in v2023.2.0
  • add Drivetrain subsystem with corresponding DrivetrainIO interface
  • add DrivetrainIOCTRE class which extends CTRE’s SwerveDrivetrain class in order to benefit from all their optimizations, including 250 Hz odometry updates
  • add DrivetrainIOGeneric class which can be customized for a variety of swerve motors, encoders, and gyros in the same manner as previous releases
  • update RobotOdometry to support another class managing the odometry (e.g., CTRE’s SwerveDrivetrain)

PhotonVision and PhotonLib

  • leverage PhotonVision’s new MULTI_TAG_PNP_ON_COPROCESSOR feature which replaces our custom multi-tag support that ran on the RIO

Static Field Origin

  • in a manner consistent with PathPlanner, the origin of the field will always be the corner to the right of the blue alliance driver station, regardless of which alliance we are
  • add 2024 Crescendo AprilTag file and update the Vision subsystem to use this file
  • add shouldFlipAutoPath method to Drivetrain class which is invoked by PathPlanner immediately before running an auto to flip the auto across the center of the field
  • update drive method of the Drivetrain class such that, in field-relative mode, pushing the joystick forward always moves the robot away from the driver and pushing the joystick left always moves the robot to the driver’s left
  • remove all code related to changing the field origin, which was the 2023 approach

Phoenix 6 Pro TorqueCurrentFOC

  • add getSwerveDriveControlMode and getSwerveSteerControlMode methods to RobotConfig. By default, these methods return SWERVE_CONTROL_MODE.VOLTAGE, which is the same control mode as supported previously.
  • Classes that implement RobotConfig may return TORQUE_CURRENT_FOC to that control mode for either steer or drive motors. We have config classes for both approaches at the moment as we are still testing and tuning this new control mode and don’t yet have the performance we expect. Keep in mind that the associated kS, kV, kA, kP, kI, kD values are different for these two control modes, which is why separate config classes are helpful.

Fault Reporter

  • update to detect missing CTRE devices with Phoenix 6 and report faults
  • add support for SparkMAX to FaultReporter

Serve Tuning

  • add a new “auto” to tune swerve rotation
  • log closed loop reference for swerve modules to facilitate tuning

API Changes

  • update to accommodate API changes in all dependencies (WPILib, AdvantageKit, PathPlanner, PhotonLib)

Highlighted Outstanding Issues

  • update FieldConstants and FieldRegionConstants classes for the 2024 field
  • add LED subsystem (needs more testing)
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.