acmerobotics / ftc-dashboard

React-based web dashboard designed for FTC
https://acmerobotics.github.io/ftc-dashboard
Other
171 stars 129 forks source link

Graph View - telemetry keys flicker and reorder when keys differ on every packet #56

Closed NoahBres closed 2 years ago

NoahBres commented 3 years ago

Key selection flickers and reorders. Implement opmode lifecycle aware key caching like PR #55

https://user-images.githubusercontent.com/6739076/111059465-5a7d8d00-845b-11eb-9fee-7de84954b458.mp4

Opmode code causing this behavior:

@Config
@TeleOp
class RampTest : LinearOpMode() {
    companion object {
        @JvmField
        var INCREASE = 0.005

        @JvmField
        var paused = false
    }

    var progress = 0.0
    var increasing = true

    var counter = 0

    override fun runOpMode() {
        telemetry = MultipleTelemetry(telemetry, FtcDashboard.getInstance().telemetry)

        waitForStart()

        while (!isStopRequested) {
            telemetry.clear()

            if (gamepad1.a) {
                paused = true;
            } else if (gamepad1.b) {
                paused = false;
            }

            if (!paused) {
                if (increasing)
                    progress += INCREASE;
                else
                    progress -= INCREASE;

                if (progress >= 100)
                    increasing = false;
                else if (progress <= 0)
                    increasing = true;

                telemetry.addData("x", SineWaveOpMode.AMPLITUDE * Math.sin(
                        2 * Math.PI * SineWaveOpMode.FREQUENCY * runtime + Math.toRadians(SineWaveOpMode.PHASE)
                ))
                telemetry.addData("progress", progress)
            }

            counter++
            if (counter % 3 == 0)
                telemetry.addData("three", counter)

            val fizz = if (((counter % 5) == 0) && ((counter % 7) == 0))
                "fizzbuzz"
            else if ((counter % 5) == 0)
                "fizz"
            else if ((counter % 7) == 0)
                "buzz"
            else
                counter

            telemetry.addData("fizz", fizz)

            if(counter % 5 == 0)
               telemetry.addLine("Sonata No. " + counter)

            telemetry.update()
        }
    }
}

Flickering just caused because telemetry is cleared on every loop and the same data keys aren't added every time. If you encounter this problem just be sure to add the same data keys every time.

rbrott commented 2 years ago

Fixed in master :+1: