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

Fill READMEs with helpful(?) information #31

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
64d95b1
Update READMEs
anivanchen Apr 6, 2022
1378542
Update limelight README
anivanchen Apr 6, 2022
2cb2fbd
More READMEs and fix typo
anivanchen Apr 6, 2022
35d74f5
MORE READMEs
anivanchen Apr 6, 2022
6871ae1
Start Controls README
anivanchen Apr 6, 2022
6f00594
Update READMEs
anivanchen Apr 6, 2022
9cdc309
Update limelight README
anivanchen Apr 6, 2022
a425c4d
More READMEs and fix typo
anivanchen Apr 6, 2022
955281a
MORE READMEs
anivanchen Apr 6, 2022
cd2ae28
Start Controls README
anivanchen Apr 6, 2022
f78dd0b
Merge branch 'ic/readme-marathon' of https://github.com/stuypulse/stu…
anivanchen Apr 6, 2022
c0762a5
Update READMEs
anivanchen Apr 6, 2022
bf6ba94
Update limelight README
anivanchen Apr 6, 2022
cf4f56e
More READMEs and fix typo
anivanchen Apr 6, 2022
6f4414b
MORE READMEs
anivanchen Apr 6, 2022
ab8ee05
Start Controls README
anivanchen Apr 6, 2022
e3e7c51
Merge branch 'ic/readme-marathon' of https://github.com/stuypulse/stu…
anivanchen Apr 7, 2022
9a991a9
Update READMEs
anivanchen Apr 7, 2022
358cdb9
Update readme.md
anivanchen Apr 7, 2022
5bafd52
Merge branch 'ic/readme-marathon' of https://github.com/stuypulse/stu…
anivanchen Apr 7, 2022
8be77bc
Update control readme
anivanchen Apr 8, 2022
40f48de
Merge branch 'main' into ic/readme-marathon
Sam-Belliveau Aug 23, 2022
be9ff15
Merge branch 'main' into ic/readme-marathon
Sam-Belliveau Aug 23, 2022
6b96d41
Merge branch 'main' into ic/readme-marathon
Sam-Belliveau Aug 23, 2022
7bab963
Merge branch 'main' into ic/readme-marathon
Sam-Belliveau Aug 23, 2022
2382e90
Merge branch 'main' into ic/readme-marathon
Sam-Belliveau Aug 23, 2022
d9c2ab3
Merge branch 'main' into ic/readme-marathon
Sam-Belliveau Aug 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/com/stuypulse/stuylib/control/PIDCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* This is a Bang-Bang controller that while controlling the robot, will be able to calculate the
* values for the PID controller. It does this by taking the results of oscillations, then creating
* a PIDController withe the correct values once the oscillations have been measured.
* a PIDController with the correct values once the oscillations have been measured.
*
* @author Sam ([email protected])
*/
Expand Down
30 changes: 27 additions & 3 deletions src/com/stuypulse/stuylib/control/readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
# StuyLib Control Algorithms
# StuyLib Control Algorithms Library

WPI...
The Control Algorithms library contains various control algorithms which are commonly used in robotics such as [PID](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDController.java) or [Bang Bang](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/BangBangController.java). They are intuitively programmed and handles the complex mathematics behind each algorithm for the programmer, allowing for beginners to use PID in their control systems. However, it is HIGHLY recommended to have a concrete understanding of what you are using as they require tuning.

## What is control theory?

Control theory is the application of mathematics to predict and analyze the behavior of systems and make them responsive and robust to external forces. We apply control theory to the systems we design to make them meet our expected output and behavioral specifications.

## Why is `Number` used over `double`

This is to allow for the use of [SmartNumber](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartNumber.java), which extends `Number`. This makes things like configuring PID values significantly easier, as they can be instantly hooked into SmartDashboard without any configuration.
This is to allow for the use of [SmartNumber](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartNumber.java), which extends `Number`. This makes things like configuring PID values significantly easier, as they can be instantly hooked into SmartDashboard without any configuration.

### [Controller](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/Controller.java)

The [Controller](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/Controller.java) abstract class is used to create controllers and includes functions which makes controller implementations easier.

### [BangBangController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/BangBangController.java)

A [BangBangController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/BangBangController.java) goes forward at full force when the error is positive and backwards at full force when the error is negative.

### [PIDCalculator](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDCalculator.java)

[PIDCalculator](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDCalculator.java) is a Bang-Bang controller which can be used to calculate the values for the [PIDController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDController.java). It creates a [PIDController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDController.java) with correct values as oscillations occur.

### [PIDController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDController.java)

[PIDController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/PIDController.java) is an implementation of a PID controller. Our implementation features an intergral reset every time the error reaches 0 to prevevnt integral lag. Setups involving rate may not be suitable for this controller.

