Skip to content

frc3322/Code-2026

Repository files navigation

Build Status: Build

Welcome to the very breif documentation on the 3322 Skyline Robotics team!

This MarkDown file will go over how the robot works in a very simple way and tell you how you can make your own. You can find more in-depth documentation in code-docs for the main robot systems and common issues

------------------------------- TOOL LINKS -------------------------------

FRC Game tools

MarkDown

  • Documentation: MD Docs
  • At least the docs I used for writing this

FRC PathPlanner

WPILib

Git

Github

Dependencies

  • AdvantageKit
  • CTRE-Phoenix (v6)
  • PathplannerLib
  • REVLib
  • Studica
  • WPILib-New-Commands

------------------------------- USING GIT/GITHUB -------------------------------

The use of tools like Git and Github is very important to productivity and cooporation.
In very basic terms, git connects our IDE to github and gives us source control

We'll start by explaining github seeing as that what we're connecting to, we should know what it does.
Github is cloud-based platform which allows us to store, write, read, and share code with others.
In git hub you can do a couple things including but not limited to: create/write/pull/push/delete repositories

Repositories are essentially containers for projects and inside of those are branches of code that store variations
When you select a repository you will see the main branch or the "README.md" depending on what you have access to
The main branch is where the most recent updated code is stored.
Other branches can be used to edit and test code before publishing to the main branch
To merge branches you would create a "pull request".

Cloning a repository is how we would create local clones of code that we can edit from an IDE
To clone a repository you would select the branch you want to clone and press the "<> Code" button
From there copy the HTTPS link and use your IDE to clone the repository branch.


Next we need to talk about git, this is crucial to pushing and pulling from/to github.
Git is a version control system, this allows us to see and revert back to pushed changes

Using git requires you to first have a github account.
To log into git you can follow the docs but I'll also add basic commands to the end of this section
We use git because it allows us to easily pull and push code from the IDE

Pulling code is the process of getting, reading and updating your code from the repository and your local files
Pushing code is when you update the repository code with code from your local files
general practice is to pull before you push to prevent merge conflicts

Fetch will check the recent changes made to the repository you're connected to without pulling Checkout will allow you to change the branch of the repository you're connected to

You can use these commands in the IDE source control menu

Git Commands:
git config user.name my-name
git config user.email my-email

------------------------------- BASIC SUBSYSTEM -------------------------------

Creating a subsystem requires a ~6 files

  1. Subsystem
    • The main subsystem class and contains commands, methods, etc.
    • Passed into the robot container and autons
  2. Constants
    • It has constants that we tune
  3. IO Interface
    • The abstraction layer
    • Allows use to switch between Sim and Real easily
  4. Subsystem Real
    • The code that runs parts on the robot such as motors
  5. Subsystem Sim
    • The code that runs parts on the simulation
  6. Subsystem Visual
    • Visualizes the movement of parts during simulation

The basic flow of code during processing and running goes as such
Subsystem -> IO -> Real/Sim

Logged information is setup in IO and changed throughout the rest of the code
Updating logs so we can edit, read, and use is done in the Subsystem Main

The IO contains a sort of skeleton of the real/sim which holds no data but is used for overwriting
Logged information is held in the IO as "inputs" which other files manipulate

The Real/Sim files hold code for the parts of the robot and movement logic
You can add motors, encoders, pneumatics, etc. to the Real/Sim files

Need a more in-depth answer? Read code-docs/Subsystem-Integration!

------------------------------- ROBOT CONTAINER -------------------------------

The robot container (Found at `src\main\java\frc\robot\RobotContainer.java`) contains all the logic for running the robot
If you need to add a controller, auton, new subsystem, etc. go to the robot container

To allow the code to differentiate between the real robot and the simulation we use a file
src\main\java\frc\robot\Constants.java
This file works with the robot container to allow for the easy switching between the two

The robot container also contains, initializes, and manages the subsystems
The controller objects created in robot container are used to run commands created on subsystems

This can include something like

private final CommandXboxController controller = new CommandXboxController(0);
private final Climber climber;

