Skip to content

Commit

Permalink
Merge pull request FIRST-Tech-Challenge#1250 from FIRST-Tech-Challeng…
Browse files Browse the repository at this point in the history
…e/20241102-092223-release-candidate

FtcRobotController v10.1.1
  • Loading branch information
cmacfarl authored and Noah Lin committed Nov 6, 2024
2 parents 6af9bb6 + 9f11128 commit 28ace82
Show file tree
Hide file tree
Showing 10 changed files with 580 additions and 19 deletions.
6 changes: 5 additions & 1 deletion FtcRobotController/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ android {
buildConfigField "String", "APP_BUILD_TIME", '"' + (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ROOT).format(new Date())) + '"'
}

compileSdkVersion 29
buildFeatures {
buildConfig = true
}

compileSdkVersion 30

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
4 changes: 2 additions & 2 deletions FtcRobotController/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="56"
android:versionName="10.1">
android:versionCode="57"
android:versionName="10.1.1">

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repository contains the public FTC SDK for the INTO THE DEEP (2024-2025) co
This GitHub repository contains the source code that is used to build an Android app to control a *FIRST* Tech Challenge competition robot. To use this SDK, download/clone the entire project to your local computer.

## Requirements
To use this Android Studio project, you will need Android Studio 2021.2 (codename Chipmunk) or later.
To use this Android Studio project, you will need Android Studio Ladybug (2024.2) or later.

To program your robot in Blocks or OnBot Java, you do not need Android Studio.

