Skip to content

Commit e825750

Browse files
authored
v2.0.0
2 parents 5a3d175 + c0c4412 commit e825750

File tree

111 files changed

+11059
-6831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+11059
-6831
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.idea/gradle.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

build.gradle.kts

Lines changed: 3 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,4 @@
1-
import com.android.builder.symbols.exportToCompiledJava
2-
import org.jetbrains.dokka.plugability.configuration
3-
41
plugins {
5-
id("org.jetbrains.kotlin.android") version "1.9.20"
6-
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.20"
7-
id("com.android.library") version "8.1.2"
8-
9-
`maven-publish`
10-
11-
id("org.jetbrains.dokka") version "1.9.20"
12-
}
13-
14-
tasks.named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaJavadoc") {
15-
outputDirectory.set(file("${buildDir}/dokka"))
16-
17-
dokkaSourceSets {
18-
named("main") {
19-
sourceRoots.from(file("src/main/kotlin"), file("src/main/java"))
20-
reportUndocumented.set(true)
21-
skipDeprecated.set(false)
22-
jdkVersion.set(8) // or adjust based on your requirements
23-
perPackageOption {
24-
matchingRegex.set("com\\.acmerobotics\\.roadrunner\\.ftc.*")
25-
suppress.set(true) // Exclude this package
26-
}
27-
}
28-
}
29-
}
30-
31-
tasks.dokkaHtml {
32-
dokkaSourceSets {
33-
named("main") {
34-
perPackageOption {
35-
matchingRegex.set("com\\.acmerobotics\\.roadrunner\\.ftc.*")
36-
suppress.set(true) // Exclude this package
37-
}
38-
}
39-
}
40-
}
41-
42-
43-
val defaultMinSdkVersion by extra(29)
44-
val defaultMinSdkVersion1 by extra(23)
45-
46-
repositories {
47-
mavenCentral()
48-
google()
49-
maven("https://maven.brott.dev/")
50-
}
51-
52-
android {
53-
namespace = "com.pedropathing.pedropathing"
54-
compileSdk = 32
55-
56-
compileOptions {
57-
sourceCompatibility = JavaVersion.VERSION_1_8
58-
targetCompatibility = JavaVersion.VERSION_1_8
59-
}
60-
kotlinOptions {
61-
jvmTarget = "1.8"
62-
}
63-
publishing {
64-
singleVariant("release")
65-
}
66-
sourceSets {
67-
getByName("main") {
68-
java.srcDirs("src/main/kotlin")
69-
}
70-
}
71-
defaultConfig {
72-
minSdk = 23
73-
}
74-
}
75-
76-
dependencies {
77-
compileOnly("org.firstinspires.ftc:RobotCore:10.2.0")
78-
compileOnly("org.firstinspires.ftc:Hardware:10.2.0")
79-
compileOnly("org.firstinspires.ftc:FtcCommon:10.2.0")
80-
compileOnly("org.firstinspires.ftc:RobotServer:10.2.0")
81-
compileOnly("org.firstinspires.ftc:OnBotJava:10.2.0")
82-
compileOnly("com.acmerobotics.dashboard:dashboard:0.4.16")
83-
84-
implementation("org.apache.commons:commons-math3:3.6.1")
85-
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.9.20")
86-
dokkaGfmPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.9.20")
87-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20")
88-
}
89-
90-
// CONFIGURE PUBLICATION
91-
publishing {
92-
publications {
93-
register<MavenPublication>("release") {
94-
groupId = "com.pedropathing"
95-
artifactId = "pedro"
96-
version = "1.0.9"
97-
98-
afterEvaluate {
99-
from(components["release"])
100-
}
101-
}
102-
}
103-
104-
repositories {
105-
maven {
106-
name = "publishing"
107-
url = uri("./maven.pedropathing.com")
108-
}
109-
}
110-
}
2+
alias(libs.plugins.android.library) apply false
3+
alias(libs.plugins.dokka) apply false
4+
}

