prev -> prevPosition
This commit is contained in:
@@ -9,14 +9,13 @@ CONTROLLER_ID = 0
|
|||||||
POSITION=1
|
POSITION=1
|
||||||
BUTTONS=6
|
BUTTONS=6
|
||||||
|
|
||||||
|
|
||||||
#assume that the VR physics server is already started before
|
#assume that the VR physics server is already started before
|
||||||
p.connect(p.SHARED_MEMORY)
|
p.connect(p.SHARED_MEMORY)
|
||||||
p.setInternalSimFlags(0)#don't load default robot assets etc
|
p.setInternalSimFlags(0)#don't load default robot assets etc
|
||||||
p.resetSimulation()
|
p.resetSimulation()
|
||||||
p.loadURDF("plane.urdf")
|
p.loadURDF("plane.urdf")
|
||||||
|
|
||||||
prev=[None]*p.VR_MAX_CONTROLLERS
|
prevPosition=[None]*p.VR_MAX_CONTROLLERS
|
||||||
colors=[0.,0.5,0.5]*p.VR_MAX_CONTROLLERS
|
colors=[0.,0.5,0.5]*p.VR_MAX_CONTROLLERS
|
||||||
widths = [3]*p.VR_MAX_CONTROLLERS
|
widths = [3]*p.VR_MAX_CONTROLLERS
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ while True:
|
|||||||
|
|
||||||
for e in (events):
|
for e in (events):
|
||||||
if (e[BUTTONS][33]&p.VR_BUTTON_WAS_TRIGGERED):
|
if (e[BUTTONS][33]&p.VR_BUTTON_WAS_TRIGGERED):
|
||||||
prev[e[CONTROLLER_ID]] = e[POSITION]
|
prevPosition[e[CONTROLLER_ID]] = e[POSITION]
|
||||||
if (e[BUTTONS][32]&p.VR_BUTTON_WAS_TRIGGERED):
|
if (e[BUTTONS][32]&p.VR_BUTTON_WAS_TRIGGERED):
|
||||||
widths[e[CONTROLLER_ID]]=widths[e[0]]+1
|
widths[e[CONTROLLER_ID]]=widths[e[0]]+1
|
||||||
if (widths[e[CONTROLLER_ID]]>20):
|
if (widths[e[CONTROLLER_ID]]>20):
|
||||||
@@ -44,15 +43,15 @@ while True:
|
|||||||
p.removeAllUserDebugItems()
|
p.removeAllUserDebugItems()
|
||||||
p.loadURDF("plane.urdf")
|
p.loadURDF("plane.urdf")
|
||||||
if (e[BUTTONS][33]==p.VR_BUTTON_IS_DOWN):
|
if (e[BUTTONS][33]==p.VR_BUTTON_IS_DOWN):
|
||||||
pt = prev[e[CONTROLLER_ID]]
|
pt = prevPosition[e[CONTROLLER_ID]]
|
||||||
|
|
||||||
#print(prev[e[0]])
|
#print(prevPosition[e[0]])
|
||||||
#print(e[1])
|
#print(e[1])
|
||||||
diff = [pt[0]-e[POSITION][0],pt[1]-e[POSITION][1],pt[2]-e[POSITION][2]]
|
diff = [pt[0]-e[POSITION][0],pt[1]-e[POSITION][1],pt[2]-e[POSITION][2]]
|
||||||
lenSqr = diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]
|
lenSqr = diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]
|
||||||
ptDistThreshold = 0.01
|
ptDistThreshold = 0.01
|
||||||
if (lenSqr>(ptDistThreshold*ptDistThreshold)):
|
if (lenSqr>(ptDistThreshold*ptDistThreshold)):
|
||||||
p.addUserDebugLine(e[POSITION],prev[e[CONTROLLER_ID]],colors[e[CONTROLLER_ID]],widths[e[CONTROLLER_ID]])
|
p.addUserDebugLine(e[POSITION],prevPosition[e[CONTROLLER_ID]],colors[e[CONTROLLER_ID]],widths[e[CONTROLLER_ID]])
|
||||||
#p.loadURDF("cube_small.urdf",e[1])
|
#p.loadURDF("cube_small.urdf",e[1])
|
||||||
colors[e[CONTROLLER_ID]] = [1-colors[e[CONTROLLER_ID]][0],1-colors[e[CONTROLLER_ID]][1],1-colors[e[CONTROLLER_ID]][2]]
|
colors[e[CONTROLLER_ID]] = [1-colors[e[CONTROLLER_ID]][0],1-colors[e[CONTROLLER_ID]][1],1-colors[e[CONTROLLER_ID]][2]]
|
||||||
prev[e[CONTROLLER_ID]] = e[POSITION]
|
prevPosition[e[CONTROLLER_ID]] = e[POSITION]
|
||||||
Reference in New Issue
Block a user