WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-15-2008, 05:20 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
RE:Slide Joints and physics optimization

Hi,

I have constructed a virtual environment containing, amongst other things, a forklift. As the "name of the game" for this project was realism I have constructed the truck using purely physics joints. This works well, the truck follows the lay of the land and behaves pretty well how i want it to. However, one of the tasks for the user is to load some items (steel cages) onto the back of a lorry, at this point things go a bit weird. I am using a slide joint for the forks and 'applyForce' on joystick button events (within a timer) to raise and lower them, but when I pick up the cages they bounce and jump all over the place - not good. I have tried everything i can think of -reducing the physics stepsize (0.0003) and accuracy (0.000001), altering the weight, bounce and friction of the forks and cages, all of which have an effect, but not really what I want.
Is applyForce the best way to operate this type of slide joint, or is having it within a timer making the forks movement jumpy???? HELP, i've run out of ideas and this has to be finished by beginning of next week!!

This is the code for the cages:
Code:
top =cage1.collideBox(node = 'Cage_Top',bounce=0,density=.1)
top.setFriction(80)
bottom = cage1.collideBox(node = 'Cage_Bottom',bounce=0,density=.4)
bottom.setFriction(80)
side1=cage1.collideBox(node='Left_Ones',bounce=0,density=0.05)
side2=cage1.collideBox(node='Right_Ones',bounce=0,density=0.05)
cage1.enable(viz.COLLIDE_NOTIFY)
This is the code for the FLT:
Code:
#Build FLT#
###########
flt = viz.add('flt8.ive')
body = flt.getChild('Body')
body.playsound('CE2a.WAV',viz.LOOP)
body.collideBox(bounce=0, density = 1.25)

lever1=flt.getChild('Lever1')
lever1.collideBox(bounce=0,density=0.05)
lever2=flt.getChild('Lever02')
lever2.collideBox(bounce=0,density=0.05)

#Get and process children
run = flt.getChild('Shaft')
run.collideBox(bounce=0, density = 0.1)
run.setPosition([0.0,0.2,0.0])
print run.getPosition()

guard = flt.getChild('ForkGuard')
guard.translate([0,0,0.005])
guard.collideBox(bounce=0,density=0.05)

fork1 = flt.getChild('Blades')
#fork1.setPosition(0,-0.1,0)
forks = fork1.collideBox(bounce=0,density = 0.1)
forks.setFriction(200)

steering = flt.getChild('Steering_Wheel')
steerBox = steering.collideSphere(bounce=0,density=0.01)

#Link
bodyLink = viz.link(body,view,dstFlag=viz.LINK_BODY)
bodyLink.preTrans([0,-0.12,0.28])

##--MOTORS & JOINTS--##

steerlink = viz.phys.addHingeJoint(body,steering,pos=[-0.005,1.153,0.813],axis0=[0,1,0])
steerlink.setMotorAngle(0,0,1,.25)

#lever1link = viz.phys.addHingeJoint(body,lever1,pos=[0.249,0.763,0.993],axis0=[1,0,0])
lever1link=viz.phys.addFixedJoint(body,lever1)
lever2link=viz.phys.addFixedJoint(body,lever2)
#lever1link.setMotorAngle(0,0,100,.5)

slideJoint = viz.phys.addSliderJoint(fork1,run,pos=[-0.005,0.5,1.317],axis0=(0,1,0))
slideJoint.setAxisFriction(0,12)
slideJoint.setAxisLimit(0,-0.2,2.8) # Limit sliding distance

guardJoint = viz.phys.addFixedJoint(guard,fork1)
#cwLink = viz.phys.addFixedJoint(cw,body)
#runJoint = viz.phys.addFixedJoint(run,body)
runJoint = viz.phys.addHingeJoint(run,body,pos=[-0.005,0.279,1.21],axis0=[1,0,0]) 
#runJoint.setAxisFriction(0,10)
#runJoint.setAxisLimit(0,-5,8)
runJoint.setMotorAngle(0,-1,26,1)
 
fr = viz.add('F_wheel1.ive',scale = [1,1,1],pos=[0.58,0.194,0.9])
fright = fr.collideSphere(bounce = 0, density = 1)
fright.setFriction(5)
frJoint = viz.phys.addHingeJoint(body,fr,pos=[0.58,0.194,0.9],axis0=(-1,0,0))
frJoint.setAxisFriction(0,1.5)

fl = viz.add('F_wheel1.ive',scale = [1,1,1],pos=[-0.58,0.194,0.9])
fleft = fl.collideSphere(bounce = 0, density =1)
fleft.setFriction(5)
flJoint = viz.phys.addHingeJoint(body,fl,pos=[-0.58,0.194,0.9],axis0=(-1,0,0))
flJoint.setAxisFriction(0,1.5)

rr = viz.add('F_wheel1.ive',scale=[1,1,1],pos=[0.0,0.194,-0.727])
#rr.playsound('CE2a.WAV',viz.LOOP)
rearr = rr.collideSphere(bounce = 0, density = 3)
rearr.setFriction(2)
rrJoint = viz.phys.addWheelJoint(body,rr,pos=[0.0,0.194,-0.727],axis0=(0,1,0),axis1=(1,0,0))
rrJoint.setAxisBounce(0,0)
rrJoint.setAxisBounce(1,0)
rrJoint.setAxisFriction(1,.75)
print rrJoint.getPosition()


def steer(val):
    rrJoint.setMotorAngle(0,val,0xFF,.05)
    
def steerWheel(val):
    steerlink.setMotorAngle(0,val,3,.1) 
    
def SetThrottle(val):
    rrJoint.setMotorThrottle(1,-val,9,1100)

#Control Forks#
def buttonTimer():

    
    if joy.isButtonDown (7):
        print "Button is 7 down"
        fork1.applyForce([0,215,0])
        
    elif joy.isButtonDown (8):
        print "Button 8 is down"
        fork1.applyForce ([0,-205,0])
        
    if joy.isButtonDown (5):
        runJoint.setMotorAngle(0,-6,6,.03)
    elif joy.isButtonDown (6):
        runJoint.setMotorAngle(0,2,6,.03)

        
vizact.ontimer(viz.FASTEST_EXPIRATION,buttonTimer)
Any help, suggestions, information will be VERY gratefully received.

Cheers,

Nige
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:26 AM.


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