scenarios.py
def _applyTransforms(self, app, objs):
    "Apply requested transformations on the objects"
    if self.get("rand"):
      # Adjust velocities by +/- 1%
      for oid in objs:
        v0 = app.getBodyVelocity(oid)[0]
        if np.linalg.norm(v0) > 0:
          p.resetBaseVelocity(oid, linearVelocity=(
            v0[0] + (random.random() - 0.5) * (v0[0] / 100),
            v0[1] + (random.random() - 0.5) * (v0[1] / 100),
            v0[2]
          ))
    for oid in objs:
      dynamics = {}
      if self.get("bouncy"):
        # Set everything's restitution to 1
        dynamics["restitution"] = 1
      if self.get("frictionless"):
        # Make everything frictionless
        dynamics["lateralFriction"] = 0
        dynamics["rollingFriction"] = 0
        dynamics["spinningFriction"] = 0
      if dynamics:
        p.changeDynamics(oid, -1, **dynamics)
    return objs
Apply requested transformations on the objects
Apply requested transformations on the objects
Apply requested transformations on the objects
def _applyTransforms(self, app, objs):
    if self.get("rand"):
      for oid in objs:
        v0 = app.getBodyVelocity(oid)[0]
        if np.linalg.norm(v0) > 0:
          p.resetBaseVelocity(oid, linearVelocity=(
            v0[0] + (random.random() - 0.5) * (v0[0] / 100),
            v0[1] + (random.random() - 0.5) * (v0[1] / 100),
            v0[2]
          ))
    for oid in objs:
      dynamics = {}
      if self.get("bouncy"):
        dynamics["restitution"] = 1
      if self.get("frictionless"):
        dynamics["lateralFriction"] = 0
        dynamics["rollingFriction"] = 0
        dynamics["spinningFriction"] = 0
      if dynamics:
        p.changeDynamics(oid, -1, **dynamics)
    return objs
def _applyTransforms ( self , app , objs ) : if self . get ( "rand" ) : for oid in objs : v0 = app . getBodyVelocity ( oid ) [ 0 ] if np . linalg . norm ( v0 ) > 0 : p . resetBaseVelocity ( oid , linearVelocity = ( v0 [ 0 ] + ( random . random ( ) - 0.5 ) * ( v0 [ 0 ] / 100 ) , v0 [ 1 ] + ( random . random ( ) - 0.5 ) * ( v0 [ 1 ] / 100 ) , v0 [ 2 ] ) ) for oid in objs : dynamics = { } if self . get ( "bouncy" ) : dynamics [ "restitution" ] = 1 if self . get ( "frictionless" ) : dynamics [ "lateralFriction" ] = 0 dynamics [ "rollingFriction" ] = 0 dynamics [ "spinningFriction" ] = 0 if dynamics : p . changeDynamics ( oid , - 1 , ** dynamics ) return objs
Apply requested transformations on the objects
Apply requested transformations on the objects
"Apply requested transformations on the objects" # Adjust velocities by +/- 1% # Set everything's restitution to 1 # Make everything frictionless
self
app
objs