nhs-t10 / Robotics_2021_2022

2 stars 0 forks source link

Make a MostlyNodesDualControllers #40

Closed chlohal closed 2 years ago

chlohal commented 2 years ago

Relates to #27.

Right now, we have a bunch of if/else in the loop method. Right now, all of this has to be executed in sequence, meaning that we can't take advantage of parallelism to speed up our code.

Of course, the code is great as-is! Simplifying isn't a choice that we needed to make until we started bumping up against performance limits.

The first step towards fixing this is hammering into a more "pure" format.

For example, image

image This code only uses simple ButtonNode. We can make this better by using a ToggleNode (and fixing the weirdness of scaleUp/scaleDown)-- then, it'd just be

input.registerInput("precisionDriving", new IfNode(
    new ToggleNode(new ButtonNode("b")), //if it's toggled on, then
    new StaticValueNode(0.1), //return 0.1
    new StaticValueNode(1f) //otherwise (if toggled off) return 1
));
input.registerInput("dashing", new IfNode(
    new ToggleNode(new ButtonNode("x")), //if it's toggled on, then
    new StaticValueNode(1f), //return 1
    new StaticValueNode(0.6f) //otherwise (if toggled off) return 0.6
));
driver.setScale(Math.min(input.getFloat("precisionDriving"), input.getFloat("dashing")));