Closed dyingbrain closed 1 year ago
Have you tried not prepending b to the string? The value should be a str, not bytes.
I tried, but it doesn't solve the problem.
This is strange. The following code gives me a window that prints the inputs to keyboardfunc in either Python 2 or 3, could you try it on your system and see what happens? I
from klampt.vis.glprogram import * class KBTest(GLNavigationProgram): def init(self): GLNavigationProgram.init(self,'KBTest') def keyboardfunc(self,c,x,y): print(c,x,y) KBTest().run() exit(0)
Python2 works but Python3 doesn't. Maybe we can talk with Mengchao, he experienced similar problems.
Zherong
Looks like this is resolved
Zherong: The following code can receive keyboard signals in python2 but not python3:
from klampt.vis import GLProgram,camera,gldraw from klampt import WorldModel,Geometry3D import klampt.math.vectorops as op from klampt.math import se3,so3 import math,klampt
TEXT_COLOR=(0,0,0)
def empty_bb(dim=3): return ([1000]dim,[-1000]dim)
def union_bb(a,b): if isinstance(b,list): return union_bb(a,(b,b)) else: return ([min(c[0],c[1]) for c in zip(a[0],b[0])], \ [max(c[0],c[1]) for c in zip(a[1],b[1])])
def expand_bb(bb,expand): return ([c-expand for c in bb[0]], \ [c+expand for c in bb[1]])
def expand_bb_eps(bb,eps): d=max(op.sub(bb[1],bb[0])) return expand_bb(bb,d*eps)
def contain_bb(bb,pt): for d in range(len(bb[0])): if pt[d]<bb[0][d] or pt[d]>bb[1][d]: return False return True
def compute_bb_tight(geom,Rt=None): if geom.type()=="Group": return geom.getBB()
Rtc=geom.getCurrentTransform() if Rt is None else se3.mul(Rt,geom.getCurrentTransform())
def get_robot_bb(robot,link0=None): bb=None if link0 is None: link0=0 for i in range(link0,robot.numLinks()): if i==link0: bb=compute_bb_tight(robot.link(i).geometry(),robot.link(i).getTransform()) else: bbI=compute_bb_tight(robot.link(i).geometry(),robot.link(i).getTransform()) if bb is None: bb=bbI elif bbI is not None: bb=union_bb(bb,bbI) return bb
def get_object_bb(object): return compute_bb_tight(object.geometry())
class GLVisualizer(GLProgram): def init(self,world,env=None): GLProgram.init(self,"Visualizer") self.path='.' self.zeroZ=True self.world=world self.env=env self.lockX=False self.lockY=False self.frameFunc=None self.qdq0=None self.traj=None self.init_camera() self.povray_properties={}
if name=='main': world=klampt.WorldModel() pt=klampt.GeometricPrimitive() pt.setSphere([0,0,0],1) geom=world.makeTerrain('sphere') geom.geometry().setGeometricPrimitive(pt) geom.appearance().setColor(1.,0.,0.)