From f47d1e72b7354395eb7aa2cdb7c3c2326d3d4830 Mon Sep 17 00:00:00 2001 From: mwitcpalek Date: Sat, 3 Feb 2024 14:57:04 -0500 Subject: [PATCH] add scaled measures to cancoder --- build.gradle | 2 +- .../telemetry/measurable/CancoderMeasureable.kt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8dacfb5..a04b385 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ plugins { } group = "org.strykeforce" -version = "24.0.1" +version = "24.0.2" sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/kotlin/org/strykeforce/telemetry/measurable/CancoderMeasureable.kt b/src/main/kotlin/org/strykeforce/telemetry/measurable/CancoderMeasureable.kt index 1d9cb37..992e963 100644 --- a/src/main/kotlin/org/strykeforce/telemetry/measurable/CancoderMeasureable.kt +++ b/src/main/kotlin/org/strykeforce/telemetry/measurable/CancoderMeasureable.kt @@ -3,11 +3,15 @@ package org.strykeforce.telemetry.measurable import com.ctre.phoenix6.hardware.CANcoder import org.strykeforce.telemetry.talon.HAS_RESET_OCCURRED import org.strykeforce.telemetry.talon.IS_PRO_LIC +import org.strykeforce.telemetry.talon.POS_SCALE internal const val MAGNET_HEALTH = "MAGNET_HEALTH" //internal const val POSITION = "POSITION" +internal const val POSITION_SCALED = "POS_SCALED" internal const val POSITION_SINCE_BOOT = "POSITION_SINCE_BOOT" +internal const val POS_BOOT_SCALED = "POS_BOOT_SCALED" internal const val ABS_POSITION = "ABS_POSITION" +internal const val ABS_POS_SCALED = "ABS_POS_SCALED" internal const val SUPPLY_VOLTAGE = "SUPPLY_VOLTAGE" internal const val UNFILTERED_VELOCITY = "UNFILTERED_VELOCITY" internal const val VELOCITY = "VELOCITY" @@ -18,12 +22,16 @@ class CancoderMeasureable @JvmOverloads constructor( override val description: String = "Cancoder ${cancoder.deviceID}" ): Measurable { + private val scaleFactor = 1000.0; override val deviceId = cancoder.deviceID override val measures = setOf( Measure(MAGNET_HEALTH, "Magnet Health") {cancoder.magnetHealth.valueAsDouble}, Measure(POSITION, "Position") {cancoder.position.valueAsDouble}, + Measure(POS_SCALE, "Pos. Scaled") {cancoder.position.valueAsDouble * scaleFactor}, Measure(POSITION_SINCE_BOOT, "Position Since Boot") {cancoder.positionSinceBoot.valueAsDouble}, + Measure(POS_BOOT_SCALED, "Pos. since Boot Scaled") {cancoder.positionSinceBoot.valueAsDouble * scaleFactor}, Measure(ABS_POSITION, "Absolute Position") {cancoder.absolutePosition.valueAsDouble}, + Measure(ABS_POS_SCALED, "Absolute Pos. Scaled") {cancoder.absolutePosition.valueAsDouble * scaleFactor}, Measure(SUPPLY_VOLTAGE, "Supply Voltage") {cancoder.supplyVoltage.valueAsDouble}, Measure(UNFILTERED_VELOCITY, "Unfiltered Velocity") {cancoder.unfilteredVelocity.valueAsDouble}, Measure(VELOCITY, "Velocity") {cancoder.velocity.valueAsDouble},