evil-mad / robopaint

The software for your friendly painting robot kit!
126 stars 34 forks source link

Major fill problems for intricate drawings with high quality settings (for pen) #109

Closed techninja closed 10 years ago

techninja commented 10 years ago

When doing test prints with highly intricate line drawings using penmode 3, drawing from SVG clipart using intricate settings, fill (or maybe stroke) occasionally draws huge lines very far out near the edge for no apparent reason. Very possibly related to stroke fill, but it's really awful and ruins prints. See here:

2013-10-12 01 47 15

oskay commented 10 years ago

Any idea what the root cause is? These lines are pretty distinctive; It should be possible to catch/identify/trap them with some method.

techninja commented 10 years ago

All of the terrible lines shown on the top example appear to be caused by an improperly calculated overshoot with certain compound paths. In the above commit I've completely removed the end path overshoot (as every quick fix I put in its place made things worse).

What probably needs to be put in place is some kind of line continuation falsifier that gauges the general direction we were going before we picked up and then to move in that direction times the overshoot multiplier. Yes, I could have sworn that's what I had intended to do, but the code sure didn't look at it. This path code again is some of the oldest in the codebase, and ripest for a rewrite.

gwygonik commented 10 years ago

I've had the same issue with both paint mode and pen mode with SVG exported from Processing (one big path data block, strokes only, no fill). There's also a few times the brush will go down, up, then down again before starting paths, making lines from the paint area to the start of paths. Pics attached show both.

I note in my SVG that the data has decimals out to 5-6 digits... Could there be floating point calculation issues with certain paths?

wcb_perlin_1 wcb_perlin_2

techninja commented 10 years ago

Troublesome! I doubt there's too much issue with rounding. My feeling is that it has something direct to do with tracing or path occlusion detection... or something. My path running algorithm is really quite naive and some part of subpath selection may be to blame.

Try breaking apart any compound paths, and pin down what different precision settings effect it. Also if you enable the experimental manual mode (Settings->Advanced->Modes->Manual Paint), you can turn off "Check Stroke Visibility" and this will follow the path "exactly" without avoiding overlaps.

If all this fails to help, post the simplest offending SVG code in this issue and we might just get this one squashed. Also if any of the above seems to help a bit, document it and post here as well, might better help point to where the real problem lies.

oskay commented 10 years ago

@gwygonik Can you post an example that we can test?

gwygonik commented 10 years ago

I had tried several different settings last night, but didn't run it in manual mode with the "check stroke visibility" turned off until today. Success! There seems to be another issue with running several back-to-back in manual mode, but I'm trying to reproduce and note the steps I'm taking; I'll post that elsewhere :-)

wcb_p_svg_1

gwygonik commented 10 years ago

Here's an SVG from Processing, the one from the first pictures. You'll have to copy/paste to a new file and save it; I can't attach a non-bitmap image.

I imported the SVG into RoboPaint and scaled to fit, then scaled down a bit, then centered before I printed.


