Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Class RopeLift
Browse files Browse the repository at this point in the history
  • Loading branch information
RobotIGS-Building committed Sep 28, 2023
1 parent 91fb712 commit 9921f06
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.firstinspires.ftc.teamcode.Tools.Modules;

import com.qualcomm.robotcore.hardware.DcMotor;

public class RopeLift {
private DcMotor LiftMotor;
private int steps_min;
private int steps_max;
private int steps_sum;

public RopeLift() {
}

public void setPower(double power,boolean W) {
if (W)
LiftMotor.setPower(power);
else {
if (Math.max(LiftMotor.getCurrentPosition(), steps_min) == Math.min(LiftMotor.getCurrentPosition(), steps_max))
LiftMotor.setPower(power);
else
setTargetPosition(((LiftMotor.getCurrentPosition() > steps_max) ? steps_max : steps_min), power);
if (LiftMotor.getMode() != DcMotor.RunMode.RUN_USING_ENCODER)
LiftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
}
}
public void setTargetPosition(int steps, double v) {
steps_sum = (Math.min(steps_min + steps, steps_max));
LiftMotor.setTargetPosition(steps_sum);

if (LiftMotor.getMode() != DcMotor.RunMode.RUN_TO_POSITION)
LiftMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);

LiftMotor.setPower(v);
}
public void step() {
}
}

0 comments on commit 9921f06

Please sign in to comment.