-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea5a19d
commit 3bbde97
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Callout } from "nextra/components"; | ||
|
||
# Gamepad | ||
|
||
There are two gamepads/drivers, `gamepad1` and `gamepad2`. We designate gamepad1`to the driver and`gamepad2` to subsystems. | ||
|
||
## Gamepad Usage | ||
|
||
```java | ||
if (gamepad1.a) { | ||
servo.setPosition(servo.getPosition()+0.1); | ||
} | ||
else if (gamepad1.b) { | ||
servo.setPosition(servo.getPosition()-0.1); | ||
} | ||
``` | ||
|
||
Handling boolean simply involves putting the gamepad boolean under an if statement inside the main loop. Note that the methods inside the if statement will continously run while the button is being held down, unless we use a rising edge detector. | ||
|
||
```java | ||
double y = -gamepad1.left_stick_y; | ||
motor.setPower(y); | ||
``` | ||
|
||
Float inputs are directly set to control hardware. | ||
|
||
## Rising Edge Detector | ||
|
||
A commonly used technique is a rising edge detector. It allows code to be run only once upon the initial button press rather than continuously while the button is held down. It verifies the button was not pressed in the previous loop but is pressed currently. | ||
|
||
```java | ||
// Usage | ||
if (currentGamepad1.a && !previousGamepad1.a) { | ||
servo.setPosition(servo.getPosition() + 0.1); | ||
} | ||
|
||
// Rising Edge Detector method | ||
public boolean risingEdgeDetect(boolean current, boolean previous) { | ||
return current && !previous; | ||
} | ||
``` | ||
|
||
<Callout type="info" emoji="ℹ️"> | ||
This is easily achieved through | ||
[FTCLib](https://docs.ftclib.org/ftclib/v/v2.0.0/features/gamepad-extensions#buttonreader). | ||
</Callout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# IMU | ||
|
||
## Orientation Parameters | ||
|
||
Initializing the IMU is a little different from normal hardware because you need to set the orientation of the IMU/Control Hub. You can read the FTC doc page on the IMU interface and the orientation parameters [here](https://ftc-docs.firstinspires.org/en/latest/programming_resources/imu/imu.html). | ||
|
||
```java | ||
imu = hardwareMap.get(IMU.class, "imu"); | ||
|
||
IMU.Parameters parameters = new IMU.Parameters(new RevHubOrientationOnRobot( | ||
RevHubOrientationOnRobot.LogoFacingDirection.UP, | ||
RevHubOrientationOnRobot.UsbFacingDirection.FORWARD)); | ||
imu.initialize(parameters); | ||
``` | ||
|
||
## Reading IMU | ||
|
||
For all axes, IMU angles are provided in the range of -Pi to +Pi radians which is -180 to +180 degrees. | ||
|
||
```java | ||
double Yaw = imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.RADIANS); | ||
double Pitch = imu.getRobotYawPitchRollAngles().getPitch(AngleUnit.RADIANS); | ||
double Roll = imu.getRobotYawPitchRollAngles().getRoll(AngleUnit.RADIANS); | ||
``` |