I'm trying to implement a roll pitch rotation on a body. For the moment I'm using simSetJointTargetVelocity to manipulate the rotation. Are there other ways to control the revolute joint's rotation angle/velocity under a non threaded script? I'm trying to make a "swinging motion" like a real quad that's achieving balance after moving. My file is below:
http://www.filedropper.com/orientationbodytest
My coding part for the rotation is below (also included in the file script):
Code: Select all
---------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------ RP-Orientation------------------------------------------------------------
posnew=simGetObjectPosition(body,-1)
posnew1=simGetObjectPosition(target,-1)
posnew[2]=math.sqrt(posnew[2]*posnew[2])
posnew[1]=math.sqrt(posnew[1]*posnew[1])
posnew1[2]=math.sqrt(posnew1[2]*posnew1[2])
posnew1[1]=math.sqrt(posnew1[1]*posnew1[1])
mathdiff=posnew1[2]-posnew[2]
mathdiff1=posnew1[1]-posnew[1]
if mathdiff>0.075 then
Vroll=-0.075
elseif mathdiff<-0.2 then
Vroll=0.075
else
Vroll=0
end
simSetJointTargetVelocity(roll,Vroll)