Layer that does not go home

Home Evil Mad Scientist Forums AxiDraw Layer that does not go home

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #29764
    CliffStoll
    Participant

    Is it possible to use the Axidraw CLI Layer command and, at the end of plotting an Inkscape layer, return the x,y coordinates, and then simply stop (without going Home)?

    Use case: I am plotting a half-dozen Inkscape layers, and have a pen-changing mechanism. Right now, at the end of each layer, Axidraw goes home; I then issue manual walk commands to change pens, then a manual walk command to return home. Then the next layer begins. So it travels home often, which wastes time.

    It would be much faster if, at the end of a layer, the pen did not return home. Instead, give me the x,y coordinates, I’ll do my manual walks, and finally put Axidraw at home, ready for the next layer.

    Thanx! =Cliff

    #29765
    Windell Oskay
    Keymaster

    In a way, yes, by either “properly using” or “hacking” the pause and resume capabilities, depending on exactly what you need. We’ve helped a few other people build workflows around this.

    You can force the AxiDraw to pause — just as though you had pressed the pause button — by adding a layer that has a name beginning with an exclamation point. It will stop where it is at, and then raise the pen. That’s part of the AxiDraw Layer Control syntax:
    https://wiki.evilmadscientist.com/AxiDraw_Layer_Control

    If you collect the output SVG that the CLI can return, that SVG contains a plotdata element that includes the position where it was paused as well as the “current” machine position.

    If you use manual walks to return the AxiDraw to the position where it was paused, you can directly use the resume capability, without any modifications to the file, to resume from that point.

    If you use manual walks to end up at Home, you can then plot in res_home mode *with preview enabled* and collect the output SVG: That will update your SVG to show that the “current” machine position, as saved in the SVG file is now Home. From there, you can use res_plot mode to continue plotting from that point. This would require only adding one empty layer (per pen change) to your SVG file,

    (And the hack part: If you use manual walks to end up at a new position that isn’t Home, you could modify the file to indicate the new current position to resume from.)

    Two alternate approaches that you might consider:
    (1) If the pen change operation can be coded as graphical information, or perhaps graphical plus some layer control codes, then consider building those into the file. SVG is pretty easy to code by hand, if that helps.

    (2) The AxiDraw Python API can both plot SVG (doing all of the things that I listed above) as well as do more complex moves in interactive context. Note that if you switch back and forth between Plot and Interactive contexts, it will assume that you’re starting at (0,0) for each. But, it makes it much easier to read out the actual position, so doing complex moves and then returning home might be easier.

    #29769
    CliffStoll
    Participant

    Many thanks Windell!

    I’m playing with the exclamation point naming; works just as you say for the Plot command.
    But an exclamation point named layer seems to be skipped over when used in the bash cli:
    axicli filename.svg –mode layers –layer 1 layer –norotate etc
    ## after this command, the pen is at Home.

    axicli filename.svg –mode layers –layer !2 layer –norotate etc
    ## nothing is plotted by this command.

    What I’m trying to do is:
    axicli filename.svg –mode layers –layer 1 layer –Don’t_Go_Home
    ## after this command, the pen is up and at end of the layer 1

    axicli –Get_X_Y_Position X, Y
    ## return the pen location

    ## now I calculate the position to walk to and then walk to the pen change location, do the pen change, and walk back to X, Y

    ## then plot the next layer, without ever going home.

    (notice that I’m trying to avoid learning svg coding — guess I may have to)

    Best wishes, -Cliff

    #29770
    Windell Oskay
    Keymaster

    My suggestion was to use the plot mode, possibly in combination with the res_home and/or res_plot modes, not to use the layers mode.

    Using the plot and res_plot modes should be sufficient to walk through an entire file, in order, with programmatic pauses and moves, without ever moving back to home during the sequence. (In a sense, using Layers mode is an “opposite” strategy to manage flow through the document.)

    Additionally there does appear to be a bug that the programmatic pauses are not working with the layers mode. (I can see what the issue is and I will log a bug for it; should be an easy fix in the next release.)

    There is not a “Get_X_Y_Position” feature at present; for subtle reasons this is a little more tricky that it might seem. We’ll look into the best approach, it may be to read out the paused position from a file.

    Here is a “quick and dirty” way for you to implement that yourself:
    (1)
    Open up the main axidraw.py script from your python installation in a text editor. (Mine via homebrew is at: /opt/homebrew/lib/python3.9/site-packages/axidrawinternal/axidraw.py)

    (2) In resume_plot_setup(), after the self.f_curr_y = [...] line, (Line 496 as of AxiDraw 3.1.0) add this line with the same indent, then save.
    self.user_message_fun(str(self.f_curr_x) + ', ' + str(self.f_curr_y))

    (3) With that added, the res_plot and res_home modes will both print out the initial position when they run. You can thus use:

    axicli paused_file_name.svg -m res_home -v to print out the position where the plot was paused.

    • This reply was modified 2 years, 10 months ago by Windell Oskay.
    • This reply was modified 2 years, 10 months ago by Windell Oskay.
    #29773
    CliffStoll
    Participant

    I’m confused.

    I thought that –mode plot meant that the entire file would be drawn. All layers. It’s unclear to me how to interrupt a drawing other than to press a button. ie, what command do I use to say, “After writing FRAGILE, pause”

    How is a plot interrupted? Ie, after writing the first few characters, I can push the pause button. But how do I do this programmatically?

    Thanx!

    #29774
    Windell Oskay
    Keymaster

    The exclamation point on a new layer acts almost exactly as though you had manually pressed the pause button: It stops the plot at that point.

    So, what you would do is put “FRAGILE” on a layer, then add a new layer on top of that, with a name like “! Pause after fragile”.

    #29775
    Windell Oskay
    Keymaster

    Let me give a more full example, in case that helps.

    Here’s a test file: https://evilmadscientist.s3.amazonaws.com/scratch/reverse_and_joins5_pause.svg

    Its layer names, bottom to top, are “2”, “!”, “1” and “layer 3”.

    I can start to plot it with:
    axicli reverse_and_joins5_pause.svg -o output.svg

    That plots layer “2”, alone, and then stops, just as you had pressed the pause button.

    We then resume the file with:
    axicli output.svg -m res_plot -o output2.svg

    That plots layers “1” and “layer 3”, resuming from where it was paused, without returning home.

    You can also test these workflows in preview mode, with preview rendering turned on, to see which parts of the file are plotted each time that you do so.

    #29776
    CliffStoll
    Participant

    And, I’m guessing, plot with –mode plot
    without specifying any layer?

    (I assume this will plot in bottom-to-top order as seen in the Inkscape layer sidebar)

    #29777
    Windell Oskay
    Keymaster

    Yes. And, since plot is the default mode, you don’t need to specify it.

    Yes, layer order is “bottom to top” in Inkscape’s display. That matches order of creation (putting “one thing on top of another”) and is equivalent to performing actions in the order in which they appear in the SVG file.

    #29795
    Windell Oskay
    Keymaster

    We’ve just released software version 3.2, which fixes the bug with programmatic pauses in layers mode. It also changes the initialization sequence when enabling the motors such that the QS EBB command can be used to read out the position.

    Here are two short python scripts, usually runnable on a Mac CLI as:
    python3 report_pos_inch.py or python3 report_pos_mm.py that will print the XY position after being paused:

    https://bcdn.evilmadscientist.com/scratch/report_pos_scripts.zip

    #29798
    CliffStoll
    Participant

    *** MANY THANKS WINDELL ***

    Just got v 3.2.0 of Axidraw s/w and th latest Inkscape. Time to play!

    Cheers,
    -Cliff

    #29879
    CliffStoll
    Participant

    Just working on this and find that script

    report_pos_inch.py

    does, indeed, return the x,y position of the pen.

    However, when the script is run a second time (without any intervening motion), it returns 0,0

    Shouldn’t it return the same position?

    Thanx!
    -Cliff

    #29880
    Windell Oskay
    Keymaster

    Hi Cliff,
    It should indeed return the same position. And, in my test here, it does.

    Is there any chance that you only updated the Inkscape-based software to 3.2, but not the API? (They’re actually independent.)

    You can test with axicli --version

    #29882
    CliffStoll
    Participant

    As usual, I’m confused.

    using instructions at wiki.evilmadscientist.com/Axidraw_Software_Installation

    I downloaded and installed AxiDraw_Install_321.app
    and also
    Update EBB.app
    and also
    Inkscape-1.1.2.dmg
    from Inkscape/Axidraw Control/Options/Config/apply
    I see this:
    This is AxiDraw Control version 3.2.1.
    Your AxiDraw Control software is up to date.

    Your AxiDraw has firmware version 2.8.0.
    Your firmware is up to date; no updates are available.

    Additional system information:
    3.8.5 (default, Sep 8 2020, 23:22:40)
    [Clang 11.0.0 (clang-1100.0.33.17)]

    But from my bash cli script,
    axicli –version
    I see:
    AxiDraw Command Line Interface 3.1.0
    AxiDraw Software 3.1.0

    What should I be doing?

    #29883
    Windell Oskay
    Keymaster

    Inkscape uses its own bundled Python, and the AxiDraw software for Inkscape is essentially only available within Inkscape.

    For the Python/CLI API, use the upgrade instructions from its installation instructions ( https://axidraw.com/doc/cli_api/#installation ):

    python -m pip install https://cdn.evilmadscientist.com/dl/ad/public/AxiDraw_API.zip --upgrade --upgrade-strategy eager

    (For my system, I actually use python3 -m pip [...])

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.