Get Object Velocity in ZYX
Posted: 10 Feb 2022, 01:38
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.
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.
Code: Select all
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)