<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g  style="fill:none;stroke:#000000;stroke-width:2.0;" >
<path d="M0.0 398.0668 L0.0 398.0668 L22.0 406.5449 L44.0 428.89484 L66.0 457.02673 L88.0 480.8913 L110.0 492.25037 L132.0 490.5653 L154.0 480.27982 L176.0 466.19995 L198.0 454.39993 L220.0 449.83386 L242.0 441.2644 L264.0 418.7337 L286.0 390.57077 L308.0 367.10135 L330.0 356.7463 L352.0 362.9167 L374.0 382.71146 L396.0 408.02597 L418.0 428.75946 L440.0 436.7154 L462.0 416.03333 L484.0 361.74408 L506.0 295.12024 L528.0 239.10594 L550.0 215.21486 L572.0 224.47156 L594.0 254.84343 L616.0 293.9107 L638.0 326.09958 L660.0 338.69327 L682.0 323.22437 L704.0 282.035 L726.0 231.2563 L748.0 190.91064 L770.0 177.20175 L792.0 173.64767 L814.0 158.65512 L836.0 138.74615 L858.0 122.163 L880.0 115.65272 L902.0 128.07275 L924.0 160.82816 L946.0 200.30568 L968.0 229.69429 L990.0 235.5767 L1012.0 235.44176 L1034.0 250.28172 L1056.0 272.2214 L1078.0 291.11807 M0.0 491.12976 L0.0 491.12976 L22.0 497.72058 L44.0 515.12006 L66.0 537.10126 L88.0 555.921 L110.0 565.2136 L132.0 563.7965 L154.0 554.57837 L176.0 541.9026 L198.0 531.26404 L220.0 527.14526 L242.0 517.23376 L264.0 491.1923 L286.0 458.69785 L308.0 431.74207 L330.0 420.09152 L352.0 428.45612 L374.0 453.9005 L396.0 486.1763 L418.0 512.535 L440.0 522.6386 L462.0 505.6619 L484.0 461.0665 L506.0 406.24307 L528.0 359.9161 L550.0 339.69998 L572.0 344.24792 L594.0 362.30762 L616.0 386.12186 L638.0 405.91122 L660.0 413.6745 L682.0 398.47882 L704.0 358.03488 L726.0 308.2198 L748.0 268.73737 L770.0 255.5243 L792.0 251.63551 L814.0 235.31311 L836.0 213.65034 L858.0 195.60973 L880.0 188.52768 L902.0 199.62436 L924.0 228.86519 L946.0 264.034 L968.0 290.052 L990.0 294.89868 L1012.0 292.50565 L1034.0 300.55234 L1056.0 313.86798 L1078.0 325.69177 M0.0 587.55493 L0.0 587.55493 L22.0 591.8021 L44.0 603.0509 L66.0 617.3805 L88.0 629.90283 L110.0 636.5725 L132.0 635.41833 L154.0 627.4575 L176.0 616.46844 L198.0 607.234 L220.0 603.6573 L242.0 592.08984 L264.0 561.7168 L286.0 523.8811 L308.0 492.63193 L330.0 479.39792 L352.0 490.49246 L374.0 522.9362 L396.0 563.82935 L418.0 597.1493 L440.0 609.9104 L462.0 597.50586 L484.0 564.86975 L506.0 524.5979 L528.0 490.2003 L550.0 474.47687 L572.0 473.1545 L594.0 475.95023 L616.0 480.87466 L638.0 485.31412 L660.0 487.09833 L682.0 472.25223 L704.0 432.76538 L726.0 384.1974 L748.0 345.85294 L770.0 333.3317 L792.0 329.10828 L814.0 311.21368 L836.0 287.44016 L858.0 267.635 L880.0 259.8594 L902.0 269.341 L924.0 294.2998 L946.0 324.24054 L968.0 346.21597 L990.0 349.92004 L1012.0 344.87372 L1034.0 344.6484 L1056.0 347.40356 L1078.0 350.54926 M0.0 681.4517 L0.0 681.4517 L22.0 683.7792 L44.0 689.98315 L66.0 698.0153 L88.0 705.3079 L110.0 709.70605 L132.0 708.61487 L154.0 701.53625 L176.0 691.80457 L198.0 683.6374 L220.0 680.4755 L242.0 667.5746 L264.0 633.71515 L286.0 591.586 L308.0 556.89844 L330.0 542.4222 L352.0 555.7641 L374.0 593.9055 L396.0 641.798 L418.0 680.7676 L440.0 695.6848 L462.0 686.96204 L484.0 663.951 L506.0 635.3761 L528.0 610.5316 L550.0 598.334 L572.0 592.15326 L594.0 582.50134 L616.0 572.0648 L638.0 564.0349 L660.0 560.96375 L682.0 546.42633 L704.0 507.79178 L726.0 460.3553 L748.0 423.08655 L770.0 411.29742 L792.0 406.9762 L814.0 387.96616 L836.0 362.60968 L858.0 341.45767 L880.0 333.14984 L902.0 341.36993 L924.0 363.0005 L946.0 388.92535 L968.0 407.9007 L990.0 410.98102 L1012.0 404.08978 L1034.0 397.44504 L1056.0 391.87408 L1078.0 388.1398 M0.0 767.995 L0.0 767.995 L22.0 769.541 L44.0 773.6785 L66.0 779.08777 L88.0 784.1089 L110.0 787.3357 L132.0 785.96484 L154.0 778.9492 L176.0 769.48035 L198.0 761.5812 L220.0 758.52966 L242.0 745.13184 L264.0 709.9769 L286.0 666.26434 L308.0 630.3345 L330.0 615.4625 L352.0 629.74176 L374.0 670.1306 L396.0 720.75305 L418.0 761.9168 L440.0 777.67004 L462.0 770.3185 L484.0 750.8822 L506.0 726.6217 L528.0 705.2274 L550.0 694.1555 L572.0 685.89746 L594.0 671.2904 L616.0 654.8268 L638.0 641.9305 L660.0 636.9678 L682.0 622.6007 L704.0 584.4501 L726.0 537.69446 L748.0 501.1513 L770.0 489.99182 L792.0 485.9842 L814.0 466.86563 L836.0 441.15762 L858.0 419.655 L880.0 411.20245 L902.0 419.03226 L924.0 439.6677 L946.0 464.49234 L968.0 482.8706 L990.0 486.32303 L1012.0 479.33902 L1034.0 470.7961 L1056.0 462.4862 L1078.0 456.40973 M0.0 830.86084 L0.0 830.86084 L22.0 830.9885 L44.0 831.39197 L66.0 832.1172 L88.0 833.19916 L110.0 834.6176 L132.0 834.13727 L154.0 830.24817 L176.0 824.82886 L198.0 820.2612 L220.0 818.4901 L242.0 807.1284 L264.0 777.3098 L286.0 740.2109 L308.0 709.6704 L330.0 696.9359 L352.0 708.5825 L374.0 741.8728 L396.0 783.673 L418.0 817.68506 L440.0 830.7045 L462.0 825.573 L484.0 811.9337 L506.0 794.6975 L528.0 778.9896 L550.0 769.91504 L572.0 762.0607 L594.0 749.12933 L616.0 734.88684 L638.0 723.8396 L660.0 719.6026 L682.0 706.15515 L704.0 670.48987 L726.0 626.90485 L748.0 593.1144 L770.0 583.3745 L792.0 581.92566 L814.0 568.69885 L836.0 550.1034 L858.0 534.3271 L880.0 528.09827 L902.0 531.9485 L924.0 541.99426 L946.0 553.7835 L968.0 561.8478 L990.0 561.8851 L1012.0 557.4761 L1034.0 554.167 L1056.0 551.99005 L1078.0 550.79443 M0.0 862.76953 L0.0 862.76953 L22.0 859.30994 L44.0 850.30273 L66.0 839.3342 L88.0 830.8208 L110.0 828.30005 L132.0 830.9462 L154.0 835.9597 L176.0 841.7114 L198.0 846.23126 L220.0 847.93854 L242.0 841.875 L264.0 825.93176 L286.0 805.99994 L308.0 789.38306 L330.0 782.03784 L352.0 786.586 L374.0 801.10596 L396.0 819.6615 L418.0 834.8552 L440.0 840.6849 L462.0 841.4573 L484.0 843.261 L506.0 844.81635 L528.0 844.5161 L550.0 841.24915 L572.0 835.0321 L594.0 827.01245 L616.0 819.0034 L638.0 813.0678 L660.0 810.82776 L682.0 799.6508 L704.0 770.07764 L726.0 734.14215 L748.0 706.7341 L770.0 699.7946 L792.0 704.126 L814.0 705.4927 L836.0 704.8556 L858.0 703.64185 L880.0 703.0816 L902.0 696.2732 L924.0 677.872 L946.0 654.3988 L968.0 634.02374 L990.0 623.5222 L1012.0 624.2525 L1034.0 633.1959 L1056.0 645.91986 L1078.0 656.7544 M0.0 882.5731 L0.0 882.5731 L22.0 874.7087 L44.0 854.15454 L66.0 828.86414 L88.0 808.65686 L110.0 801.45215 L132.0 808.1478 L154.0 824.3323 L176.0 844.02454 L198.0 859.8622 L220.0 865.8982 L242.0 866.37585 L264.0 867.56165 L286.0 868.81506 L308.0 869.36523 L330.0 868.6338 L352.0 864.3596 L374.0 855.63495 L396.0 845.42413 L418.0 837.3351 L440.0 834.27 L462.0 842.36145 L484.0 863.3158 L506.0 888.19214 L528.0 907.05786 L550.0 911.1041 L572.0 907.0457 L594.0 905.2196 L616.0 905.0129 L638.0 905.4586 L660.0 905.70935 L682.0 897.3069 L704.0 875.1676 L726.0 848.536 L748.0 828.8253 L770.0 825.1342 L792.0 836.39655 L814.0 855.6085 L836.0 877.01495 L858.0 893.70184 L880.0 900.1126 L902.0 880.0736 L924.0 826.34204 L946.0 759.0179 L968.0 703.1555 L990.0 679.2557 L1012.0 685.96576 L1034.0 709.7168 L1056.0 740.59045 L1078.0 766.1211 M0.0 913.64795 L0.0 913.64795 L22.0 902.22864 L44.0 872.3583 L66.0 835.5209 L88.0 805.9031 L110.0 794.96423 L132.0 804.99146 L154.0 830.2635 L176.0 861.2735 L198.0 886.29297 L220.0 895.8397 L242.0 901.60706 L264.0 916.6439 L286.0 935.02637 L308.0 949.452 L330.0 954.05676 L352.0 942.63086 L374.0 915.0879 L396.0 881.59424 L418.0 854.6624 L440.0 844.3992 L462.0 858.4182 L484.0 894.88416 L506.0 938.65564 L528.0 973.06323 L550.0 983.0663 L572.0 980.79474 L594.0 984.0158 L616.0 990.1505 L638.0 995.77765 L660.0 998.05023 L682.0 991.8829 L704.0 975.72876 L726.0 956.5789 L748.0 943.0381 L770.0 941.91113 L792.0 958.7168 L814.0 992.30786 L836.0 1031.5018 L858.0 1062.6406 L880.0 1074.6805 L902.0 1043.921 L924.0 961.556 L946.0 858.6767 L968.0 774.00446 L990.0 739.1538 L1012.0 750.59 L1034.0 786.2197 L1056.0 831.6962 L1078.0 869.0642 M0.0 974.9278 L0.0 974.9278 L22.0 962.1519 L44.0 928.72675 L66.0 887.4845 L88.0 854.2794 L110.0 841.92224 L132.0 853.2299 L154.0 881.9802 L176.0 917.31903 L198.0 945.84924 L220.0 956.7383 L242.0 964.5257 L264.0 984.8523 L286.0 1009.77594 L308.0 1029.4998 L330.0 1036.1406 L352.0 1021.98096 L374.0 987.24817 L396.0 944.8598 L418.0 910.72974 L440.0 897.7166 L462.0 914.00073 L484.0 956.3943 L506.0 1007.3871 L528.0 1047.7363 L550.0 1060.0205 L572.0 1058.4373 L594.0 1063.5914 L616.0 1072.1526 L638.0 1079.7616 L660.0 1082.8074 L682.0 1077.4924 L704.0 1063.6204 L726.0 1047.3217 L748.0 1036.1293 L770.0 1035.9725 L792.0 1054.8862 L814.0 1093.9614 L836.0 1139.9429 L858.0 1176.5977 L880.0 1190.786 L902.0 1155.9293 L924.0 1062.6202 L946.0 946.1485 L968.0 850.4575 L990.0 811.408 L1012.0 824.6334 L1034.0 864.78577 L1056.0 915.8286 L1078.0 957.7105 "/>
</g>
</svg>
oskay commented 10 years ago

