Hello,
I want to get the derivatives of Euler angles of a dummy in ZYX format. How can I do this by using sim.getObjectVelocity?
I have to add that I used the following code to get Euler angles in XYZ order and verify its results by comparing it with the sim.getObjectVelocity function and then using it for ZYX, but the results were not even close.
function sysCall_init()
-- in frame t:
t1 = sim.getSimulationTime()
m1=sim.getObjectMatrix(objHandle,-1)
function sysCall_sensing()
-- in frame t+dt:
t2 = sim.getSimulationTime()
dt = t2 - t1
t1 = t2
linearVelocity, angularVelocity=sim.getObjectVelocity(objHandle)
sim.invertMatrix(m1)
m2=sim.getObjectMatrix(objHandle,-1)
m=sim.multiplyMatrices(m1,m2) -- now m is the transf. matrix of obj at t, expressed relative to the transf. matrix of obj at t+dt
euler=sim.getEulerAnglesFromMatrix(m)
da={euler[1]/dt,euler[2]/dt,euler[3]/dt}
m1 = m2
print(angularVelocity)
print(da)
in your code, your are computing the derivative of the Euler angles relative to the previous object frame, which is correct. sim.getObjectVelocity has a bug, if you use sim.getObjectVelocity, then make sure to combine the object handle with the sim.handleflag_axis flag, which will return a vector expressed in the absolute ref. frame, that indicates the instantaneous rotation axis (the rotation angle is given via the vector's length), which is the usual way of representing a rotation velocity.
Additionally, have a look at sim.yawPitchRollToAlphaBetaGamma or sim.alphaBetaGammaToYawPitchRoll, and the demo scene scenes/eulerAngles.ttt