Skip to content

Commit

Permalink
add scaled measures to cancoder
Browse files Browse the repository at this point in the history
  • Loading branch information
mwitcpalek committed Feb 3, 2024
1 parent db4b7bc commit f47d1e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = "org.strykeforce"
version = "24.0.1"
version = "24.0.2"

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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},
Expand Down

0 comments on commit f47d1e7

Please sign in to comment.