ad-1 / 3DKinematicsVisualisation

Mechanics projects in Python
5 stars 2 forks source link

Please provide SW version info #1

Open riverbend305 opened 2 years ago

riverbend305 commented 2 years ago

Hi Andrew, This tutorial is very informative but I am encountering an error at line #402 of 'kinematics_visualization.py' Perhaps this is a python versioning issue. Please add the version number of python and each of the packages that you used to your documentation.

Specifically I am getting the following error on macOS 10.15.7 (Catalina) and python 3.10.7:

Traceback (most recent call last): File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/venv/lib/python3.10/site-packages/matplotlib/cbook/init.py", line 307, in process func(*args, *kwargs) File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 899, in _start self._init_draw() File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 1706, in _init_draw self._draw_frame(frame_data) File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 1728, in _draw_frame self._drawn_artists = self._func(framedata, self._args) File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/3DKinematicsVisualisation/kinematics_visualization.py", line 402, in visualize self.center_of_curvature.set_3d_properties(self.simulation_results['rcz'][i]) File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/venv/lib/python3.10/site-packages/mpl_toolkits/mplot3d/art3d.py", line 175, in set_3d_properties zs = np.broadcast_to(zs, len(xs)) TypeError: object of type 'numpy.float64' has no len()

-Joe

riverbend305 commented 2 years ago

Sorry I didn't notice your requirements.txt file. The following almost worked for me:

sudo port install ffmpeg python3 -m venv venv source venv/bin/activate pip install -r requirements.txt python kinematics_visualization.py # Note I renamed your file

Result: plt.show() works as expected

But the following code hangs after creating a gif of an single frame:

os.makedirs('./animations', exist_ok=True) FFwriter = animation.FFMpegWriter(fps=30) anim.save('./animations/spiral_trajectory.gif', writer=FFwriter)

The following error message is generated due to my closing the plot window after the program hangs:

KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/3DKinematicsVisualisation/kinematics_visualization.py", line 451, in anim.save('./animations/spiral_trajectory.gif', writer=FFwriter) File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/3DKinematicsVisualisation/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 1155, in save with mpl.rc_context({'savefig.bbox': None}), \ File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/3DKinematicsVisualisation/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 238, in saving self.finish() File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/3DKinematicsVisualisation/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 347, in finish self._cleanup() # Inline _cleanup() once cleanup() is removed. File "/Users/joe/Desktop/guiEditor/LI-iNavPO/pythonDir/3DKinematicsVisualisation/venv/lib/python3.10/site-packages/matplotlib/animation.py", line 378, in _cleanup raise subprocess.CalledProcessError( subprocess.CalledProcessError: Command '['ffmpeg', '-f', 'rawvideo', '-vcodec', 'rawvideo', '-s', '1500x800', '-pix_fmt', 'rgba', '-r', '30', '-loglevel', 'error', '-i', 'pipe:', '-filter_complex', 'split [a][b];[a] palettegen [p];[b][p] paletteuse', '-y', './animations/spiral_trajectory.gif']' returned non-zero exit status 255.