-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add States to drive #70
Conversation
linglejack06
commented
Feb 4, 2025
•
edited
Loading
edited
- add lineup state to handle lineup logic, otf for otf, joystick for joystick
- add intakeLocation and goToIntake to help determine when we want coral station vs reef / processor for otf
@jkleiber @aidnem how do i make a state transition to another state upon a condition being met? ie if cancel otf i want joystick state, or if otf completes then i want lineup also, what should even go into JoystickState, should i just make drive with joysticks send its inputs there and then joystick state can setGoalSpeeds? |
@linglejack06 for the state transition question, I assume we could set a flag from a command that each state can either handle or not depending (for example, setting otf flag would trigger joystick state to attempt to transition to otf state. Likewise if otf flag goes false otf would fire the edge to go to joystick state) As for the drive with joysticks, I would keep sending to the overall subsystem and pass those inputs into the joystick state I think |
@jkleiber so just set goal speeds in drive for joysticks, but from state or command? |
@linglejack06 if I understand correctly, the way it currently works is that drive with joysticks sends Drive some goal speeds and they get applied So what we should do is pass those goal speeds to the relevant state(s) and have them apply it when they run their periodic. Otherwise they just get ignored So short answer: command the states |
@jkleiber @avidraccoon how do i run the onEntry functions? also, how can i re run on entry? for example, if we change location in the middle of otf, i want to rerun its onEntry (which schedules the otf command) so it can go to the new location. Do i have to fire state to cancel and then refire the otf state? |
also, can i cancel a state from within that state, ie if lineup is running but it cant find a tag then i want to go back to joysticks. this logic is in the lineup state though, not drive, so i cant fire a trigger |
@linglejack06 take a look at scoring subsystem for how to fire triggers in states. @aidnem has been passing the subsystem to the state constructors 4o do this |
yeah, i saw after looking further, do you mind checking over the states to
see if thats how you want it structured?
…On Wed, Feb 5, 2025 at 8:59 AM Justin Kleiber ***@***.***> wrote:
@linglejack06 <https://github.com/linglejack06> take a look at scoring
subsystem for how to fire triggers in states. @aidnem
<https://github.com/aidnem> has been passing the subsystem to the state
constructors 4o do this
—
Reply to this email directly, view it on GitHub
<#70 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZ7J5PR5NOVATAFTW7B774D2OIKNRAVCNFSM6AAAAABWPEJRQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZWHEZTANBSGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Also on the on entry stuff I think that gets configured as part of the transition. You can also run the action again via the run on entry function in the state superclass I think? I'd need to take a look on a real code editor to be sure I'll take a look at the state structure later today |
ok, ive temporarily configured this function by just running on entry whenever the pose configured is different from drives desired location pose. |
@jkleiber regarding the joystick command state thing. I dont think i can command the state as there is no way to grab the instance of the state and send it things through robot container or init bindings... unless im missing something therefore, right now i just have setGoalSpeeds to only allow joystick speeds (field centric) if we are in joystick state.
|
also, on entry doesnt seem to be running, my otf state only began working once i added state machine periodic to drive periodic and i called otfState.onEntry in otf state periodic |
That is a known problem, and there is a branch on coppercore with an almost finished fix. |
The branch is for a few broken parts of the state machine I could also fix the not being able to pass variable in that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super high level feedback, hopefully this helps with the problems you're seeing
return latestObservation.alongTrackDistance() < 0.01 | ||
&& latestObservation.crossTrackDistance() < 0.01; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend making these thresholds JSON configurable
Because you defined the transition to lineup second is the only reason that this happened between these two states |
I have made a fix on the quickfix-statemachine branch, please let me know if it works or not |
It also fixes the onEntry problem |
does on exit work too @avidraccoon
…On Thu, Feb 6, 2025 at 12:22 PM avidraccoon ***@***.***> wrote:
It also fixes the onEntry problem
—
Reply to this email directly, view it on GitHub
<#70 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZ7J5PQB2D3P7PIWIZSWGXL2OOK5JAVCNFSM6AAAAABWPEJRQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBQGUZDKNBSG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I believe because I have no evidence to say they don't and I fixed the problem onEntry had also for onExit. |
@jkleiber state works now, but sometimes it doesn't like going straight to lineup due to thinking it's not close enough to otf pose. Ie if manually driving close and then clicking, it tries otf because the pose is not close enough to final pose (it's closer) can you think of any logic to change this behavior? If I increase distance pose can be from final pose it doesn't help |
@linglejack06 I'm confused about the issue. If you're close enough to the OTF then lineup should happen automatically. Are you saying that the robot is closer to the reef than the OTF pose is so it goes backwards? We could use the field finder utils in coppercore to see if you're already "on the runway" by seeing if you're in a certain rectangle. You'd need to define those rectangles but it could be a good add to skip OTF |
@jkleiber update: found logic that works by just checking if driveToPose command is finished, if so we fire beginLineup trigger. Drive now transitions through all states, and can even reroute otf if changing desired location mid state I think this should be ready for review and merge once I push |
trim.1EC55359-CBEF-4766-A11A-7215C0A4CAC6.MOV |
Hold on review actually, I need to figure out why josh rotation isn't working anymore |
@jkleiber ready for review
|
also, build failing due to need of new coppercore release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some quick things to knock out before we merge this.
Also please update coppercore when able. I created a ticket for follow on improvements to the state machine
release published on coppercore, should fix build soon |