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

Refactor Plan to include pen up/down positions. #110

Open
jedahan opened this issue Oct 11, 2023 · 0 comments
Open

Refactor Plan to include pen up/down positions. #110

jedahan opened this issue Oct 11, 2023 · 0 comments

Comments

@jedahan
Copy link
Collaborator

jedahan commented Oct 11, 2023

Scratchpad discussion for refactoring to move pen positions out from the individual motions, to the plan

/// current data in Plan class
class Plan {
  motions: Array<XYMotion|PenMotion>
}

class PenMotion {
  public initialPos: number;
  public finalPos: number;
  public pDuration: number;
}

I would suggest the following refactoring

  • Remove pDuration from PenMotion, and when executing motions, calculate the duration based on the current known position
  • Remove initialPos from PenMotion, as it is ignored when executing the S2 ebb command
  • Remove finalPos, and add a PenDirection enum that is either UP or DOWN
  • Store the pen up and down positions in the Plan, and index on the newly created direction enum
class Plan {
  motions: Array<XYMotion|PenMotion>
  positions: {
    up: number
    down: number
  }
}

enum PenDirection { UP: "UP", DOWN: "DOWN" }

Speculated impact

  • We no longer need the hack in the fast replanning - we can just add penUp and moveToOrigin to the plan executor
  • We no longer have the ability to move the pen to arbitrary positions in the plan, only whatever up/down is defined
  • We can remove a large amount of code
  • Less memory usage during serialization
  • More CPU used during execution

What else should we consider?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant