Giter Club home page Giter Club logo

Comments (8)

Starlight220 avatar Starlight220 commented on August 17, 2024

I feel like the use cases can be implemented using the name field, without needing to tack on another metadata field

from allwpilib.

ArchdukeTim avatar ArchdukeTim commented on August 17, 2024

Also this likely wouldn't fix the issue of compositions without the same issue being fixed for normal names

from allwpilib.

LightspeedLazer avatar LightspeedLazer commented on August 17, 2024

I feel like the use cases can be implemented using the name field, without needing to tack on another metadata field

Yes, this is true, however the issue comes when commands are composed. When commands are composed they lose their name (and thus the data stored in the name). Because tags would be inherited by the composing command, the data isn't lost.

Also this likely wouldn't fix the issue of compositions without the same issue being fixed for normal names

I not sure how you would fix the issue of compositions with normal names. Lets take the example of sequencing 3 commands:

Commands.sequence(command1, command2, command3);

What would the name of the composed command be? Currently it's just "SequencedCommandGroup", which doesn't provide any unique data. If the suggested name is "[command1.getName()], [command2.getName()], [command3.getName()]", this is far from readable (the main purpose of command names).
With tags, the name of the composed command could be anything (e.g. "Quick Auto", "Auto Drive To Amp", etc.), while still maintaining the unique data contained in the tags. The tags would also be able to be common across multiple commands (e.g. "Intake Deployed" could be common for the intake commands "Intake", and "Eject").

from allwpilib.

PeterJohnson avatar PeterJohnson commented on August 17, 2024

Why can’t you just decorate using .withName()? Eg Commands.sequence(a,b,c).withName(“quick auto”)?

from allwpilib.

LightspeedLazer avatar LightspeedLazer commented on August 17, 2024

Why can’t you just decorate using .withName()? Eg Commands.sequence(a,b,c).withName(“quick auto”)?

You can, but it still has lost the data from the commands inside.

from allwpilib.

LightspeedLazer avatar LightspeedLazer commented on August 17, 2024

Here's a real case where these tags would be useful. In our (Team 686) code, we have a shooter subsystem (only controls the flywheels) and a kicker subsystem (rollers that push the note into our flywheels). Lets say that we want to implement an auto-shoot trigger that will schedule Kicker.kick() when the flywheels are at speed. However, our shooter is also responsible for placing the note in the amp and has a separate command for that case. When we want to amp we don't want this auto-shoot trigger to fire (because we might still be trying to align to the amp). If we have tags then the trigger is as simple as this:

new Trigger(shooter::atDesiredSpeed).and(() -> shooter.getCurrentCommand().hasTags(Shooter.AUTO_SHOOT_TAG)).onTrue(kicker.kick());

In our shooter commands, we would have only the commands that are attempting to fire at the speaker have the auto-shoot tag.
The benefit of over other ways is that if we compose the shooter command with other commands (e.g. shooter.autoAim().alongWith(pivot.autoAim(), drive.autoAim())) the composed command still retains the Shooter.AUTO_SHOOT_TAG data and the trigger still works (without having to remember to make sure the parallel command name contains some arbitrary string or to wrap shooter.autoAim() in a proxy).

from allwpilib.

ArchdukeTim avatar ArchdukeTim commented on August 17, 2024

I imagine other will say that basing triggers not off the state of the system but off the state of the command schedule is an anti-pattern.

Why not have

new Trigger(shooter::preppedForShot).onTrue(kicker.kick());

and preppedForShot handles checking for the right state

from allwpilib.

LightspeedLazer avatar LightspeedLazer commented on August 17, 2024

I imagine other will say that basing triggers not off the state of the system but off the state of the command schedule is an anti-pattern.

Is the command not the state of the system? From my point of view the command scheduler is a beefed-up state machine without the convenience of easy state checking.

Why not have ... and preppedForShot handles checking for the right state

How would preppedForShot do this without checking the name of the command nor checking toggle flags (that the commands have to remember to set and reset).

I have realized a potential issue with tags where a sequenced command will have the tags of commands that might not be currently running, which might cause undesired behavior.

from allwpilib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.