WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Using 2 slider joints to move on a plane (https://forum.worldviz.com/showthread.php?t=6010)

engelskri3ger 05-12-2017 09:43 AM

Using 2 slider joints to move on a plane
 
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:
Code:

# -----------------------------------------------------------------------
# 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.


All times are GMT -7. The time now is 07:24 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC