Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collision not happen #200

Open
lucattyy opened this issue Oct 4, 2023 · 0 comments
Open

collision not happen #200

lucattyy opened this issue Oct 4, 2023 · 0 comments

Comments

@lucattyy
Copy link

lucattyy commented Oct 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant