Last active
August 29, 2025 02:09
-
-
Save yabberyabber/67a4e366fa7e7674c97cc0f8e3e3f12b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
ARM_INFO: | |
HALL_SENSOR_ID: 1 | |
ENCODER_CAN_ID: 32 | |
ENCODER_OFFSET_ROTATIONS: -0.1663 | |
DRIVE_INFO: | |
STATUS_SIGNAL_FREQUENCY: 200 | |
ANGLE_GEAR_RATIO: 15.0004 |
This file contains hidden or 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
package com.team973.frc2025; | |
import com.team973.frc2025.shared.RobotInfo; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import org.yaml.snakeyaml.Yaml; | |
public class ConfigLoader { | |
private static boolean m_initialized; | |
private static RobotInfo m_robotInfo; | |
public static synchronized RobotInfo get() { | |
if (!m_initialized) { | |
loadRobotInfo(); | |
} | |
return m_robotInfo; | |
} | |
private static void loadRobotInfo() { | |
try { | |
String filePath = System.getProperty("user.dir") + "/config/robot-info-var/Config.yaml"; | |
// Load YAML file into a string | |
String yamlContent = new String(Files.readAllBytes(Paths.get(filePath)), "UTF-8"); | |
Yaml yaml = new Yaml(); | |
RobotInfo loaded = yaml.loadAs(yamlContent, RobotInfo.class); | |
m_robotInfo = loaded; | |
m_initialized = true; | |
} catch (Exception e) { | |
System.out.println("⚠️ Could not load config file, using defaults"); | |
System.exit(1); | |
} | |
} | |
} |
This file contains hidden or 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
import static org.junit.jupiter.api.Assertions.assertEquals; | |
import com.team973.frc2025.RobotConfig; | |
import com.team973.frc2025.shared.RobotInfo; | |
import org.junit.jupiter.api.Test; | |
import org.yaml.snakeyaml.Yaml; | |
public class ConfigTest { | |
@Test | |
void testGetConfig() throws Exception { | |
RobotInfo robotInfo = RobotConfig.get(); | |
System.out.printf("Config: %s\n", (new Yaml().dump(robotInfo))); | |
System.out.printf("ANGLE_GEAR_RATIO is %f\n", robotInfo.DRIVE_INFO.ANGLE_GEAR_RATIO); | |
assertEquals(15.0004, robotInfo.DRIVE_INFO.ANGLE_GEAR_RATIO, 0.01); | |
} | |
} |
This file contains hidden or 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
m_driveWithJoysticks = new DriveWithJoysticks(ConfigLoader.get().DRIVE_INFO); |
This file contains hidden or 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
public class RobotInfo { | |
public static class ArmInfo { | |
public int HALL_SENSOR_ID; | |
public int ENCODER_CAN_ID = 32; | |
public double ARM_ROTATIONS_PER_MOTOR_ROTATIONS = (10.0 / 84.0) * (16.0 / 108.0); | |
public double ENCODER_OFFSET_ROTATIONS = -0.1663; | |
} | |
public ArmInfo ARM_INFO; | |
public static class DriveInfo { | |
public int STATUS_SIGNAL_FREQUENCY = 200; | |
public int PIGEON_ID = 1; | |
public int FRONT_LEFT_MODULE_DRIVE_MOTOR = 2; | |
public int FRONT_LEFT_MODULE_STEER_MOTOR = 3; | |
public int FRONT_LEFT_MODULE_STEER_ENCODER = 4; | |
public double FRONT_LEFT_MODULE_STEER_OFFSET = fromBotVersion(-743.027, 264.902); | |
} | |
public DriveInfo DRIVE_INFO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment