Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hanger Module Organization #35

Open
8 tasks done
dlezcan1 opened this issue Apr 1, 2024 · 16 comments · Fixed by #36
Open
8 tasks done

Hanger Module Organization #35

dlezcan1 opened this issue Apr 1, 2024 · 16 comments · Fixed by #36
Assignees
Labels
enhancement New feature or request

Comments

@dlezcan1
Copy link
Member

dlezcan1 commented Apr 1, 2024

This is a good start! Here's some suggestions

For the HangerModule class, can you implement the following:

  • MoveUp() -> Moves hanger module up
  • MoveDown() -> Moves hanger module down
  • Implement the initSendable(Builder) function for better modularity in implementing the ShuffleBoard elements

For the Hanger class, do the following

  • In HangStop() function, call the HangerModule.HangStop() functions instead of Move(0)
  • Implement GetLeftModule(), GetRightModule() to return access to the left and right hanger submoudles
  • Remove the (Left/Right)Hang(Up/Down/Stop/IsDown) commands and replace any bindings with Hanger.Get(Left/Right)Module().. This is a neater way to do this.
  • Change the Hanger.initSendable to use the HangerModule.initSenable with the Left/Right submodules named.
  • Change Hanger Speed variables to be static final
@dlezcan1 dlezcan1 added the enhancement New feature or request label Apr 1, 2024
@dlezcan1 dlezcan1 linked a pull request Apr 1, 2024 that will close this issue
@dlezcan1 dlezcan1 removed a link to a pull request Apr 1, 2024
@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 1, 2024

Almost there @jforchheimer25. Some things that will cause issue with the command scheduler is with your debug controller bindings.

debugController
.leftBumper() // Left Hanger arm down
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.leftHangerModule().MoveHangDown(),
() -> m_Hanger.leftHangerModule().HangStop()));
debugController
.a() // Left Hanger arm up
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.leftHangerModule().MoveHangUp(),
() -> m_Hanger.leftHangerModule().HangStop()));
debugController
.rightBumper() // Right Hanger arm down
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.rightHangerModule().MoveHangDown(),
() -> m_Hanger.leftHangerModule().HangStop()));
debugController
.b() // Right Hanger arm up
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.rightHangerModule().MoveHangUp(),
() -> m_Hanger.leftHangerModule().HangStop()));

Here, the Hanger submodule will cause a lock on the commands running and you won't be able to run each hanger arm at the same time. Thus, you would want to change it as an example:

debugController
        .leftBumper() // Left Hanger arm down
        .whileTrue(
            m_Hanger.leftHangerModule().runEnd(
                m_Hanger.leftHangerModule()::MoveHangDown,
                m_Hanger.leftHangerModule()::HangStop
             )
        );

This way, this won't cause for issues with the bindings.

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 1, 2024

Similarly, with the auto hang feature in the commands, it's missing the requirements needed to hold each of those hanger modules.

public Command LowerHangAuto() {
Command cmd =
Commands.parallel(
Commands.runEnd(
() -> rightHangerModule().MoveHangDown(),
() -> rightHangerModule().HangStop())
.until(() -> rightHangerModule().HangIsDown()),
Commands.runEnd(
() -> leftHangerModule().MoveHangDown(),
() -> leftHangerModule().HangStop())
.until(() -> leftHangerModule().HangIsDown()))
.finallyDo(this::StopHangers);
cmd.addRequirements(this);
return cmd;
}

Here, we would need to change it so that we are running

leftHangerModule().runEnd(leftHangerModule()::MoveHangDown, leftHangerModule()::HangStop)

and similary with the rightHangerModule.

Finally, you would need to require the hanger subsystem, so finally, you would take the Command cmd and addRequirements(this) inside this function to ensure that the hanger doesn't run anymore code.

Same with the Hanger.RaiseHangAuto function.

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 1, 2024

Finally, I think this might be a better method for adding the data to SmartDashboard.

public void initSendable(SendableBuilder builder) {
super.initSendable(builder);
m_IntakeWheels.initSendable(builder);

This can be changed in DriveTrain and Hanger and I believe that would be best. Double check it looks alright with the simulation when you're done.

This should be updated:

public void initSendable(SendableBuilder builder) {
super.initSendable(builder);
SmartDashboard.putData("Hanger/" + leftHangerModule().getName(), leftHangerModule());
SmartDashboard.putData("Hanger/" + rightHangerModule().getName(), rightHangerModule());
}

@jforchheimer25
Copy link
Member

jforchheimer25 commented Apr 2, 2024

Almost there @jforchheimer25. Some things that will cause issue with the command scheduler is with your debug controller bindings.

debugController
.leftBumper() // Left Hanger arm down
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.leftHangerModule().MoveHangDown(),
() -> m_Hanger.leftHangerModule().HangStop()));
debugController
.a() // Left Hanger arm up
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.leftHangerModule().MoveHangUp(),
() -> m_Hanger.leftHangerModule().HangStop()));
debugController
.rightBumper() // Right Hanger arm down
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.rightHangerModule().MoveHangDown(),
() -> m_Hanger.leftHangerModule().HangStop()));
debugController
.b() // Right Hanger arm up
.whileTrue(
m_Hanger.runEnd(
() -> m_Hanger.rightHangerModule().MoveHangUp(),
() -> m_Hanger.leftHangerModule().HangStop()));

Here, the Hanger submodule will cause a lock on the commands running and you won't be able to run each hanger arm at the same time. Thus, you would want to change it as an example:

debugController
        .leftBumper() // Left Hanger arm down
        .whileTrue(
            m_Hanger.leftHangerModule().runEnd(
                m_Hanger.leftHangerModule()::MoveHangDown,
                m_Hanger.leftHangerModule()::HangStop
             )
        );

This way, this won't cause for issues with the bindings.

Jared: Since this command is requiring the same sub? But if thats the case, isnt using the two modules twice requiring the same sub? (If i create the object twice does that get around the scheduler?)

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 2, 2024

That and you need to run it with the left/right hanger module subsystem, not the hanger subsystem.

@jforchheimer25
Copy link
Member

jforchheimer25 commented Apr 2, 2024

Im gonna commit in a sec, almost done with updates (probably at 11:45/12)
Ill text you when I do
Are you saying to add reqs within the parell for each also?

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 2, 2024

The only req you need to add with the parallel is the Hanger req. The others should run directly from the left/right hanger modules individually

@jforchheimer25
Copy link
Member

cmd.addRequirements(this);
return cmd;
}
)

So your saying this is fine?

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 2, 2024

That part, but the commands in parallel need to be updated.

@jforchheimer25
Copy link
Member

Very important photo
This is fine right

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 2, 2024

Should be fine.

@jforchheimer25
Copy link
Member

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 2, 2024

Create a pull request into Dev and I'll review there.

@jforchheimer25
Copy link
Member

The PR was created.

@dlezcan1 dlezcan1 linked a pull request Apr 2, 2024 that will close this issue
@jforchheimer25 jforchheimer25 moved this to Testing in @BLlakers's 2024 Apr 4, 2024
@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 5, 2024

@jforchheimer25 I reviewed. Comments need to be addressed.

@dlezcan1
Copy link
Member Author

dlezcan1 commented Apr 5, 2024

Please address the comments on the PR first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: Testing
Development

Successfully merging a pull request may close this issue.

2 participants