Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Box Movement #36

Merged
merged 19 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
48 changes: 48 additions & 0 deletions TeamCode/src/main/java/org/firstinspires/ftc/teamcode/api/Box.kt
BD103 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.firstinspires.ftc.teamcode.api

import com.qualcomm.robotcore.eventloop.opmode.OpMode
import com.qualcomm.robotcore.hardware.Servo

object Box : API() {
BD103 marked this conversation as resolved.
Show resolved Hide resolved
private lateinit var boxL: Servo
private lateinit var boxR: Servo
private lateinit var grip: Servo

override fun init(opMode: OpMode) {
super.init(opMode)

this.boxL = this.hardwareMap.get(Servo::class.java, "boxL")
this.boxR = this.hardwareMap.get(Servo::class.java, "boxR")
BD103 marked this conversation as resolved.
Show resolved Hide resolved
this.grip = this.hardwareMap.get(Servo::class.java, "grip")
}

/**
* Moves the box to the ground
*/
fun dropBox() {
boxL.position = 0.5
boxR.position = 0.5
}

/**
* Moves box to upright position
*/
fun pickUpBox() {
boxL.position = 0.0
boxL.position = 0.0
}

/**
* Moves the grip to keep pixels in place when [pickUpBox] the box
*/
fun gripIn() {
grip.position = 0.2
}

/**
* Resets the grip to starting position
*/
fun gripOut() {
grip.position = 0.0
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.components

import com.qualcomm.robotcore.eventloop.opmode.OpMode
import org.firstinspires.ftc.teamcode.api.Box
import org.firstinspires.ftc.teamcode.api.TeleOpState
import org.firstinspires.ftc.teamcode.api.TriWheels
import kotlin.math.PI
Expand Down Expand Up @@ -43,10 +44,26 @@ object TeleOpMovement : Component {
var joyMagnitude = sqrt(joyY * joyY + joyX * joyX)

// if the right bumper is pressed move slower
BD103 marked this conversation as resolved.
Show resolved Hide resolved
if (gamepad.right_bumper) {
if (gamepad.y) {
joyMagnitude *= SLOW_MULTIPLIER
}

// Inputs for the gripper on the box
if (gamepad.left_bumper) {
Box.gripIn()
}
if (gamepad.right_bumper) {
Box.gripOut()
}
BD103 marked this conversation as resolved.
Show resolved Hide resolved

// Inputs for the movement of the box
if (gamepad.a) {
Box.dropBox()
}
if (gamepad.b) {
Box.pickUpBox()
}
BD103 marked this conversation as resolved.
Show resolved Hide resolved

// movement of all wheels
TriWheels.driveWithRotation(joyRadians, joyMagnitude, rotationPower)
}
Expand Down