For this particular drawing-- just lines --it might be better to paint it from Inkscape.

A couple of questions occur to me: Why was it trying to draw a rectangle around the shapes? Is this related to Issue #21 ?

oskay commented 10 years ago

Labeling this issue priority-high.

gwygonik commented 10 years ago

I'll give the Inkscape route a whirl, too.

And sorry -- I had manually placed a rectangle around the SVG to give it a border. Some were painted at the same time, some were two-step paintings: paint SVG, paint a box. No relation to #21.

techninja commented 10 years ago

Augh, OK.. found the culprit.. Same problem as earlier, ish. The path visibility check combined with the path end delta stroke overshoot _combined_ with the sub-paths = crazy long path overshoots to bad locations. Also it seems some part of the path visibility check is giving bad results, will be looking into it.

For now I may just rip out the overshoot code until something better comes along. It really works well 90% of the time, a bit sad it keeps failing so hard on edge-cases.

gwygonik commented 10 years ago

I really like the path end overshoot; compared to the choppiness of Inkscape path ends, it's awesome. Perhaps clamping the overshoot at a maximum distance and a maximum angle away? In other words, if the overshoot is > 1% of stroke and > 15-degrees from vector, stay going the old vector and move 1%.

techninja commented 10 years ago

I had actually attempted that with the first version of the commit at https://github.com/evil-mad/robopaint/commit/28a19b07b referenced above, but I kept seeing the stray paths continue show up. I really just wanted to get rid of all that and feel better about probably the worst bug in RoboPaint be slain, but you're right, the overshoot really is helpful.