// Climber initialization is not in this example, sorry
// For more answers you can read the files to get examples

controller.povUp().onTrue(climber.setClimberStateCommand(ClimberPneumaticState.UP));
controller.povDown().onTrue(climber.setClimberStateCommand(ClimberPneumaticState.DOWN));

------------------------------- MAKING COMMANDS -------------------------------

We use commands in our subsystems for a multitude of things
Each of these commands can be used for a variety more than listed below

If you want to know the

  1. Instant Commands

    • Run a line of code once and end
    • Used mostly for stateswitching
    • Can be used in pathplanner (See also. code-docs/Auton.md)
  2. Run Commands

    • Runs a line of code until otherwise told to stop
    • Used for things that don't use states
    • Cannot be used in pathplanner
  3. Wait Commands

    • A command that waits
    • Used for manual pathplanner in src\main\java\frc\robot\Autons.java
  4. Null Commands

    • An empty command
    • Used for manual pathplanner in src\main\java\frc\robot\Autons.java

If you don't know how to make a command here are some examples!

Instant Command

// A boolean value stored that we will change
private example = true;

public Command instantCommandExample(boolean exampleParameter) {
    // "()->" is called a lambda, it allows us to add commands to a parameter
    // "This" is referencing the subsystem the command is built in
    return new InstantCommand(()-> this.example = exampleParameter, this);
}

Run Command

// A boolean value stored that we will change
private example = true;

public Command runCommandExample(boolean exampleParameter) {
    // "()->" is called a lambda, it allows us to add commands to a parameter
    // "This" is referencing the subsystem the command is built in
    return new RunCommand(()-> this.example = exampleParameter, this);
}

------------------------------- MAKING AUTONS -------------------------------

Making a robot doesn't only mean it runs with a controller, it also needs to run autonomously
To accomplish a goal like this we can use an application called PathPlanner

(code-docs\DocumentationImages\PathPlannerMainScreen.png)

To the left are the paths, they tell the robot where to go
The paths can constrain robot speed, force a rotational direction, send event signals

To the right are the autons, they can be one or more paths connected together
Autons are what the robot follows when you start autonomous mode

(code-docs\DocumentationImages\PathPlannerAutonCommandList.png)

When making an auton you can add a list of commands which are created in RobotContainer
These commands tell the robot what to do during the auton so you can play the game

(See also. The section on robot container)

PathPlanner paths are very specific which can make it hard to predict exactly what will happen
That is why we also have dynamic path planning set up!

Dynamic pathplanning is a lot like regular pathplanning but it uses only code
This pathplanning allows us to move the robot from any location to a specific one
To set it up we need a new file called Autons.java
In Autons.java We set up the following lines of code

    private Command pathfindToPose(Double TargetX, Double TargetY, Double RotationInDegrees) {
        Pose2d targetPose2d = new Pose2d(TargetX, TargetY, Rotation2d.fromDegrees(RotationInDegrees));

        PathConstraints pathConstraints = new PathConstraints(
            3.0, 
            4.0, 
            Units.degreesToRadians(540), Units.degreesToRadians(720));

        Command pathFindingCommand = AutoBuilder.pathfindToPose(targetPose2d, pathConstraints);

        return pathFindingCommand;
    }

With this we can create a basic auton that uses this command and sends in the position it wants to move to

In the current code, helper auton actions are registered as PathPlanner named commands in RobotContainer
The main dashboard auto chooser still comes from PathPlanner via AutoBuilder.buildAutoChooser()

    NamedCommands.registerCommand("ToClimbFromLocation", autons.ClimbFromLocation());

------------------------------- DOCUMENTATION -------------------------------

Don't know how a subsystem works? Got an issue you need help fixing? Check the `code-docs`!
The `code-docs` contains information on the main robot systems and common issues.

If you have an issue, you might find a solution in code-docs/CommonIssues.md!

Take a look at code-docs/Auton.md or code-docs/intake.md!

Now this! points towards robot This is a robot!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors