forked from FIRST-Tech-Challenge/FtcRobotController
-
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.
Merge pull request FIRST-Tech-Challenge#3 from aashrithbandaru/master
Update
- Loading branch information
Showing
9 changed files
with
491 additions
and
67 deletions.
There are no files selected for viewing
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
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
105 changes: 105 additions & 0 deletions
105
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DriverControltest.java
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package org.firstinspires.ftc.teamcode; | ||
|
||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp; | ||
import com.qualcomm.robotcore.util.ElapsedTime; | ||
import com.qualcomm.robotcore.util.Range; | ||
|
||
@TeleOp(name="DriverControltest", group="Linear Opmode") | ||
public class DriverControltest extends Movement { | ||
private ElapsedTime runtime = new ElapsedTime(); | ||
|
||
|
||
@Override | ||
public void runOpModeImpl() { | ||
// TODO Set up frontServo in movement | ||
|
||
waitForStart(); | ||
runtime.reset(); | ||
|
||
|
||
while(opModeIsActive()) { | ||
while(true) { | ||
// Gamepad 1 controls: | ||
|
||
/* | ||
// Left trigger - to move left sideways | ||
strafeRight(-gamepad1.right_trigger, 0); | ||
// Right trigger - to move right sideways | ||
strafeLeft(-gamepad1.left_trigger, 0); | ||
shooter.setPower(1); | ||
// Left stick y - to go forward or backward | ||
double drive = -gamepad1.left_stick_y; | ||
// Right stick x - to turn left or right | ||
double turn = gamepad1.right_stick_x; | ||
double leftPower = Range.clip(drive + turn, -1.0, 1.0) ; | ||
leftFront.setPower(leftPower); | ||
leftBack.setPower(leftPower); | ||
rightFront.setPower(rightPower); */ | ||
double leftPower = 1; | ||
double rightPower = -gamepad1.left_stick_y; | ||
rightBack.setPower(rightPower); | ||
/* | ||
// Gamepad 2 Controls | ||
// Left stick y - to move arm up or down | ||
arm.setPower(-gamepad2.left_stick_y*0.66); | ||
// left bumper - to close claw (front servo) | ||
if (gamepad2.left_bumper) { | ||
//frontServo.setPosition(0.4); | ||
//sleep(100); | ||
frontServo.setPosition(0.4); | ||
telemetry.addData("front servo open", "clawposition: 0.4" ); | ||
} | ||
// right bumper - to open claw (front servo) | ||
if (gamepad2.right_bumper) { | ||
frontServo.setPosition(0.0); | ||
telemetry.addData("front servo closed", "clawposition: 0.1" ); | ||
} | ||
// a - arm target position | ||
// if (gamepad2.a) { | ||
// arm.setTargetPosition(1); | ||
// arm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); | ||
// arm.setPower(0); | ||
// sleep(100); | ||
// } | ||
// x - to move back servo down | ||
if (gamepad2.x) { | ||
leftConstruction.setPosition(0.35); | ||
rightConstruction.setPosition(0.43); | ||
telemetry.addData("back servos down", "servoposition: 0,0" ); | ||
} | ||
q | ||
// y - to move back servo up | ||
if (gamepad2.y) { | ||
leftConstruction.setPosition(1); | ||
rightConstruction. setPosition(1); | ||
telemetry.addData("back servos up", "servoposition: 0.95" ); | ||
} | ||
*/ | ||
telemetry.addData("Status", "Run Time: " + runtime.toString()); | ||
telemetry.addData("Motors", "left (%.2f), right (%.2f)", leftPower, rightPower); | ||
telemetry.update(); | ||
} | ||
} | ||
|
||
} | ||
} |
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
113 changes: 113 additions & 0 deletions
113
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/IntakeClass.java
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package org.firstinspires.ftc.teamcode; | ||
|
||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; | ||
import com.qualcomm.robotcore.hardware.DcMotor; | ||
import com.qualcomm.robotcore.hardware.DcMotorSimple; | ||
import com.qualcomm.robotcore.hardware.Servo; | ||
|
||
/** | ||
This is an abstract class that handles 4 drive train motors. | ||
*/ | ||
abstract class IntakeClass extends LinearOpMode | ||
{ | ||
|
||
protected DcMotor intake; | ||
|
||
public void runOpMode() { | ||
setupDriveMotors(); | ||
runOpModeImpl(); | ||
} | ||
|
||
public abstract void runOpModeImpl(); | ||
|
||
protected void setupDriveMotors() { | ||
// Initialize the motor references for all the wheels | ||
// Initialize the hardware variables. Note that the strings used here as parameters | ||
|
||
updateTelemetryMessage("Initializing Motors"); | ||
intake = hardwareMap.get(DcMotor.class, "intake"); | ||
|
||
|
||
// Most robots need the motor on one side to be reve`rsed to drive goBackward | ||
// Reverse the motor that runs backwards when connected directly to the battery | ||
|
||
intake.setDirection(DcMotor.Direction.FORWARD); | ||
|
||
|
||
/* */ | ||
|
||
updateTelemetryMessage("Initialized Motors"); | ||
/* | ||
arm = hardwareMap.get(DcMotor.class, "Arm"); | ||
arm.setDirection(DcMotor.Direction.FORWARD);qa | ||
rightConstruction = hardwareMap.servo.get("rightConstruction"); | ||
*/ | ||
} | ||
|
||
public void stop(final String message) { | ||
intake.setPower(0.0); | ||
|
||
|
||
updateTelemetryMessage(message); | ||
} | ||
|
||
public void stopWithSleep(final String message, final long duration) { | ||
stop(message); | ||
sleep(duration); | ||
} | ||
|
||
public void stopWithSleep(final long duration) { | ||
stop("Stopping"); | ||
sleep(duration); | ||
} | ||
|
||
|
||
|
||
protected void updateTelemetryMessage(String message) { | ||
updateTelemetryMessage("Status", message); | ||
} | ||
|
||
protected void updateTelemetryMessage(String caption, String message) { | ||
telemetry.addData("Status", message); | ||
telemetry.update(); | ||
} | ||
|
||
|
||
|
||
public void intake(final double intakepower, final int duration){ | ||
intake.setPower(intakepower); | ||
sleep(duration); | ||
} | ||
|
||
|
||
|
||
/* | ||
public void armUp(final double armpower, final int duration) { | ||
arm.setPower(armpower); | ||
sleep(duration); | ||
updateTelemetryMessage("Arm going up"); | ||
} | ||
public void armDown(final double armpower, final int duration) { | ||
armUp(-armpower, duration); | ||
} | ||
public void backServosDown() { | ||
rightConstruction.setPosition(0.43); | ||
leftConstruction.setPosition(0.35); | ||
updateTelemetryMessage("Foundation Servos Down"); | ||
} | ||
public void backServosUp() { | ||
rightConstruction.setPosition(1); | ||
leftConstruction.setPosition(1); | ||
updateTelemetryMessage("Foundation Servos Up"); | ||
} | ||
*/ | ||
} |
Oops, something went wrong.