:wMerge branch 'master' of git.interhacker.space:teamlaser/lj

This commit is contained in:
alban 2020-09-30 19:53:48 +02:00
commit ecf7d0381d
10 changed files with 86 additions and 98 deletions

18
LJ.conf
View File

@ -10,10 +10,10 @@ autostart = artnet
[laser0]
color = -1
type = DS1000
ip = 192.168.2.4
ip = 192.168.2.44
kpps = 25000
centerx = 0
centery = 765
centery = 0
zoomx = 45.0
zoomy = 45.0
sizex = 32000
@ -32,8 +32,8 @@ color = -1
type = LOCAL
ip = 192.168.2.43
kpps = 25000
centerx = -11970
centery = -6510
centerx = 0
centery = 0
zoomx = 30.0
zoomy = 30.0
sizex = 32000
@ -54,11 +54,11 @@ ip = 192.168.2.6
kpps = 25000
centerx = 0
centery = 0
zoomx = 45.0
zoomy = 45.0
sizex = 30600
zoomx = 85.0
zoomy = 85.0
sizex = 32000
sizey = 32000
finangle = -4.0
finangle = 0.0
swapx = -1
swapy = -1
lsteps = [(1.0, 8),(0.25, 3), (0.75, 3), (1.0, 10)]
@ -70,7 +70,7 @@ warpdest = [[-1500., 1500.],
[laser3]
color = -1
type = LUKE400
ip = 192.168.2.3
ip = 192.168.2.4
kpps = 25000
centerx = 0
centery = 0

View File

@ -56,9 +56,9 @@ centerx = 0
centery = 0
zoomx = 45.0
zoomy = 45.0
sizex = 30600
sizex = 32000
sizey = 32000
finangle = -4.0
finangle = 0.0
swapx = -1
swapy = -1
lsteps = [(1.0, 8),(0.25, 3), (0.75, 3), (1.0, 10)]

View File

@ -354,7 +354,9 @@ About hardware setup, especially if you have several lasers : ILDA cables are in
#
2 useful and *always working tools* from j4cdac github repository : sitter and talk.
- Sitter will display all etherdreams available on the network and their state (playing, idle,...). python sitter.py or use the compiled version (for macOS). May need tkinter : pip3 install tk
- Sitter will display all etherdreams available on the network and their state (playing, idle,...). python sitter.py or use the compiled version (for macOS). May need tkinter :
pip3 install tk
+/- : sudo apt install python-tk
- Talk : will draw a 4 colors square. Try : python3 talk3.py -h
#
@ -375,6 +377,30 @@ Generic :
There is a nice websocket debug tool : websocat.
#
# Troubleshooting
#
Try these steps in this order ;
- Use talk3 in ethertools directory : this ensure your computer can connect to the etherdream. See ethertools chapter in this readme. If talk3 doesn't works, check the hardware, connections,...
python3 talk3.py -i etherdreamIP
- You should see "connected to yourLJserverIP" on webUI. If not : LJ is not started / your network configuration is bad / a wrong IP in the configure parameters : python3 configure.py.
- Switch to simu page. If you don't see anything : check redis server or your points in redis doesn't respect pointlist formatting (see command reference).
- If talk3 works but you don't see your points : click on the Grid icon in Align page. This will override your pointlist and display squares. If Grid works : recomputed points by tracers are bad with given values in LJ.conf.
"Bad points" ?
- too small movement : some lasers (with small angle like 40°) won't display anything if zoomx/zoomy are too small. Increase zoomx / zoomy in LJ.conf. Try 50-100 values.
- off center : check in LJ.conf centerX and centerY. Reset them to 0.
- not enough points.
*Don't kill your scanners : becareful with kpps setting.*
#
# LJ commands reference
#

View File

@ -1,74 +0,0 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
This generator reads a frame from redis
v0.1.0
Use it to create feedback loops by writing to the same frame
or to copy the frame from someone else
LICENCE : CC
by cocoa
'''
from __future__ import print_function
import ast
import argparse
import json
import redis
import sys
import time
name="generator::fromRedis"
def debug(*args, **kwargs):
if( verbose == False ):
return
print(*args, file=sys.stderr, **kwargs)
argsparser = argparse.ArgumentParser(description="Dummy generator")
argsparser.add_argument("-k","--key",required=True,help="Redis key to look after",default=30,type=str)
argsparser.add_argument("-i","--ip",help="IP address of the Redis server ",default="127.0.0.1",type=str)
argsparser.add_argument("-p","--port",help="Port of the Redis server ",default="6379",type=str)
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
args = argsparser.parse_args()
fps = args.fps
verbose = args.verbose
key = args.key
ip = args.ip
port = args.port
optimal_looptime = 1 / fps
debug(name+" optimal looptime "+str(optimal_looptime))
r = redis.Redis(
host=ip,
port=port)
while True:
start = time.time()
# Read from Redis
line = r.get(key)
# Decode as list of tuples
pointsList = ast.literal_eval(line.decode('ascii'))
# convert to list of lists
pointsList = [list(elem) for elem in pointsList]
# Convert to JSON string
line = json.dumps( pointsList )
debug(name,"Key:{} line:{}".format(key,line))
# Output
print(line, flush=True);
looptime = time.time() - start
if( looptime < optimal_looptime ):
time.sleep( optimal_looptime - looptime)
debug(name+" micro sleep:"+str( optimal_looptime - looptime))

View File

@ -35,7 +35,7 @@ import sys
argsparser = argparse.ArgumentParser(description="Draw a square on a laser via Etherdream DAC")
argsparser.add_argument("-i","--ip",help="Etherdream IP (default : first etherdream broadcast received",default="True",type=str)
argsparser.add_argument("-i","--ip",help="Etherdream IP (default : first etherdream broadcast received)",default="True",type=str)

View File

@ -15,6 +15,7 @@ from /team/laser
from libs3 import gstt
import argparse
import subprocess
from libs3 import settings as Settings
def handle():
@ -112,8 +113,7 @@ def handle():
# Lasers = number of laser connected otherwise will be autodetected with one minimum
if args.Lasers != None:
gstt.LaserNumber = args.Lasers
else:
gstt.LaserNumber = 1
Settings.Write()
if args.bhoroscIP != None:

View File

@ -92,7 +92,7 @@ Bob could use /pl/2/0 and /pl/2/1 and Lisa could use /pl/2/2 and /pl/2/3.
import types, time, socket
from libs3 import gstt
import redis
from libs3 import settings, plugins, homographyp
from libs3 import settings, plugins, homographyp,log
r = redis.StrictRedis(host=gstt.LjayServerIP , port=6379, db=0)
@ -333,6 +333,9 @@ def handler(oscpath, args):
print()
print("new laser number",args[0])
print()
gstt.LaserNumber = int(args[0])
settings.Write()
if oscpath[2] == "regen":
print()
@ -352,6 +355,7 @@ def handler(oscpath, args):
print()
gstt.debug = int(args[0])
plugins.SendAll("/debug "+str(gstt.debug))
settings.Write()
if oscpath[2] == "rescan":
@ -359,11 +363,13 @@ def handler(oscpath, args):
DAChecks()
print("Done.")
if oscpath[2] == "rstrt":
if oscpath[2] == "restart":
print()
print("Restarting", args[0], "...")
if args[0] == "lj":
raise Restart(time.asctime())
LJautokill()
import os
os.execv(sys.executable, ['python3'] + sys.argv)
else:
plugins.Restart(args[0])
print()
@ -586,6 +592,31 @@ def isconnected(IP):
time.sleep(delay)
return ipup
'''
def LJautokill():
log.warn("LJ stopping...")
print(gstt.LaserNumber,"Tracers launched")
lasernumber= gstt.LaserNumber -1
log.warn("Ending tracer0...")
worker0.join()
if lasernumber >0:
log.warn("Ending tracer1...")
worker1.join()
if lasernumber >1:
log.warn("Ending tracer2...")
worker2.join()
if lasernumber >2:
log.warn("Ending tracer3...")
worker3.join()
log.warn("Laser feedbacks resetting...")
for laserid in range(0,lasernumber+1):
r.set('/lack/'+str(laserid),64)
r.set('/lstt/'+str(laserid),64)
r.set('/cap/'+str(laserid),0)
log.infog("LJ stopped.")
# autodetect DACs in LJ.conf.
def DAChecks():

View File

@ -23,7 +23,7 @@ ljpath=''
anims= [[],[],[],[]]
# How many lasers are connected. Different that "currentlaser" and "dacnumber" (=autodetected)
LaserNumber = -1
LaserNumber = 4
# What laser client to listen at launch
SceneNumber = 0

View File

@ -526,7 +526,8 @@ class DAC(object):
# print("Writing %d points" % (cap, ))
#t0 = time.time()
#print points
#if self.mylaser == 2:
# print(points)
self.write(points)
#t1 = time.time()
# print("Took %f" % (t1 - t0, )

12
main.py
View File

@ -440,21 +440,25 @@ if __name__ == '__main__':
# Launch one process (a newdacp instance) by etherdream
dac_worker0= Process(target=dac_process, args=(0,0,))
dac_worker0.start()
commands.worker0 = dac_worker0
print("Tracer 0 : name", dac_worker0.name , "pid", dac_worker0.pid )
if lasernumber >0:
dac_worker1= Process(target=dac_process, args=(1,0,))
commands.worker1 = dac_worker1
print("Tracer 1 : name", dac_worker1.name , "pid", dac_worker1.pid )
dac_worker1.start()
if lasernumber >1:
dac_worker2= Process(target=dac_process, args=(2,0,))
dac_worker2.start()
commands.worker2 = dac_worker2
print("Tracer 2 : name", dac_worker2.name , "pid", dac_worker2.pid )
if lasernumber >2:
dac_worker3= Process(target=dac_process, args=(3,0,))
print("Tracer 3 : name", dac_worker3.name , "pid", dac_worker3.pid )
commands.worker3 = dac_worker3
dac_worker3.start()
print("")
#def Run():
@ -511,14 +515,13 @@ if __name__ == '__main__':
except Exception:
log.err("Exception")
traceback.print_exc()
except Restart(moment):
print("Autokill asked at", moment)
# Gently stop on CTRL C
finally:
commands.LJautokill()
'''
dac_worker0.join()
if lasernumber >0:
dac_worker1.join()
@ -533,8 +536,9 @@ if __name__ == '__main__':
r.set('/lack/'+str(laserid),64)
r.set('/lstt/'+str(laserid),64)
r.set('/cap/'+str(laserid),0)
'''
print("Fin de LJ.")
#if __name__ == "__main__":
# Run()