This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
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
Showing
2 changed files
with
17 additions
and
13 deletions.
There are no files selected for viewing
24 changes: 13 additions & 11 deletions
24
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/api/Drone.kt
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,30 +1,32 @@ | ||
package org.firstinspires.ftc.teamcode.api | ||
|
||
import com.qualcomm.robotcore.eventloop.opmode.OpMode | ||
import com.qualcomm.robotcore.hardware.Servo | ||
import org.firstinspires.ftc.teamcode.utils.RobotConfig | ||
import com.qualcomm.robotcore.hardware.DcMotor | ||
import com.qualcomm.robotcore.hardware.DcMotorSimple | ||
|
||
/** | ||
* An API to control the drone launcher. | ||
*/ | ||
object Drone : API() { | ||
private lateinit var pin: Servo | ||
private lateinit var droneLeft: DcMotor | ||
private lateinit var droneRight: DcMotor | ||
|
||
override fun init(opMode: OpMode) { | ||
super.init(opMode) | ||
|
||
this.pin = this.opMode.hardwareMap.get(Servo::class.java, "pin") | ||
this.droneLeft = this.opMode.hardwareMap.get(DcMotor::class.java, "droneLeft") | ||
this.droneRight = this.opMode.hardwareMap.get(DcMotor::class.java, "droneRight") | ||
|
||
this.resetPin() | ||
this.droneRight.direction = DcMotorSimple.Direction.REVERSE | ||
} | ||
|
||
/** Moves the pin to the open position, releasing the drone. */ | ||
fun releasePin() { | ||
this.pin.position = RobotConfig.Drone.OPEN_PIN | ||
fun spin() { | ||
this.droneLeft.power = 1.0 | ||
this.droneRight.power = 1.0 | ||
} | ||
|
||
/** Resets the pin to its default, closed, position. */ | ||
private fun resetPin() { | ||
this.pin.position = RobotConfig.Drone.CLOSE_PIN | ||
fun stop() { | ||
this.droneLeft.power = 0.0 | ||
this.droneRight.power = 0.0 | ||
} | ||
} |
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