fix: helios dac homography should work

This commit is contained in:
alban 2023-02-25 22:18:32 +01:00
parent 80c76bfeb1
commit 6c73bd9fc2
4 changed files with 24 additions and 27 deletions

View File

@ -68,6 +68,7 @@ GridDisplay = [0,0,0,0]
# Transformation Matrix for each laser # Transformation Matrix for each laser
EDH = [[], [], [], []] EDH = [[], [], [], []]
# EDH = [[], [], [], []]
# Etherdreams reports # Etherdreams reports
# ipconn is initial newdac to its etherdream # ipconn is initial newdac to its etherdream

View File

@ -150,12 +150,13 @@ def find_affine(points1,points2):
H[2,2] = 1 H[2,2] = 1
return H return H
def apply(H,points):
p = np.ones((len(points),2),'float64') def apply(H, points):
p[:,:2] = points p = np.ones((len(points), 3), 'float64')
pp = np.dot(p,H.T) p[:, :3] = points
pp[:,:2]/=pp[:,2].reshape(len(p),1) pp = np.dot(p, H.T)
return pp[:,:2] pp[:, :2] /= pp[:, 2].reshape(len(p), 1)
return pp[:, :2]
# Align and axis swap corrections # Align and axis swap corrections
# Reference points # Reference points

View File

@ -95,13 +95,9 @@ class Status(object):
print(prefix + l) print(prefix + l)
def OnePointIterator(pl): def OnePointIterator(ref):
while True: while True:
for indexpoint, currentpoint in enumerate(pl): for indexpoint, currentpoint in enumerate(ref.pl):
print("cp", indexpoint, currentpoint)
yield currentpoint[0], currentpoint[1], 255, 255, 255
continue
for indexpoint, currentpoint in enumerate(pl):
# We modify the point geometry according to warp settings # We modify the point geometry according to warp settings
# print indexpoint, currentpoint # print indexpoint, currentpoint
@ -327,7 +323,7 @@ class Tracer(object):
# pdb.set_trace() # pdb.set_trace()
# How much room? # How much room?
capacity = self.get_points_capacity() capacity = self.get_points_capacity()
iterator = iter(OnePointIterator(self.pl)) iterator = iter(OnePointIterator(self))
self.redis.set('/cap/' + str(self.laser_id), capacity) self.redis.set('/cap/' + str(self.laser_id), capacity)
points = [next(iterator) for i in range(capacity)] points = [next(iterator) for i in range(capacity)]

View File

@ -1,4 +1,5 @@
import ctypes import ctypes
import math
import random import random
from libs3 import gstt from libs3 import gstt
@ -33,7 +34,7 @@ class TracerHelios(Tracer):
self.redis = redis self.redis = redis
self.laser_id = laser_id self.laser_id = laser_id
self.PL = PL self.PL = PL
self.pl = [[0,0,0]] self.pl = [[0, 0, 0]]
self.clientkey = self.redis.get("/clientkey").decode('ascii') self.clientkey = self.redis.get("/clientkey").decode('ascii')
self.xyrgb = self.xyrgb_prev = (0, 0, 0, 0, 0) self.xyrgb = self.xyrgb_prev = (0, 0, 0, 0, 0)
self.intensity = 65280 self.intensity = 65280
@ -50,7 +51,7 @@ class TracerHelios(Tracer):
pass pass
def get_points_capacity(self): def get_points_capacity(self):
return 10 return 1000
# def GetPoints(self, capacity): # def GetPoints(self, capacity):
# a = [2,3] # a = [2,3]
@ -80,20 +81,14 @@ class TracerHelios(Tracer):
return True return True
def write(self, points): def write(self, points):
# status_attempts = 0
# j = 0
# while (status_attempts < 512 and HeliosLib.GetStatus(j) != 1):
# status_attempts += 1
# print("attempt {}".format(status_attempts))
# HeliosLib.WriteFrame(j, 3000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
frame_type = HeliosPoint * self.get_points_capacity() frame_type = HeliosPoint * self.get_points_capacity()
frame = frame_type() frame = frame_type()
helios_id = 0 helios_id = 0
# print("hello got {} points".format(len(points)))
points = [point for point in points] points = [point for point in points]
for i, point in enumerate(points): for i, point in enumerate(points):
x, y, r, g, b = point x, y, r, g, b = point
print(x,y,r,g,b) x = x if not math.isnan(x) else 0
y = x if not math.isnan(y) else 0
frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255) frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255)
statusAttempts = 0 statusAttempts = 0
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway # Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
@ -101,15 +96,19 @@ class TracerHelios(Tracer):
statusAttempts += 1 statusAttempts += 1
f = ctypes.pointer(frame) f = ctypes.pointer(frame)
# int HeliosDac::WriteFrame(unsigned int devNum, unsigned int pps, std::uint8_t flags, HeliosPoint* points, unsigned int numOfPoints) # int HeliosDac::WriteFrame(unsigned int devNum, unsigned int pps, std::uint8_t flags, HeliosPoint* points, unsigned int numOfPoints)
r = HeliosLib.WriteFrame(0, 300, 0, f, len(frame)) ret_helios = HeliosLib.WriteFrame(0, 3000, 0, f, len(frame))
# @todo : detect errors
if ret_helios != 1:
print(f"ERR ]Helios DAC #{self.laser_id} returned error {ret_helios}")
def get_warped_point(self, x, y): def get_warped_point(self, x, y):
# transform in one matrix, with warp !! # transform in one matrix, with warp !!
# Etherpoint all transform in one matrix, with warp !! # Etherpoint all transform in one matrix, with warp !!
# position = homographyp.apply(gstt.EDH[self.laser_id], np.array([(x, y)])) np_arr = np.array([(x, y, 0)])
return x, y laser_EDH = gstt.EDH[self.laser_id]
# return position[0][0], position[0][1] position = homographyp.apply(laser_EDH, np_arr)
return position[0][0], position[0][1]
# #
# # Create sample frames # # Create sample frames