Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat(motors): implement all standard FRC motors #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Baconing
Copy link
Member

@Baconing Baconing commented Aug 21, 2024

This pull requests implements the following motors:

  • Spark Motor
  • TalonFXMotor
  • TalonSRXMotor
  • VictorSPXMotor

in addition to potential modifications to other motors.

Summary by CodeRabbit

  • New Features

    • Introduced the SparkMotor class for enhanced control over Spark motor controllers, including methods for speed adjustment, safety, and inversion management.
    • Added the TalonFXMotor class to simplify integration and control of TalonFX motor controllers, featuring flexible instantiation and various motor control methods.
  • Improvements

    • Clarified the purpose of the SparkMaxMotor class by updating its documentation and simplifying method visibility.

@Baconing Baconing added Kind/Enhancement Improve existing functionality Kind/Feature New functionality labels Aug 21, 2024
@Baconing Baconing requested a review from Trip-kun August 21, 2024 19:28
@Baconing Baconing self-assigned this Aug 21, 2024
@Baconing Baconing added this to the Version: 2025-1.0.0 milestone Aug 21, 2024
Copy link

coderabbitai bot commented Aug 21, 2024

Walkthrough

The recent changes introduce two new motor classes, SparkMotor and TalonFXMotor, enhancing the hardware abstraction layer for controlling Spark and TalonFX motor controllers. Additionally, the existing SparkMaxMotor class has been refactored to improve clarity and simplify method signatures. These modifications collectively streamline motor control operations, ensuring a more coherent interface for developers.

Changes

Files Change Summary
src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java Updated class documentation and refactored getRawMotor() method to return CANSparkMax directly, enhancing clarity and simplifying the method's visibility.
src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java Introduced SparkMotor class, implementing motor control methods and constructors for easy instantiation and access to the underlying Spark motor controller.
src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java Introduced TalonFXMotor class, wrapping TalonFX motor controller functionality while providing methods for control and direct access to the motor instance.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SparkMotor
    participant CANSparkMax

    User->>SparkMotor: setSpeed(speed)
    SparkMotor->>CANSparkMax: set(speed)
    CANSparkMax-->>SparkMotor: Confirm speed set
    SparkMotor-->>User: Speed set confirmation
Loading
sequenceDiagram
    participant User
    participant TalonFXMotor
    participant TalonFX

    User->>TalonFXMotor: setSpeed(speed)
    TalonFXMotor->>TalonFX: set(speed)
    TalonFX-->>TalonFXMotor: Confirm speed set
    TalonFXMotor-->>User: Speed set confirmation
Loading

Poem

🐰 In the garden of code, we hop with glee,
New motors added, how happy are we!
Spark and Talon, they dance and sing,
With speed and control, oh what joy they bring!
Through circuits and wires, our dreams take flight,
A robust dance of code, shining bright!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Baconing Baconing changed the base branch from master to dev August 21, 2024 19:29
@Baconing Baconing changed the base branch from dev to master August 21, 2024 19:29
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8883b9b and 3fc721b.

Files selected for processing (3)
  • src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java (2 hunks)
  • src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java (1 hunks)
  • src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java (1 hunks)
Additional context used
GitHub Check: pmd
src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java

[warning] 4-4: Unused import 'edu.wpi.first.wpilibj.motorcontrol.MotorController'
Reports import statements that can be removed. They are either unused,
duplicated, or the members they import are already implicitly in scope,
because they're in java.lang, or the current package.

If some imports cannot be resolved, for instance because you run PMD with
an incomplete auxiliary classpath, some imports may be conservatively marked
as used even if they're not to avoid false positives.

UnnecessaryImport (Priority: 4, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.4.0/pmd_rules_java_codestyle.html#unnecessaryimport

Additional comments not posted (4)
src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java (1)

1-62: LGTM!

The SparkMotor class is well-implemented, providing essential motor control functionalities. The constructors and methods are clear and follow best practices. Ensure that unit tests cover all functionalities.

src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java (1)

1-63: LGTM!

The TalonFXMotor class is well-implemented, providing essential motor control functionalities. The constructors and methods are clear and follow best practices. Ensure that unit tests cover all functionalities.

Tools
GitHub Check: pmd

[warning] 4-4: Unused import 'edu.wpi.first.wpilibj.motorcontrol.MotorController'
Reports import statements that can be removed. They are either unused,
duplicated, or the members they import are already implicitly in scope,
because they're in java.lang, or the current package.

If some imports cannot be resolved, for instance because you run PMD with
an incomplete auxiliary classpath, some imports may be conservatively marked
as used even if they're not to avoid false positives.

UnnecessaryImport (Priority: 4, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.4.0/pmd_rules_java_codestyle.html#unnecessaryimport

src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java (2)

12-12: Improved documentation.

The updated class documentation accurately reflects the purpose of the SparkMaxMotor class. This enhances the clarity of the code.


71-71: Simplified method signature.

The getRawMotor() method now directly returns a CANSparkMax instance, simplifying the method and aligning it with the class's purpose.

Copy link

@Trip-kun Trip-kun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I literally just saw this PR while browsing the org's new repos.
Overall the docs and everything is pretty good but I would consider adding "follow()" functionality into the motor system. The Phoenix API has it built in, I believe that Rev has a follow system as well, implemented differently. It's not strictly necessary but it can be nice to use the hardware-based following (especially for Phoenix-based motors, as I believe it can use daisy chaining and echoing to declog the CAN network instead of 2 separate streams)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind/Enhancement Improve existing functionality Kind/Feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants