SmartDashboard not outputting manipulated data

I’ve been having issues with the 2018 edition of SmartDashboard. I’ve been trying to read the motor’s raw velocity from the encoder and then convert it to the SI standard of m/s. I can output the raw encoder data to the SmartDashboard as usual, but multiplying it or passing a static variable outputs nothing.

The following code works just fine:

SmartDashboard.putNumber("Lifter position", lifterMotor.getSelectedSensorPosition(0));

However, manipulating the data or passing a custom variable as such causes it to not output anything:

public static final double RPM = lifterMotor.getSelectedSensorVelocity(0) * (600/4096);
SmartDashboard.putNumber("Lifter position", RPM);

Even something like the following kills it:

SmartDashboard.putNumber("Lifter position", 3);

However, the following code on last year’s robot functioned when the SmartDashboard method was putDouble(). It’s now been refactored as putNumber():

SmartDashboard.putDouble("Gear Boi", Robot.armEye.getVoltage()*1000);

Does anyone know how to fix this? I’d like things to be as easy as when all I had to do was write putDouble().

You’re doing integer division - 600/4096 rounds down to zero instead of 0.146484 because both operands are of type ‘int’. Adding a “.0” or “D” to the end of at least one of the numbers will make it floating-point division and return the value you expect:


public static final double RPM = lifterMotor.getSelectedSensorVelocity(0) * (600.0/4096.0);
SmartDashboard.putNumber("Lifter position", RPM);

You’re also assigning the RPM value once, when the class is initialized. This may cause a NullPointerException if the lift motor hasn’t been initialized at that time. It should be a local variable, inside whatever method you’re putting the RPM into SmartDashboard.

Even something like the following kills it:

SmartDashboard.putNumber("Lifter position", 3);

How does that “kill it”? Is there no “Lifter position” entry? Is its value incorrect?

Writing ints as doubles fixed it for me! Thanks!