How about this, I'm going to attempt to refactor it in a way that preserves its abilities, but completely changes the way in which it works to avoid this exact problem. This might even be a good step forward toward better brush simulation and sharp angle management.

oskay commented 10 years ago

@gwygonik With regards to the "choppiness," are you referring to the lack of lead-in when re-inking ( evil-mad/wcb-ink#13 ) or is this a separate problem? I was not aware of any issues at the path ends themselves.

gwygonik commented 10 years ago

@oskay Sounds about right -- unlike RoboPaint, Inkscape has small gaps between stop and start points when reloading paint in the middle of a path. Actual ends of paths are okay.

oskay commented 10 years ago

@gwygonik Thanks! We'll see what we can do about that one. ;)

techninja commented 10 years ago

The workflow for issues if it wasn't clear, is that I close by commit (to match it to the issue), then you should come back and retest when the December release comes out (in the next few days). Re-open if the bug returns and mark down any new port of the issue, or be kind and leave a note that you've found it now fixed :)

techninja commented 10 years ago

Just to give an update: We'll be taking @makersylvia, the bot and RoboPaint off to RobotsConf in Florida this weekend to do a keynote, and I hope to have the release out before I have to pack, but this release is carrying a LOT with it right now: CNC Server experimental command buffering, NW upgrade past 3 major versions, complete restructure of node-serialport code for windows.. It's crazy.

I'm currently working out some very odd drawing and latency issues in Windows only, and as soon as I can polish those out, it's release time! Of course I have 5 different systems to build for... makes me a little worried. Perhaps it's moments like these where mitigating risk is the best option. Perhaps tomorrow night? Fingers crossed! :horse_racing: