Skip to content
Merged

2025 #10

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
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ So, after adding the lines to the settings.gradle, this line in the dependencies
```
implementation "com.team2813:lib2813"
```
Finally, in order to guarantee that the library jars are created before GradleRIO referes to them, add the following line to your build.gradle
Finally, in order to guarantee that the library jars are created before GradleRIO referees to them, add the following line to your build.gradle
```
downloadDepsPreemptively.dependsOn gradle.includedBuild("lib2813").task(":lib:jar")
```
Expand All @@ -28,14 +28,14 @@ to your settings.json
```
"java.gradle.buildServer.enabled": "off",
```
This isn't strictly neccesary, but without it vscode will not be able to do code completion from things in the library, and tell the user that there are errors,
This isn't strictly necessary, but without it vscode will not be able to do code completion from things in the library, and tell the user that there are errors,
when gradle builds fine.

## Cloning a repository with a git submodule
When cloning a repository with a git submodule, git will not automatically get the files in the submodules. in order to do this, run the command
```
git submodule update --init --recursive
```
This command will recursivly initialize all submodules.
This command will recursively initialize all submodules.

This code is still in development, and apis are still subject to change. The most likely thing to get removed is the swerve api, as ctre recently released their own.
66 changes: 33 additions & 33 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id "edu.wpi.first.GradleRIO" version "2024.3.1"
id 'maven-publish'
id "edu.wpi.first.GradleRIO" version "2025.1.1"
id 'maven-publish'
}

java {
Expand All @@ -28,10 +28,10 @@ version = "1.2.0"
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven {
// WPI
url "https://frcmaven.wpi.edu/artifactory/release/"
}
maven {
// WPI
url "https://frcmaven.wpi.edu/artifactory/release/"
}
}

dependencies {
Expand Down Expand Up @@ -60,41 +60,41 @@ tasks.named('test') {
tasks.named('jar') {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
'Implementation-Version': project.version)
}
}

javadoc {
options.tags = [ "apiNote:a:Api Note:", "implSpec:a:Implementation Requirements:" ]
options.tags = ["apiNote:a:Api Note:", "implSpec:a:Implementation Requirements:"]
}

task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
from sourceSets.main.allJava
archiveClassifier = "sources"
}

publishing {
publications {
lib2813(MavenPublication) {
groupId = "com.team2813.lib2813"
artifactId = "lib2813"
from components.java
artifact sourceJar
pom {
name = "2813 Library"
description = "Frequently reused code written by team 2813"
developers {
developer {
id = "mango"
name = "kyle"
email = "mangoiscute95@gmail.com"
}
}
organization {
name = "2813 Gear Heads"
url = "https://team2813.com"
}
}
}
}
publications {
lib2813(MavenPublication) {
groupId = "com.team2813.lib2813"
artifactId = "lib2813"
from components.java
artifact sourceJar
pom {
name = "2813 Library"
description = "Frequently reused code written by team 2813"
developers {
developer {
id = "mango"
name = "kyle"
email = "mangoiscute95@gmail.com"
}
}
organization {
name = "2813 Gear Heads"
url = "https://team2813.com"
}
}
}
}
}
26 changes: 13 additions & 13 deletions lib/src/main/java/com/team2813/lib2813/control/ControlMode.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.team2813.lib2813.control;

import com.revrobotics.CANSparkBase.ControlType;
import com.revrobotics.spark.SparkBase.ControlType;

public enum ControlMode {
DUTY_CYCLE(ControlType.kDutyCycle),
VELOCITY(ControlType.kVelocity),
MOTION_MAGIC(ControlType.kPosition),
VOLTAGE(ControlType.kVoltage);
DUTY_CYCLE(ControlType.kDutyCycle),
VELOCITY(ControlType.kVelocity),
MOTION_MAGIC(ControlType.kPosition),
VOLTAGE(ControlType.kVoltage);

private final ControlType sparkMode;
private final ControlType sparkMode;

ControlMode(ControlType sparkMode) {
this.sparkMode = sparkMode;
}
ControlMode(ControlType sparkMode) {
this.sparkMode = sparkMode;
}

public ControlType getSparkMode() {
return sparkMode;
}
}
public ControlType getSparkMode() {
return sparkMode;
}
}
108 changes: 55 additions & 53 deletions lib/src/main/java/com/team2813/lib2813/control/DeviceInformation.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
package com.team2813.lib2813.control;

import java.util.Optional;

import com.team2813.lib2813.util.InputValidation;
import java.util.Optional;

public final class DeviceInformation {
private int id;
private Optional<String> canbus;

/**
* Creates a DeviceInformation for a device on the RoboRIO can loop
* @param id the can ID
*/
public DeviceInformation(int id) {
this(id, null);
}

/**
* Creates a DeviceInformation with a canbus string. If {@code canbus} is {@code null},
* method acts like {@link #DeviceInformation(int)} was called
* @param id the CAN id
* @param canbus the canbus string
*/
public DeviceInformation(int id, String canbus) {
this.id = InputValidation.checkCanId(id);
this.canbus = Optional.ofNullable(canbus);
}

/**
* Gets the can id of this device
* @return the can id of the device
*/
public int id() {
return id;
}

/**
* Returns the canbus that this device is on, or {@link Optional#empty()} if it is on the
* RoboRIO can loop
* @return the canbus that the device is on
*/
public Optional<String> canbus() {
return canbus;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof DeviceInformation))
return false;
DeviceInformation other = (DeviceInformation) o;
return other.id == id && other.canbus.equals(canbus);
}

@Override
public int hashCode() {
return id * 31 + canbus.hashCode();
}
private int id;
private Optional<String> canbus;

/**
* Creates a DeviceInformation for a device on the RoboRIO can loop
*
* @param id the can ID
*/
public DeviceInformation(int id) {
this(id, null);
}

/**
* Creates a DeviceInformation with a canbus string. If {@code canbus} is {@code null}, method
* acts like {@link #DeviceInformation(int)} was called
*
* @param id the CAN id
* @param canbus the canbus string
*/
public DeviceInformation(int id, String canbus) {
this.id = InputValidation.checkCanId(id);
this.canbus = Optional.ofNullable(canbus);
}

/**
* Gets the can id of this device
*
* @return the can id of the device
*/
public int id() {
return id;
}

/**
* Returns the canbus that this device is on, or {@link Optional#empty()} if it is on the RoboRIO
* can loop
*
* @return the canbus that the device is on
*/
public Optional<String> canbus() {
return canbus;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof DeviceInformation)) return false;
DeviceInformation other = (DeviceInformation) o;
return other.id == id && other.canbus.equals(canbus);
}

@Override
public int hashCode() {
return id * 31 + canbus.hashCode();
}
}
Loading