about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <you@example.com>2022-02-09 18:46:52 +0000
committerBaitinq <you@example.com>2022-02-09 18:46:52 +0000
commit07aa1b5ef617d0ba7a58c47ce6670a4d3876694e (patch)
tree0e65bb722bad826f5d6d0a0f75bdcaa144040026
parentImplemented force calculation for x coordinate (diff)
downloadOSLS-07aa1b5ef617d0ba7a58c47ce6670a4d3876694e.tar.gz
OSLS-07aa1b5ef617d0ba7a58c47ce6670a4d3876694e.tar.bz2
OSLS-07aa1b5ef617d0ba7a58c47ce6670a4d3876694e.zip
Implemented basic version of x movement
Right now gimble = heading, which shouldnt be the case. TODO
-rw-r--r--rocket.py2
-rw-r--r--simulation.py31
-rw-r--r--stage.py2
3 files changed, 21 insertions, 14 deletions
diff --git a/rocket.py b/rocket.py
index 962678b..de17812 100644
--- a/rocket.py
+++ b/rocket.py
@@ -7,6 +7,8 @@ class Rocket():
         self.stages_spent = 0
         self.payload_mass = payload_mass
 
+        self.heading_angle = 0 #TODO: TODOODODODODODODODODODOOD
+
     def current_stage(self) -> type[Stage]:
         return self.stages[0]
 
diff --git a/simulation.py b/simulation.py
index 3459242..a4a7aa6 100644
--- a/simulation.py
+++ b/simulation.py
@@ -19,9 +19,9 @@ class Simulation():
         self.rocket = rocket
         self.x = 0#TODO
         self.y = 0 #TODO: we need to make it so there is height() to calc height based on x and y
-        self.speed_x = 0#TODO
+        self.speed_x = 0
         self.speed_y = 0
-        self.acceleration_x = 0#TODO
+        self.acceleration_x = 0
         self.acceleration_y = 0
 
     #simulation logic
@@ -33,9 +33,7 @@ class Simulation():
             fuel_used = current_stage.fuel_mass
         current_stage.fuel_mass -= fuel_used
         print("Fuel remaining: " + str(current_stage.fuel_mass))
-        
-        #TODO: FORCE_X AND FORCE_Y
-        
+                
         force_x = 0
         force_y = 0
         if fuel_used > 0:
@@ -46,9 +44,6 @@ class Simulation():
         print("Thrust X: " + str(force_x))
         print("Thrust Y: " + str(force_y))
 
-        #print("Y THRUST: " + str(upwards_force))
-        #print("TOTAL THRUST: " + str(current_stage.convert_y_component_to_total_with_gimbal(upwards_force)))
-
         print("BODY MASS: " + str(self.body.mass()))
         print("ROCKET TOTAL MASS: " + str(self.rocket.total_mass()))
 
@@ -84,18 +79,28 @@ class Simulation():
         print("Total Force X: " + str(force_x))
         print("Total Force Y: " + str(force_y))
 
-        self.acceleration_y = force_y / self.rocket.total_mass() #mayb we need momentum??
-        print("Acceleration: " + str(self.acceleration_y))
-        self.speed_y = self.speed_y + (self.acceleration_y * delta) #i think thir swrong
+        self.acceleration_x = force_x / self.rocket.total_mass()
+        self.acceleration_y = force_y / self.rocket.total_mass()
+        print("Acceleration x: " + str(self.acceleration_x))
+        print("Acceleration y: " + str(self.acceleration_y))
+        
+        self.speed_x = self.speed_x + (self.acceleration_x * delta)
+        self.speed_y = self.speed_y + (self.acceleration_y * delta)
+
+        print("Speed x: " + str(self.speed_x))
+        print("Speed y: " + str(self.speed_y))
 
         #update position based on velocity and delta
+        self.x += self.speed_x * delta
+
+        #in future u should be able to go negative y (y and height are different)
         self.y += self.speed_y * delta
         if self.y < 0:
             self.y = 0
             self.speed_y = 0
             
-        print("Speed: " + str(self.speed_y))
-        print("Height: " + str(self.y))
+        print("X: " + str(self.x))
+        print("Y: " + str(self.y))
 
         print("Total Simulation Time: " + str(self.time))
         print("")
diff --git a/stage.py b/stage.py
index 453c759..e2c32d1 100644
--- a/stage.py
+++ b/stage.py
@@ -15,7 +15,7 @@ class Stage():
         self.cross_sectional_area = cross_sectional_area
         
         self.max_engine_gimbaling_angle = max_engine_gimbaling_angle
-        self.gimbal = 0
+        self.gimbal = 0 #one thing is gimbal another is rocket angle (TODO TOODODODODODODOD)
         self.throttle = 100
         self.engines_on = False