### [TBHController](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/control/TBHController.java)

A "take back half" controller which increases the speed until it goes over the reference, then decreases the speed by half and repeats the process until the error reaches 0.
2 changes: 1 addition & 1 deletion src/com/stuypulse/stuylib/input/Gamepad.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import edu.wpi.first.wpilibj2.command.button.Button;

/**
* An class for using gamepads with different interfaces. You can implement this class in another
* A class for using gamepads with different interfaces. You can implement this class in another
* file, and then use it with a standard interface.
*
* <p>Any unimplemented buttons will never be triggered, so if a certain controller is missing one,
Expand Down
30 changes: 29 additions & 1 deletion src/com/stuypulse/stuylib/input/gamepads/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# StuyLib Gamepad Implementations

WIP...
Implementations of various gamepads used in FRC robotics.

### [AutoGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[AutoGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java) detects the gamepad you are using and uses this to determine which gamepad implementation to return for your connected gamepad. It is used to prevent wrong values from being read from your gamepad due to your code believing you are using a different type than the one you are using.

### [Logitech](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[Logitech](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java) is the implementation of the Logitech gamepad, which has an X and D mode.

### [PS4](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[PS4](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java) is the implementation of the PS4 gamepad.

### [Xbox](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[Xbox](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java) is the implementation of the Xbox gamepad.

### [KeyGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[KeyGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java) manages the keymapping for keyboard gamepads.

### [NetKeyGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[NetKeyGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)takes in keyboard inputs and maps them to a gamepad to simulate a gamepad, despite using a keyboard as an input medium.

### [SimKeyGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java)

[SimKeyGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java) opens a window which accepts keyboard / trackpad inputs within the window and maps them to a gamepad to simulate one. It is meant to be used in the robot simulation and will not work on an actual robot, except the [Romi](https://github.com/StuyPulse/StuyRomi) which utilizes the simulator for control.
14 changes: 13 additions & 1 deletion src/com/stuypulse/stuylib/input/keyboard/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# StuyLib Network Keyboard

WIP...
Network keyboards can be used as input devices to trigger commands during testing, especially when running simulations or the [Romi](https://github.com/StuyPulse/StuyRomi).

### [NetKeyboard](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyboard.java)

[NetKeyboard](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyboard.java) implements and simplifies interactions with keyboard information through a network table.

### [NetKeyListener](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyListener.java)

[NetKeyListener](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyListener.java) listens for and uploads keyboard events to the keyboard network table.

### [NetKeyWindow](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyWindow.java)

[NetKeyWindow](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyWindow.java) opens a Java AWT window and simulates a keyboard with a [NetKeyListener](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/NetKeyListener.java) which can be used to control a robot.
20 changes: 18 additions & 2 deletions src/com/stuypulse/stuylib/input/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# StuyLib Gamepad Library
# StuyLib Input Library

WIP...
The Input library contains classes which simplifies gamepad / keyboard input and standardizes the way input is handled and retrieved.

To learn about specific gamepads, [read here](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/gamepads/readme.md).

To learn about keyboard input, [read here](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/keyboard/readme.md).

### [Gamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/Gamepad.java)

[Gamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/Gamepad.java) is a class which standardizes the gamepad interface. It does not do anything by itself and must be extended by other gamepads.

### [GamepadState](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/GamepadState.java)

[GamepadState](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/GamepadState.java) stores the state of a [`Gamepad`](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/Gamepad.java) separated by the different buttons and axis. Yet to be implemented, it can be used to "record" and "play back" gamepad input.

### [SPIGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/WPIGamepad.java)

The [SPIGamepad](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/input/WPIGamepad.java) class adds functions which make interactions with WPILib's `Joystick` class simpler.
18 changes: 9 additions & 9 deletions src/com/stuypulse/stuylib/math/readme.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# StuyLib Math Library

## What is the point of these classes
The Math library in StuyLib contains helpful utilities that make FRC programming easier and cleaner.

### [SLMath](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/SLMath.java)

SLMath is just a class with some static math functions that are useful in robotics.
SLMath is a class with static math functions that are useful in robotics.

For example, when squaring a number, `SLMath.square(x)` will keep the sign of the number. *this is used when filtering controller inputs* `SLMath.pow(x, p)` will also keep the sign of x no matter what the value of x or p. This might not seem useful normally, but is nice to have in FRC.
For example, when squaring a number, `SLMath.square(x)` will keep the sign of the number. *This is used when filtering controller inputs.* `SLMath.pow(x, p)` will also keep the sign of `x` no matter what the value of `x` or `p`. This might not seem useful normally, but is nice to have in FRC.

Other functions like `SLMath.limit` or `SLMath.deadband` are super helpful in FRC.

### [Vector2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java)
### [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java)

This is just a standard Vector2D class that has every feature you would need, and also works with our other classes in Stuylib. It also works nicely with our [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Angle.java) class, which is a nice bonus.
This is an [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java) class that removes the confusion about degrees and radians, and works nicely with our [Vector2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java). When doing math with the [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java) class, you do not need to worry about the value of the angle being outside the range of `-pi < x < pi`.

### [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java)
### [Vector2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java)

This is an angle class that removes the confusion about degrees / radians, and works nicely with our [Vector2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java). When doing math with the angle class, you do not need to worry about the value of the angle being outside the range of `-pi < x < pi`.
The [Vector2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java) class contains features that cover common coordinate vector manipulation needs, and also works with other classes in StuyLib. It also works nicely with the [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Angle.java) class.

## Summary
### [Polar2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Polar2D.java)

This Math folder in stuylib contains some helpful utilities that make programming FRC code a little bit easier.
The [Polar2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Polar2D.java) class contains features that cover common polar vector manipulation needs. It is heavily dependant on the [Angle](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Angle.java) and [Vector2D](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/math/Vector2D.java) classes.
33 changes: 32 additions & 1 deletion src/com/stuypulse/stuylib/network/limelight/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# StuyLib Limelight Library

WIP...
The Limelight Library allows the programmer to interface with the Limelight's network table. It allows for cleaner code which would be used for robot functions such as alignment for shooting or target acquisition.

### [Limelight](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/limelight/Limelight.java)

[Limelight](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/limelight/Limelight.java) allows you to check the status of the limelight and get raw data from the limelight, along with data regarding the target, and utilize the returned data in manipulating the robot to align with a target. It also features low level control over the various elements of the Limelight's pipeline such as `LEDMode`.

Example: To determine the distance of the limelight from the target...

```
double targetHeight = 96.0;
double limelightHeight = 38.7;
double limelightPitch = 27.0;
double heightDifference = targetHeight - limelightHeight;

public static boolean hasAnyTarget() {
return kLimelight.getValidTarget();
}

public static Angle getYAngle() {
if (hasAnyTarget()) {
return Angle.fromDegrees(kLimelight.getTargetYAngle() + limelightPitch);
}
return Angle.kZero;
}

public static double getDistance() {
if (hasAnyTarget()) {
return heightDifference / getYAngle().tan();
}
return Angle.kZero;
}
```
48 changes: 47 additions & 1 deletion src/com/stuypulse/stuylib/network/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# StuyLib Robot Networking Library

WIP...
The Robot Networking Library simplifies user interaction with the APIs of various network elements of FRC Robotics such as NetworkTables / SmartDashboard or the Limelight.

## Usage

Say we wanted to insert values into SmartDashboard which we could use to control a motor, either in code or on SmartDashboard, we could write:
```
SmartNumber MOTOR_SPEED = new SmartNumber("Conveyor/Motor Speed", 1.0);
SmartBoolean MOTOR_DISABLED = new SmartBoolean("Conveyor/Disabled", false)
```

By creating a new SmartNumber, we can now adjust the speed of the motor using SmartDashboard during testing. In addition, we can toggle the reject function of the motor through SmartDashboard or by manipulating the SmartBoolean value through code. Using SmartDashboard to store values allow for them to be "centralized" and more easily accessible throughout the program.

For example, if we wanted to disable a motor:
```
if (shouldDisableMotor()) {
Settings.Subsystem.MOTOR_DISABLED.set(true);
}
```
If we want to run a motor:
```
if (hasBall()) {
motor.set(Settings.Subsystem.MOTOR_SPEED.get())
}
else {
motor.stopMotor()
}
```

### [Limelight](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/limelight/readme.md)

Read the limelight [`readme.md`](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/limelight/readme.md) to learn more.

### [SLNetworkTable](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SLNetworkTable.java)

[SLNetworkTable](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SLNetworkTable.java) is used to easily interface with a network table. It can be used to get or set values on the network table.

### [SmartBoolean](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartBoolean.java)

[SmartBoolean](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartBoolean.java) is a wrapper of the SmartDashboard API for manipulating `boolean` values on SmartDashboard.

### [SmartNumber](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartNumber.java)

[SmartNumber](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartNumber.java) is a wrapper of the SmartDashboard API for manipulating `double` values on SmartDashboard. Their values can be the returned, casted as a `double`, `float`, `int`, or `long`.

### [SmartString](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartString.java)

[SmartString](https://github.com/StuyPulse/StuyLib/blob/main/src/com/stuypulse/stuylib/network/SmartString.java) is a wrapper of the SmartDashboard API for manipulating `String` values on SmartDashboard.
Loading