Expand Down Expand Up @@ -59,6 +59,25 @@ The readme.md file located in the [/TeamCode/src/main/java/org/firstinspires/ftc

# Release Information

## Version 10.1.1 (20241102-092223)

### Breaking Changes

* Support for Android Studio Ladybug. Requires Android Studio Ladybug.

### Known Issues

* Android Studio Ladybug's bundled JDK is version 21. JDK 21 has deprecated support for Java 1.8, and Ladybug will warn on this deprecation.
OnBotJava only supports Java 1.8, therefore, in order to ensure that software developed using Android Studio will
run within the OnBotJava environment, the targetCompatibility and sourceCompatibility versions for the SDK have been left at VERSION_1_8.
FIRST has decided that until it can devote the resources to migrating OnBotJava to a newer version of Java, the deprecation is the
lesser of two non-optimal situations.

### Enhancements

* Added `toString()` method to Pose2D
* Added `toString()` method to SparkFunOTOS.Pose2D

## Version 10.1 (20240919-122750)

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import org.firstinspires.ftc.robotcore.external.Telemetry;
@Autonomous(name="Auton For Right Field", group="Robot")
public class AutonForRightField extends LinearOpMode {
public DcMotor frontLeft = null;
public DcMotor frontRight = null;
public DcMotor backLeft = null;
public DcMotor backRight = null;
public DcMotor leftSlide = null;
public DcMotor rightSlide = null;
public DcMotor Arm = null;
public void moveWheel(double x,double y) {
double fl = (y+x);
double fr = (x-y);
double bl = (y-x);
double br = (-y-x);
double wheelCPR = 423.2116; //Counts per revolution
int Flposition = frontLeft.getCurrentPosition();
int Frposition = frontRight.getCurrentPosition();
int Blposition = backLeft.getCurrentPosition();
int Brposition = backRight.getCurrentPosition();
//YAY MORE VARIABLES
double Flrevolutions = Flposition/wheelCPR;
double Frrevolutions = Frposition/wheelCPR;
double Blrevolutions = Blposition/wheelCPR;
double Brrevolutions = Brposition/wheelCPR;
double leadMotor = Math.min(Math.min(Flrevolutions,Frrevolutions),Math.min(Blrevolutions,Brrevolutions));
//Modifier Variables YAY
// double linearMotor = Math.min(Lsposition,Rsposition);
double flModifier = 1;
double frModifier = 1;
double blModifier = 1;
double brModifier = 1;
if (Flrevolutions > leadMotor) {
flModifier = leadMotor/Flrevolutions;
}
if (Frrevolutions > leadMotor) {
frModifier = leadMotor/Frrevolutions;
}
if (Blrevolutions > leadMotor) {
blModifier = leadMotor/Blrevolutions;
}
if (Brrevolutions > leadMotor) {
brModifier = leadMotor/Brrevolutions;
}
//stops it from going greater than 1/-1
double maxNumber = Math.max(Math.abs(x)+Math.abs(y),1);
//powers the motor for wheels
frontLeft.setPower(fl/maxNumber);
frontRight.setPower(fr/maxNumber);
backLeft.setPower(bl/maxNumber);
backRight.setPower(br/maxNumber);
//Should do telemetery data thingy I hate this.
telemetry.addData("Front Left",fl/maxNumber;
telemetry.addData("Front Right",fr/maxNumber);
telemetry.addData("Back Left",bl/maxNumber);
telemetry.addData("Back Right",br/maxNumber);
}
public void turn(boolean rotateLeft, boolean rotateRight) {
double fl, fr, bl, br;
double wheelCPR = 423.2116; //Counts per revolution
int Flposition = frontLeft.getCurrentPosition();
int Frposition = frontRight.getCurrentPosition();
int Blposition = backLeft.getCurrentPosition();
int Brposition = backRight.getCurrentPosition();
//YAY MORE VARIABLES
double Flrevolutions = Flposition/wheelCPR;
double Frrevolutions = Frposition/wheelCPR;
double Blrevolutions = Blposition/wheelCPR;
double Brrevolutions = Brposition/wheelCPR;
double leadMotor = Math.min(Math.min(Flrevolutions,Frrevolutions),Math.min(Blrevolutions,Brrevolutions));
//Modifier Variables YAY
// double linearMotor = Math.min(Lsposition,Rsposition);
double flModifier = 1;
double frModifier = 1;
double blModifier = 1;
double brModifier = 1;
if (Flrevolutions > leadMotor) {
flModifier = leadMotor/Flrevolutions;
}
if (Frrevolutions > leadMotor) {
frModifier = leadMotor/Frrevolutions;
}
if (Blrevolutions > leadMotor) {
blModifier = leadMotor/Blrevolutions;
}
if (Brrevolutions > leadMotor) {
brModifier = leadMotor/Brrevolutions;
}
fl = fr = bl = br = 0;
if (rotateRight) {
fl = 0.5;
fr = 0.5;
bl = 0.5;
br = 0.5;
}
if (rotateLeft) {
fl = -0.5;
fr = -0.5;
bl = -0.5;
br = -0.5;
}
}
public void linearVertical(float verticalPower) {
if (verticalPower>0) {
leftSlide.setPower(verticalPower);
rightSlide.setPower(verticalPower);
} //Assumes triggers to be positive values
else if (verticalPower<0) {
leftSlide.setPower(verticalPower);
rightSlide.setPower(verticalPower);
}
}
public void armPleaseWork(float armVertical) {
if (armVertical > 0) {
Arm.setPower(armVertical);
} else if (armVertical < 0) {
Arm.setPower(armVertical);
}
}
//Code for moving in different directions. may have to reverse
public void moveForward(int seconds) {
//sets current time
long durationSucks = System.currentTimeMillis();
//stops current time
long stop = (durationSucks + seconds*100); //Im using tenths of a seconds, not seconds btw
while (System. currentTimeMillis() < stop) {
//not even sure if this works or not. We can test it anyway
moveWheel(0,0.5);
}
}
public void moveBackward(int seconds) {
//sets current time
long durationSucks = System.currentTimeMillis();
//stops current time
long stop = (durationSucks + seconds*100);
while (System. currentTimeMillis() < stop) {
//not even sure if this works or not. We can test it anyway
moveWheel(0,-0.5);
}
}
//Hopefully strafe code works
public void strafeRight(int seconds) {
//sets current time
long durationSucks = System.currentTimeMillis();
//stops current time
long stop = (durationSucks + seconds*100);
while (System. currentTimeMillis() < stop) {
//not even sure if this works or not. We can test it anyway
moveWheel(0.5,0);
}
}
public void strafeLeft(int seconds) {
//sets current time
long durationSucks = System.currentTimeMillis();
//stops current time
long stop = (durationSucks + seconds*100);
while (System. currentTimeMillis() < stop) {
//not even sure if this works or not. We can test it anyway
moveWheel(-0.5,0);
}
}
public void rotateLeft(int seconds) {
//sets current time
long durationSucks = System.currentTimeMillis();
//stops current time
long stop = (durationSucks + seconds*100);
while (System. currentTimeMillis() < stop) {
turn(true,false);
}
}
public void rotateRight(int seconds) {
//sets current time
long durationSucks = System.currentTimeMillis();
//stops current time
long stop = (durationSucks + seconds*100);
while (System. currentTimeMillis() < stop) {
turn(false,true);
}
}

public void runOpMode() {
DcMotor frontLeft = hardwareMap.get(DcMotor.class, "frontLeft");
DcMotor frontRight = hardwareMap.get(DcMotor.class, "frontRight");
DcMotor backLeft = hardwareMap.get(DcMotor.class, "backLeft");
DcMotor backRight = hardwareMap.get(DcMotor.class, "backRight");
DcMotor leftSlide = hardwareMap.get(DcMotor.class,"leftSlide");
DcMotor rightSlide = hardwareMap.get(DcMotor.class,"rightSlide");
DcMotor Arm = hardwareMap.get(DcMotor.class,"Arm");
//Not even sure it runs
frontLeft.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
frontRight.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
backLeft.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
backRight.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
//More code
frontLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
frontRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
backLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
backRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
waitForStart();
if (opModeIsActive()) {
moveForward(1);

}
while (opModeIsActive()) {
//Updates the thingy
telemetry.update();

}

}
}
Loading

0 comments on commit 28ace82

Please sign in to comment.