first test
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import time
|
||||
import math
|
||||
|
||||
# Solar module for simulation of world
|
||||
import solar # Modeling of the world
|
||||
import objects.solar as solar # Modeling of the world
|
||||
|
||||
from motor import Motor # Small helper functions and constants
|
||||
from motor import Board
|
||||
from objects.motor import Motor # Small helper functions and constants
|
||||
from objects.board import Board
|
||||
|
||||
STEP = 10
|
||||
LOOP_DELAY = 0.01 # In seconds
|
||||
LOOP_DELAY = 0.005 # In seconds
|
||||
|
||||
# Testing embedding the mirrors in the world
|
||||
board = Board()
|
||||
@@ -15,29 +16,39 @@ world = solar.World(board, tilt_deg=15) # The world is tilted 15 degrees around
|
||||
|
||||
HEIGHT = 30
|
||||
|
||||
source = solar.Source(world, pos=(0, 0, 30))
|
||||
target = solar.Target(world, pos=(20, 0, 30))
|
||||
source = solar.Source(world, pos=(-30, -50, 100))
|
||||
target = solar.Target(world, pos=(30, -50, 40))
|
||||
|
||||
# Create mirrors in a 9x9 grid
|
||||
# Create mirrors in a 3x2 grid
|
||||
for x in range(3):
|
||||
for y in range(3):
|
||||
for y in range(2):
|
||||
mirror = solar.Mirror(world, cluster_x=x, cluster_y=y)
|
||||
world.add_mirror(mirror)
|
||||
|
||||
world.update_mirrors_from_source_target(source, target)
|
||||
|
||||
for i, mirror in enumerate(world.mirrors):
|
||||
pitch, yaw = mirror.get_angles()
|
||||
print(f"Mirror {i} ({mirror.cluster_x}, {mirror.cluster_y}) angles -> pitch: {pitch:.2f}°, yaw: {yaw:.2f}°")
|
||||
def print_status():
|
||||
for i, mirror in enumerate(world.mirrors):
|
||||
pitch, yaw = mirror.get_angles()
|
||||
print(f"Mirror {i} ({mirror.cluster_x}, {mirror.cluster_y}) angles -> pitch: {pitch:.2f}°, yaw: {yaw:.2f}°")
|
||||
|
||||
print_status()
|
||||
|
||||
a = 1
|
||||
t = time.time()
|
||||
|
||||
# Main
|
||||
try:
|
||||
while True:
|
||||
# Shutdown
|
||||
if GPIO.input(SHUTDOWN_BTN) == GPIO.HIGH:
|
||||
os.system("sudo shutdown now")
|
||||
source.move(10 * math.sin(a * t), 10 * math.cos(a * t))
|
||||
print(source.pos)
|
||||
|
||||
world.update_mirrors_from_source_target(source, target)
|
||||
print_status()
|
||||
|
||||
time.sleep(LOOP_DELAY)
|
||||
|
||||
t = time.time()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user