Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.

Commit

Permalink
Add elevator subsystem (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
will-hou authored and SUPERCILEX committed Feb 2, 2018
1 parent 2ccf29e commit a2799e8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/main/java/org/sert2521/powerup/RobotName.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.sert2521.powerup

import org.sert2521.powerup.drivetrain.Drivetrain
import org.sert2521.powerup.elevator.Elevator
import org.sert2521.powerup.intake.Intake
import org.sertain.Robot

class RobotName : Robot() {
override fun onCreate() {
Drivetrain
Intake
Elevator
}
}
20 changes: 20 additions & 0 deletions src/main/java/org/sert2521/powerup/elevator/Elevator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.sert2521.powerup.elevator

import org.sert2521.powerup.elevator.commands.TeleopElevator
import org.sert2521.powerup.util.LEFT_ELEVATOR_MOTOR
import org.sert2521.powerup.util.RIGHT_ELEVATOR_MOTOR
import org.sertain.command.Subsystem
import org.sertain.hardware.Talon
import org.sertain.hardware.autoBreak
import org.sertain.hardware.plus

object Elevator : Subsystem() {
private val elevator =
Talon(LEFT_ELEVATOR_MOTOR).autoBreak() + Talon(RIGHT_ELEVATOR_MOTOR).autoBreak()

override val defaultCommand = TeleopElevator()

fun set(speed: Double) = elevator.set(speed)

fun stop() = elevator.stopMotor()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.sert2521.powerup.elevator.commands

import org.sert2521.powerup.elevator.Elevator
import org.sert2521.powerup.util.secondaryJoystick
import org.sertain.command.Command

class TeleopElevator : Command() {
init {
requires(Elevator)
}

override fun execute(): Boolean {
if (secondaryJoystick.trigger) Elevator.set(secondaryJoystick.y)
return false
}

override fun onDestroy() {
Elevator.stop()
}
}
9 changes: 6 additions & 3 deletions src/main/java/org/sert2521/powerup/util/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ const val SECONDARY_STICK_PORT = 2
const val CONTROLLER_PORT = 3

// Talon IDs
const val RIGHT_FRONT_MOTOR = 10
const val RIGHT_REAR_MOTOR = 14
const val LEFT_FRONT_MOTOR = 19
const val LEFT_REAR_MOTOR = 17
const val RIGHT_FRONT_MOTOR = 10
const val RIGHT_REAR_MOTOR = 14

const val RIGHT_INTAKE_MOTOR = 13
const val LEFT_INTAKE_MOTOR = 12
const val RIGHT_INTAKE_MOTOR = 13

const val LEFT_ELEVATOR_MOTOR = -1
const val RIGHT_ELEVATOR_MOTOR = -1

0 comments on commit a2799e8

Please sign in to comment.