-
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.
Merge pull request #98 from Galaxia5987/dev
Merge to main
- Loading branch information
Showing
15 changed files
with
636 additions
and
26 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
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 was deleted.
Oops, something went wrong.
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,84 @@ | ||
package frc.robot.lib.motors | ||
|
||
import edu.wpi.first.math.MathUtil | ||
import edu.wpi.first.units.Units | ||
import edu.wpi.first.units.measure.Distance | ||
import edu.wpi.first.wpilibj.Servo | ||
import edu.wpi.first.wpilibj.Timer | ||
import edu.wpi.first.wpilibj2.command.button.Trigger | ||
|
||
/** | ||
* Parameters for L16-R Actuonix Linear Actuators | ||
* | ||
* @param channel PWM channel used to control the servo | ||
* @param length max length of the servo [mm] | ||
* @param speed max speed of the servo [mm/second] | ||
*/ | ||
class LinearServo( | ||
channel: Int, | ||
length: Int, | ||
speed: Int, | ||
positionTolerance: Double | ||
) : Servo(channel) { | ||
private var speed: Double | ||
private var length: Double | ||
private var setpoint = 0.0 | ||
private var position = 0.0 | ||
private var lastTime = 0.0 | ||
|
||
/** | ||
* Miniature Linear Servo Actuators - User Guide (Rev 1) Page 10Table of | ||
* Contentswcproducts.com Run this method in any periodic function to update | ||
* the position estimation of your servo | ||
* | ||
* @param setpoint the target position of the servo [mm] | ||
*/ | ||
override fun setPosition(setpoint: Double) { | ||
this.setpoint = MathUtil.clamp(setpoint, 0.0, length) | ||
setSpeed((this.setpoint / length * 2.0) - 1.0) | ||
} | ||
|
||
fun setPosition(setpoint: Distance) { | ||
Check notice on line 41 in src/main/kotlin/frc/robot/lib/motors/LinearServo.kt
|
||
setPosition(setpoint.`in`(Units.Millimeters)) | ||
} | ||
|
||
init { | ||
setBoundsMicroseconds(2000, 0, 0, 0, 1000) | ||
this.length = length.toDouble() | ||
this.speed = speed.toDouble() | ||
} | ||
|
||
/** | ||
* Run this method in any periodic function to update the position | ||
* estimation of your servo | ||
*/ | ||
fun updatePosition() { | ||
val dt = Timer.getFPGATimestamp() - lastTime | ||
if (position > setpoint + speed * dt) { | ||
position -= speed * dt | ||
} else if (position < setpoint - speed * dt) { | ||
position += speed * dt | ||
} else { | ||
position = setpoint | ||
} | ||
} | ||
|
||
/** | ||
* Current position of the servo, must be calling | ||
* [updatePosition()][.updatePosition] periodically | ||
* | ||
* @return Servo Position [mm] | ||
*/ | ||
override fun getPosition(): Double { | ||
return position | ||
} | ||
|
||
/** | ||
* Checks if the servo is at its target position, must be calling | ||
* [updatePosition()][.updatePosition] periodically | ||
* @return true when servo is at its target | ||
*/ | ||
val reachedSetpoint = Trigger { | ||
MathUtil.isNear(setpoint, position, positionTolerance) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,38 +1,61 @@ | ||
# Autonomous Specifications | ||
|
||
## Linked waypoints | ||
|
||
- `Lower position`: Lower starting position | ||
- `Intake line start` | ||
- `Intake line end` | ||
|
||
## Paths | ||
|
||
- `Intaking zone to high position` | ||
- Drive from the intaking zone, pick up a cone, wait for a second, and drive close to the second alliance's loading zone. | ||
 | ||
- Special constraints (if relevant) | ||
- Near loading zone: decrease speed so the red dragon won't notice us. | ||
 | ||
- Drive from the intaking zone, pick up a cone, wait for a second, and drive close to the second alliance's loading | ||
zone. | ||
 | ||
- Special constraints (if relevant) | ||
- Near loading zone: decrease speed so the red dragon won't notice us. | ||
 | ||
- Another one... | ||
|
||
## Autos | ||
|
||
- `Intaking zone to high position while shooting` | ||
- Uses `Intaking zone to high position` path | ||
- Shoots after passing the second waypoint, near the Charge Station | ||
 | ||
- Uses `Intaking zone to high position` path | ||
- Shoots after passing the second waypoint, near the Charge Station | ||
 | ||
- Another one... | ||
|
||
# Choosers | ||
> Could be as simple as "Using PathPlanner's built-in chooser" (BTW use [this](https://www.chiefdelphi.com/t/pathplanner-2024-beta/442364/149?u=dan)) or more complex based on the game, like what's been done [here](https://www.chiefdelphi.com/t/frc-6328-mechanical-advantage-2023-build-thread/420691/179#autos-the-questionnaire-2): | ||
|
||
> Could be as simple as "Using PathPlanner's built-in chooser" (BTW | ||
> use [this](https://www.chiefdelphi.com/t/pathplanner-2024-beta/442364/149?u=dan)) or more complex based on the game, | ||
> like what's been | ||
> | ||
done [here](https://www.chiefdelphi.com/t/frc-6328-mechanical-advantage-2023-build-thread/420691/179#autos-the-questionnaire-2): | ||
|
||
## Side chooser | ||
|
||
Choose which side the robot's on: | ||
|
||
- Left | ||
- Center | ||
- Right | ||
|
||
## Game piece chooser | ||
|
||
Choose which game piece type the robot is preloaded with: | ||
|
||
- Cube | ||
- Cone | ||
|
||
## State machine | ||
|
||
> Mermaid state graph which shows which auto to run based on the chooser goes here. | ||
# Dashboard | ||
> Include here fields that will be sent over NetworkTables and shown to the drivers during the autonomous period of the match. | ||
|
||
> Include here fields that will be sent over NetworkTables and shown to the drivers during the autonomous period of the | ||
> match. | ||
- Robot location: `Robot/Odometry` | ||
- Time left until teleop starts: `Robot/TimeLeftUntilTeleop` |
Oops, something went wrong.