PDA

View Full Version : Using 2 slider joints to move on a plane


engelskri3ger
05-12-2017, 09:43 AM
Hey there,

I'm working on a project where I need to use a portalcrane where the mounted object is moved by grabbing it with the vizconnect grabber and the parts of the crane should move too. I want to use the built-in physics engine, so i tried to use multiple joints to connect the crane parts, but I didn't figure out yet, how I could use 2 slider joints to get the crane moving in the room.
Is there a way to do this? This is an example code I use for testing purposes:

# -----------------------------------------------------------------------
# Options

CYCLES_PER_SEC = 0.05 # Frames
viz.setMultiSample(4) # Multisampling
viz.setOption('viz.max_frame_rate', 60) # Avoid flickering
viz.vsync(viz.OFF) # V-Sync
viz.collision(viz.ON) # Viewport Collision
viz.phys.enable() # Physics Simulation
viz.setOption('viz.model.cache', viz.CACHE_CLONE)
vizconnect.go(r'../vizconnect_files/keyboard.py') # Standard Vizconnect Keyboard Setting

# -----------------------------------------------------------------------
# Loading of Objects
grabber = vizconnect.getRawTool('grabber')
position = [5.0, 0, 0]
room = viz.add('lab.osgb') # Room is loaded
room.collideMesh() # Room gets Collision

box = vizshape.addBox(size=[12.8, 0.2, 0.2], pos=[0, 5.5, position[2]])
box.collideBox()
box_joint = viz.phys.addSliderJoint(box, None, pos=[0, 5.5, position[2]], axis0=(0, 0, 1))
box_joint.setAxisLimit(0, -6, 6) # Limit sliding distance
box_joint.setAxisBounce(0, 0) # Change end bounce properties

rope = vizshape.addBox(size=[0.075, 3, 0.075], pos=[position[0], 3.9, position[2]])
rope.collideBox()
rope_joint = viz.phys.addSliderJoint(rope, None, pos=[position[0], 3.9, position[2]], axis0=(1, 0, 0))
rope_joint.setAxisLimit(0, -12.8 / 2 - position[0],12.8 / 2 - position[0]) # Limit sliding distance
rope_joint.setAxisBounce(0, 0) # Change end bounce properties

# rope_box_joint = viz.phys.addFixedJoint(box, rope)

grabber.addItems([rope])

Jeff
05-15-2017, 06:59 AM
I'll check with a developer but I'm not sure if this is possible using the physics engine. It may require IK code that moves the joints based on the object's position.

Jeff
05-19-2017, 06:11 AM
Is there some way you can show how you expect the objects to move together, maybe a diagram or picture.