Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver enhancements #38

Merged
merged 6 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class ArmToIntake extends QQTimeoutNode {
public ArmToIntake(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {
if (lastStatus != State.RUNNING) {
return lastStatus;
}else {
opMode.robot.scoreArm.goToIntake();
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
} else if (opMode.robot.scoreArm.isLimitSwitchPressed()) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
return State.RUNNING;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class BehindChamber extends QQTimeoutNode {
public BehindChamber(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {
opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(17,-58,0);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ public State tick(DebugTree debug, QQOpMode opMode) {
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class DriveToFirstSample extends QQTimeoutNode {
public DriveToFirstSample(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(42,-88,90);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class DriveToSamples extends QQTimeoutNode {
public DriveToSamples(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(42,-84,90);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class DriveToSecondSample extends QQTimeoutNode {
public DriveToSecondSample(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(42,-94,90);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class GetReadyToPushSamples extends QQTimeoutNode {
public GetReadyToPushSamples(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {
opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(17,-83,0);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class IntakeAttempt extends QQTimeoutNode {
public static final double INTAKE_SPEED = -0.3;
State lastStatus = State.RUNNING;

public IntakeAttempt(double seconds) {
super(seconds);
}

@Override
public State tick(DebugTree debug, QQOpMode opMode) {
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
if(hasTimedOut()){
opMode.robot.mecanumDrive.stop();
lastStatus = State.FAILURE;
return State.FAILURE;
}
opMode.robot.mecanumDrive.move(INTAKE_SPEED,0,0);
if (opMode.robot.scoringClaw.isClawClosed()){
opMode.robot.mecanumDrive.stop();
lastStatus = State.SUCCESS;
return State.SUCCESS;

}
return State.RUNNING;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ public class Park extends QQTimeoutNode {
public Park(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {
boolean isDoneDriving = opMode.nav.driveToPositionIN(14,-109.5,0);

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(12,-90.5,0);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class PushFirstSample extends QQTimeoutNode {
public PushFirstSample(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(14,-88,90);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class PushSecondSample extends QQTimeoutNode {
public PushSecondSample(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(14,-88,90);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.Actions;

import com.ftcteams.behaviortrees.DebugTree;

import org.firstinspires.ftc.teamcode.ftc16072.BehaviorTrees.QQTimeoutNode;
import org.firstinspires.ftc.teamcode.ftc16072.OpModes.QQOpMode;

public class ReadyToIntake extends QQTimeoutNode {
public ReadyToIntake(double seconds) {
super(seconds);
}
State lastStatus = State.RUNNING;

@Override
public State tick(DebugTree debug, QQOpMode opMode) {

opMode.telemetry.addData("location",opMode.robot.otos.getOtosPosition());
if (lastStatus != State.RUNNING){
return lastStatus;
}else{
boolean isDoneDriving = opMode.nav.driveToPositionIN(14,-84,0);
if (isDoneDriving) {
lastStatus = State.SUCCESS;
return State.SUCCESS;
}
if (hasTimedOut()) {
lastStatus = State.FAILURE;
return State.FAILURE;
}
return State.RUNNING;
}
}
}
Loading
Loading