I put a ball and a box in the simulation and have them move towards each other at first. However, when they meet each other they don't collide but penetrate. How to make a collision happen??
Here is the code.
Code
import torch
import nimblephysics as nimble
world = nimble.simulation.World()
world.setGravity([0, -9.81, 0])
world.setTimeStep(0.01)
world.setFallbackConstraintForceMixingConstant(0.001)
world.setPenetrationCorrectionEnabled(True)
for _ in range(300):
state = nimble.timestep(world, state, action)
states.append(state)
gui = nimble.NimbleGUI(world)
gui.serve(8080) # host the GUI on localhost:8080
gui.loopStates(states) # tells the GUI to animate our list of states
gui.blockWhileServing() # block here so we don't exit the program
I put a ball and a box in the simulation and have them move towards each other at first. However, when they meet each other they don't collide but penetrate. How to make a collision happen??
Here is the code.
Code
import torch import nimblephysics as nimble world = nimble.simulation.World() world.setGravity([0, -9.81, 0]) world.setTimeStep(0.01) world.setFallbackConstraintForceMixingConstant(0.001) world.setPenetrationCorrectionEnabled(True)
box = nimble.dynamics.Skeleton() boxJoint, boxBody = box.createTranslationalJoint2DAndBodyNodePair() boxShape = boxBody.createShapeNode(nimble.dynamics.BoxShape([.1, .1, .1])) boxVisual = boxShape.createVisualAspect() boxVisual.setColor([0.5, 0.5, 0.5]) world.addSkeleton(box)
sphere = nimble.dynamics.Skeleton() sphereJoint, sphereBody = sphere.createTranslationalJoint2DAndBodyNodePair() sphereShape = sphereBody.createShapeNode(nimble.dynamics.SphereShape(.2)) sphereVisual = sphereShape.createVisualAspect() sphereVisual.setColor([0., 0., 1, 1]) world.addSkeleton(sphere)
initialState = torch.tensor([0, 0, 0, 2, 0, 5, 0, 0]) action = torch.zeros((world.getActionSize())) state = initialState states = [] sphere.enableSelfCollisionCheck() box.enableSelfCollisionCheck()
for _ in range(300): state = nimble.timestep(world, state, action) states.append(state)
gui = nimble.NimbleGUI(world) gui.serve(8080) # host the GUI on localhost:8080 gui.loopStates(states) # tells the GUI to animate our list of states gui.blockWhileServing() # block here so we don't exit the program