pyswarming icon indicating copy to clipboard operation
pyswarming copied to clipboard

notebook examples and 3D simulation

Open magixn opened this issue 8 months ago • 2 comments

  1. The notebook examples can not run neither in vs code nor in browser. Scripts under examples works well.
  2. The model is 3D actually, and the visualization code seems to be easy to expand 3D, have you try it?

magixn avatar Mar 19 '25 07:03 magixn

Hi @magixn !

  1. These notebooks were created using the Jupyter Notebook. I've tested here and they are working fine. Just remember that depending on the notebook (Jupyter, Colab, etc.) you may have to add something to be able to animate. For instance, in the Jupyter Notebook I just add the following code at the end:
from IPython.display import HTML
HTML(anim.to_jshtml())
  1. Yes! We coded in a way to be able to used with drones, underwater vehicles, etc., which essentially move in the 3D. We did not tried to code that (yet), but it would be great. There are great python libraries that have 3D environments where would be interesting to make examples using the PySwarming. Nowadays, due time constraints, we are focused in other projects, but, if you have interest we can talk and I can work on that also (just send me an email).

mrsonandrade avatar Mar 19 '25 18:03 mrsonandrade

  1. This is my minimal example that can show animation in the local browser. It is not a big issue indeed.
import pyswarming.swarm as ps
my_swarm = ps.Swarm() 
anim = my_swarm.simulate(mode='anim')
  1. I can easily modified the code to achieve such as acceleration-based control. Since I am not good at matplotlib, if you could help in 3D animation, I will be very grateful. Also add obstacles on the plot, which is easy in algorithm.
  2. There are some other things which I can fix by myself, but should be mentioned. The angle $\theta$ of the robot may be the angle of the speed, which is more reasonable. The behaviors not initialized in the self.behaviors_dict of swarm.py should be added manually.

magixn avatar Mar 26 '25 14:03 magixn