Skip to content

Claw Subsystem

Another common subsystem in FTC is a claw. Generally, a claw is powered by one servo, generally with open and closed positions.

This guide assumes you have already read the lift subsystem guide. Let's get started!

Step 1: Create your subsystem

Just like with the lift Subsystem, we need to start by creating our subsystem.

kotlin
object Claw : Subsystem {

}

Step 2: Create your servo

Now, since we're using a servo, instead of a motor, let's create a servo variable.

kotlin
private val servo = ServoEx("claw_servo")

Step 3: Create commands

Creating servo commands is very easy in NextFTC.

For servos, the command you will be using is SetPosition. You will pass your servo and a target position.

kotlin
val open = SetPosition(servo, 0.1).setSubsystems(this)

Nice! Let's do the same with the close command:

kotlin
val close = SetPosition(servo, 0.2).setSubsystems(this)

Final result

You've successfully created your claw subsystem! Here's the final result:

kotlin
object Claw : Subsystem {
    private val servo = ServoEx("claw_servo")

    val open = SetPosition(servo, 0.1).setSubsystems(this)
    val close = SetPosition(servo, 0.2).setSubsystems(this)
}