GazzolaLab / PyElastica

Python implementation of Elastica, an open-source software for the simulation of assemblies of slender, one-dimensional structures using Cosserat Rod theory.
https://www.cosseratrods.org
MIT License
229 stars 110 forks source link

Visualization bug of lacking Povray #66

Closed woshizh951 closed 2 years ago

woshizh951 commented 2 years ago

Describe the bug I want to run the example of snake visualization, the scripting process is running correctly. However, when the rendering process begin, Some error occured. File "G:\study\pyelastica\PyElastica-master\examples\Visualization\ContinuumSnakeVisualization_povmacros.py", line 138, in render

To Reproduce

from line 127 to 139
<script>
    process = subprocess.Popen(
        cmds, stderr=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE
    )
    _, stderr = process.communicate()

    # # Check execution error
    if process.returncode:
        print(type(stderr), stderr)
        raise IOError(
            "POVRay rendering failed with the following error: "
            + stderr.decode("ascii",'ignore')

        )
<error>

Environment

Expected behavior I hope to run the visualization correctly. And I would like to simulation the manipulation of deformable linear objects(cable) by the pyelastca, would you please give me some advice?

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

skim0119 commented 2 years ago

Hi @woshizh951

It appears to me that POVray does not provide CLI for Windows 10 (https://github.com/POV-Ray/povray/issues/227). The script above assumes POVray available on CLI, which is why you are getting an error.

Suggestion

  1. Remove any .pov file created: remove frames/diag or frames/top directory.
  2. Modify https://github.com/GazzolaLab/PyElastica/blob/dd1bff433e7789914939e11eb6db90cfd60eee71/examples/Visualization/ContinuumSnakeVisualization/continuum_snake_render.py#L79-L83 to represent global path. For example
    included = ["C:\\Users\\mattia-lab\\Downloads\\PyElastica-master\\examples\\Visualization\\default.inc"]
  3. run python continuum_snake_render.py. It is okay to get an error, as long as .pov files are created properly. They should be created in the directory frames\diag and frames\top.
  4. Render .pov files on POVray

On POVray windows, you can run batch-rendering by pressing alt-Q

image

image

image


After generating all the frames, you can combine images to make movie. We use moviepy in the script to do so:

https://github.com/GazzolaLab/PyElastica/blob/dd1bff433e7789914939e11eb6db90cfd60eee71/examples/Visualization/ContinuumSnakeVisualization/continuum_snake_render.py#L183-L194

skim0119 commented 2 years ago

I am closing this issue. @woshizh951 Please feel free to reopen this issue or create a new one if you have further questions.

woshizh951 commented 2 years ago

Thank you so much, i can render the simulation through you tutorial now.