Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fibonacci numbers visulalzation #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions fibonacci_rainfall_simulation/fibonacci_rainfall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'''hello everyone!!! I am Pratyush and this is a basic pybullet project to visualize Fibonacci numbers using simulation.'''

import pybullet as p
import pybullet_data
import time

physicsClient = p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())


x=[]
ball=[]

for i in range(1000):

planeId = p.loadURDF("plane.urdf") #loading the plane
p.setGravity(0,0,-10) #setting the gravity


if(i==0 or i==1): #storing Fibonacci numbers
x.append(1)
else:
x.append(x[i-1]+x[i-2])


print(i+1,"th wave , no of spheres=",x[i])

ball.clear()
for z in range(x[i]):
ball.append(p.loadURDF("sphere.urdf",[z,0,5])) #appending the number of balls and their coordinates

for y in range(1000): #running the simulation
p.stepSimulation()
time.sleep(1./240.)
pos,_ = p.getBasePositionAndOrientation(ball[0])
if pos[2]<=0.05:
time.sleep(1)
break


p.resetSimulation()
44 changes: 44 additions & 0 deletions fibonacci_rainfall_simulation/sphere.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<robot name="sphere">

<material name="blue">
<color rgba="0 0 0.8 1"/>
</material>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
<material name="white">
<color rgba="1 1 1 1"/>
</material>

<link name="base">
<inertial>
<origin xyz ="0 0 0" rpy="0 0 0"/>
<mass value="20"/>
<inertia
ixx="1.2"
iyy="5.5"
izz="6.0"
ixy="0.0"
ixz="-0.2"
iyz="-0.01" />

</inertial>


<visual>
<origin xyz ="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="0.05"/>
</geometry>
<material name="blue">
<color rgba="0.3 0.3 0.3 1.0"/>
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="0.05"/>
</geometry>
</collision>
</link>
</robot>