core/build.gradle.kts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
plugins {
2+
id("java-library")
3+
id("maven-publish")
4+
}
5+
6+
dependencies {
7+
compileOnly(libs.annotations)
8+
}
9+
10+
java {
11+
sourceCompatibility = JavaVersion.VERSION_1_8
12+
targetCompatibility = JavaVersion.VERSION_1_8
13+
14+
withSourcesJar()
15+
withJavadocJar()
16+
}
17+
18+
publishing {
19+
publications {
20+
register<MavenPublication>("release") {
21+
groupId = "com.pedropathing"
22+
artifactId = "core"
23+
version = property("version") as String
24+
25+
from(components["java"])
26+
}
27+
}
28+
29+
repositories {
30+
maven {
31+
name = "publishing"
32+
url = uri("../../maven.pedropathing.com")
33+
}
34+
}
35+
}
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
package com.pedropathing;
2+
3+
import com.pedropathing.math.Vector;
4+
import com.pedropathing.math.MathFunctions;
5+
6+
public abstract class Drivetrain {
7+
/**
8+
* These are the movement vectors for the drivetrain, essentially the directions of the forces created by each wheel, such that x-components are scaled by the x velocity and y-components are scaled by the y velocity.
9+
*/
10+
protected Vector[] vectors;
11+
12+
/**
13+
* This is the maximum power scaling for the drivetrain. This is used to limit the maximum
14+
* power that can be applied to the motors, which is useful for preventing damage to the
15+
* drivetrain or for controlling the speed of the robot.
16+
*/
17+
protected double maxPowerScaling;
18+
19+
/**
20+
* This is used to determine whether the drivetrain should use voltage compensation or not.
21+
*/
22+
protected boolean voltageCompensation;
23+
24+
/**
25+
* This is the nominal voltage for the drivetrain. This is used for voltage compensation.
26+
* It is set to 12.0V by default, which is the nominal voltage for most FTC robots.
27+
*/
28+
protected double nominalVoltage;
29+
30+
/**
31+
* This takes in vectors for corrective power, heading power, and pathing power and outputs
32+
* an Array.
33+
* IMPORTANT NOTE: all vector inputs are clamped between 0 and 1 inclusive in magnitude.
34+
*
35+
* @param correctivePower this Vector includes the centrifugal force scaling Vector as well as a
36+
* translational power Vector to correct onto the Bezier curve the Follower
37+
* is following.
38+
* @param headingPower this Vector points in the direction of the robot's current heading, and
39+
* the magnitude tells the robot how much it should turn and in which
40+
* direction.
41+
* @param pathingPower this Vector points in the direction the robot needs to go to continue along
42+
* the Path.
43+
* @param robotHeading this is the current heading of the robot, which is used to calculate how
44+
* much power to allocate to each wheel.
45+
* @return this returns an Array of doubles with a length of 4, which contains the wheel powers.
46+
*/
47+
public abstract double[] calculateDrive(Vector correctivePower, Vector headingPower, Vector pathingPower, double robotHeading);
48+
49+
/**
50+
* This sets the maximum power scaling for the drivetrain. This is used to limit the maximum
51+
* power that can be applied to the motors, which is useful for preventing damage to the
52+
* drivetrain or for controlling the speed of the robot.
53+
*
54+
* @param maxPowerScaling this is a double between 0 and 1 inclusive that represents the maximum
55+
* power scaling factor.
56+
*/
57+
public void setMaxPowerScaling(double maxPowerScaling) {
58+
this.maxPowerScaling = MathFunctions.clamp(maxPowerScaling, 0, 1);
59+
}
60+
61+
/**
62+
* This gets the maximum power scaling for the drivetrain. This is used to limit the maximum
63+
* power that can be applied to the motors, which is useful for preventing damage to the
64+
* drivetrain or for controlling the speed of the robot.
65+
*
66+
* @return this returns a double between 0 and 1 inclusive that represents the maximum power
67+
* scaling factor.
68+
*/
69+
public double getMaxPowerScaling() {
70+
return maxPowerScaling;
71+
}
72+
73+
/**
74+
* This updates the constants used by the drivetrain.
75+
*/
76+
public abstract void updateConstants();
77+
78+
/**
79+
* This is used to break the drivetrain's following. This is useful for stopping the robot from following a Path or PathChain.
80+
*/
81+
public abstract void breakFollowing();
82+
83+
/**
84+
* This runs the drivetrain with the specified drive powers. This is used to set the power of the motors directly.
85+
*
86+
* @param drivePowers this is an Array of doubles with a length of 4, which contains the wheel powers.
87+
*/
88+
public abstract void runDrive(double[] drivePowers);
89+
90+
/**
91+
* This gets the drive powers and runs them immediately.
92+
*
93+
* @param correctivePower this Vector includes the centrifugal force scaling Vector as well as a
94+
* translational power Vector to correct onto the Bezier curve the Follower
95+
* is following.
96+
* @param headingPower this Vector points in the direction of the robot's current heading, and
97+
* the magnitude tells the robot how much it should turn and in which
98+
* direction.
99+
* @param pathingPower this Vector points in the direction the robot needs to go to continue along
100+
* the Path.
101+
* @param robotHeading this is the current heading of the robot, which is used to calculate how
102+
* much power to allocate to each wheel.
103+
*/
104+
public void runDrive(Vector correctivePower, Vector headingPower, Vector pathingPower, double robotHeading) {
105+
runDrive(calculateDrive(correctivePower, headingPower, pathingPower, robotHeading));
106+
}
107+
108+
/**
109+
* This starts the TeleOp drive mode. This is used to set the drivetrain into TeleOp mode, where
110+
* it can be controlled by the driver.
111+
*/
112+
public abstract void startTeleopDrive();
113+
114+
/**
115+
* This starts the TeleOp drive mode with a specified brake mode. This is used to set the drivetrain
116+
* into TeleOp mode, where it can be controlled by the driver, and allows for setting the brake mode.
117+
*
118+
* @param brakeMode this is a boolean that specifies whether the drivetrain should use brake mode or not.
119+
*/
120+
public abstract void startTeleopDrive(boolean brakeMode);
121+
122+
/**
123+
* This gets the current x velocity of the drivetrain.
124+
* @return this returns the x velocity of the drivetrain.
125+
*/
126+
public abstract double xVelocity();
127+
128+
/**
129+
* This gets the current y velocity of the drivetrain.
130+
* @return this returns the y velocity of the drivetrain.
131+
*/
132+
public abstract double yVelocity();
133+
134+
/**
135+
* This sets the x velocity of the drivetrain.
136+
* @param xMovement this is the x velocity to set.
137+
*/
138+
public abstract void setXVelocity(double xMovement);
139+
140+
/**
141+
* This sets the y velocity of the drivetrain.
142+
* @param yMovement this is the y velocity to set.
143+
*/
144+
public abstract void setYVelocity(double yMovement);
145+
146+
/**
147+
* This sets whether the drivetrain should use voltage compensation or not.
148+
* @param use this is a boolean that specifies whether the drivetrain should use voltage compensation or not.
149+
*/
150+
public void useVoltageCompensation(boolean use) {
151+
this.voltageCompensation = use;
152+
}
153+
154+
/**
155+
* This gets whether the drivetrain is using voltage compensation or not.
156+
* @return this returns a boolean that specifies whether the drivetrain is using voltage compensation or not.
157+
*/
158+
public boolean isVoltageCompensation() {
159+
return voltageCompensation;
160+
}
161+
162+
/**
163+
* This gets the nominal voltage for the drivetrain.
164+
* @return this returns the nominal voltage for the drivetrain.
165+
*/
166+
public double getNominalVoltage() {
167+
return nominalVoltage;
168+
}
169+
170+
/**
171+
* This sets the nominal voltage for the drivetrain. This is used for voltage compensation.
172+
* @param set this is the nominal voltage to set.
173+
*/
174+
public void setNominalVoltage(double set) {
175+
this.nominalVoltage = set;
176+
}
177+
178+
/**
179+
* This is used to get the voltage of the drivetrain. This is useful for debugging purposes.
180+
* It should be called periodically to get the current voltage of the drivetrain.
181+
*/
182+
public abstract double getVoltage();
183+
184+
/**
185+
* This is used to get a debug string for the drivetrain. This is useful for debugging purposes.
186+
*
187+
* @return this returns a String that contains the debug information for the drivetrain.
188+
*/
189+
public abstract String debugString();
190+
191+
}

0 commit comments

Comments
 (0)