In [1]:
import sys
sys.path.append('../build')
import libry as ry
import numpy as np
import time
In [2]:
C = ry.Config()
C.addFile("../scenarios/pandasTable.g")
V = ry.ConfigurationViewer()
V.setConfiguration(C)
In [3]:
#no collisions so far:
C.computeCollisions() #this calls broadphase collision detection
C.getCollisions() #this reports collisions (in algorithms, use features instead)
Out[3]:
In [4]:
#bring into collision:
q = C.getJointState()
for t in range(10):
[y,J] = C.evalFeature(ry.FS.positionDiff, ["R_gripperCenter", "L_gripperCenter"])
vel = J.T @ np.linalg.inv(J@J.T + 1e-2*np.eye(y.shape[0])) @ (-y);
q = q + .8*vel
C.setJointState(q)
V.setConfiguration(C)
In [5]:
C.computeCollisions() #this calls broadphase collision detection
C.getCollisions(belowMargin=1.)
Out[5]:
In [6]:
#those are the real penetrations:
C.getCollisions(belowMargin=0.)
Out[6]:
In [7]:
#deactivate a collision flag!
f = C.getFrame("R_gripper")
f.setContact(0)
In [8]:
C.computeCollisions()
C.getCollisions(belowMargin=0.)
Out[8]:
In [9]:
#Note: this is exactly the sum of the above:
C.evalFeature(ry.FS.accumulatedCollisions, [])
Out[9]:
In [11]:
-0.02988786580078831-0.01623162839226778
Out[11]:
Notes:
In [ ]:
import os
os._exit(0)
In [1]:
import sys
sys.path.append('../build')
import libry as ry
import numpy as np
import time
In [2]:
C = ry.Config()
C.addFile("../scenarios/pandasTable.g")
V = ry.ConfigurationViewer()
V.setConfiguration(C)
In [3]:
C.attach("L_gripper", "R_gripper")
In [6]:
#move a bit around
q = C.getJointState()
for t in range(30):
q[0] = np.sin(t/10)
C.setJointState(q)
V.setConfiguration(C)
time.sleep(0.1)
In [ ]: