## Angular velocity or derivative of Euler angles

Typically: "How do I... ", "How can I... " questions
juan-rodriguez
Posts: 8
Joined: 21 Jul 2016, 18:43

### Angular velocity or derivative of Euler angles

Hi there,

Currently, I am doing a project for my master where I need to work with a quadrotor. I need to develop a visual servoing controller. In order to do it, I need to know the angular velocities of the quadrotor w.r.t to the world frame of v-rep. I checked the function simGetVelocity which retrieves the angular velocity of the center of mass in absolute coordinates. I would like to know if the function retrieves the angular velocity of the CoM, or instead, the derivatives of the Euler angles (Here is brief explanation between the difference of both).

I made a test to check that the function is not returning the derivatives of the Euler angles, I computed the angles derivatives and then compared them with values returned by the function. The numerical results are almost the same. I got a bit confused. Could you please clarify which is the value returned by the function? (The derivative of the angles, or the angular velocity of the center of mass).

Moreover, in the description of the function, it is mentioned that it retrieves the velocities in absolute coordinates, so it means the velocities of the center of mass w.r.t the reference frame of V-REP?

Thanks

coppelia
Site Admin
Posts: 7226
Joined: 14 Dec 2012, 00:25

### Re: Angular velocity or derivative of Euler angles

Hello,

the function simGetVelocity gives your the linear and angular velocity of a dynamically enabled shape (i.e. a shape that is not static). The velocities are not computed by V-REP, but retrieved from the various physics engines. So, in case of the angular velocity, we have:
• Bullet: bulletRigidBody->getAngularVelocity()
• ODE: dBodyGetAngularVel(odeRigidBody)
• Vortex: vortexRigidBody->getAngularVelocity()
• Newton: NewtonBodyGetVelocity(newtonRigidBody,...)
Above velocity is not dependent on the position of the com. It is based on the derivative of Euler angles.

Cheers

juan-rodriguez
Posts: 8
Joined: 21 Jul 2016, 18:43

### Re: Angular velocity or derivative of Euler angles

Thanks for your answer!
I have one more question. Which is the reference frame of the Euler angles used for the derivatives? In the documentation of the simGetVelocity function is mentioned that the velocities are in absolute coordinates, so that means that the velocity is referred to the world frame of v-rep? If so, then the Euler angles too right?

Thanks

coppelia
Site Admin
Posts: 7226
Joined: 14 Dec 2012, 00:25

### Re: Angular velocity or derivative of Euler angles

You can't compute (e.g. for alpha): (alpha2-alpha1)/dt, because euler angles can jump. If you manually compute it, you would do:

Code: Select all

``````-- in frame t:
local m1=simGetObjectMatrix(objHandle,-1)
simInvertMatrix(m1)
-- in frame t+dt:
local m2=simGetObjectMatrix(objHandle,-1)
local m=simMultiplyMatrices(m1,m2) -- now m is the transf. matrix of obj at t, expressed relative to the transf. matrix of obj at t+dt
local euler=simGetEulerAnglesFromMatrix(m)
local da={euler/dt,euler/dt,euler/dt}``````
Cheers

juan-rodriguez
Posts: 8
Joined: 21 Jul 2016, 18:43

### Re: Angular velocity or derivative of Euler angles

I understood your point. However, my question was related to the reference frame for the simGetVelocity function. I mean, I only want to know, what does it mean absolute coordinates in the function description? Are the velocities referred to the world frame, or instead to the object itself? (or none of the two).

In the project that I am doing, I need to know to which frame is referred the angular velocities returned by simGetVelocity in order to use correctly the velocity in the controller.

Thanks

coppelia
Site Admin
Posts: 7226
Joined: 14 Dec 2012, 00:25

### Re: Angular velocity or derivative of Euler angles

The documentation is a little bit confusing. The linear velocity is expressed in the world reference frame. But the angular velocity is technically expressed in the reference frame of the object, one dynamic simulation step before current one, since it is computed as shown in my previous post.
If we wanted to express the angular velocity relative to the world reference frame, we would have to use a different velocity measure: you would obtain a rotation axis, and a velocity around that rotation axis. You can also do this in V-REP manually, with following code:

Code: Select all

``````-- in frame t:
local m1=simGetObjectMatrix(objHandle,-1)
-- in frame t+dt:
local m2=simGetObjectMatrix(objHandle,-1)
local rotationAxis,rotationAngle=simGetRotationAxis(m1,m2)
rotationVelocity=rotationAngle/dt``````
Cheers

juan-rodriguez
Posts: 8
Joined: 21 Jul 2016, 18:43

### Re: Angular velocity or derivative of Euler angles

Dear Coppelia, thanks a lot for your help.
Sorry for bothering you with a lot of questions, but how can I reconstruct the angular velocity from the rotation velocity? I mean, the rotation velocity is only one value while the angular velocity is composed by 3 vector components.
Moreover, If we have the angular velocity expressed in the reference frame of the object, won't be easier to obtain the angular velocity w.r.t world reference frame by multiplying the angular velocity by the rotation matrix from the object frame to the world reference frame?

Thanks!

coppelia
Site Admin
Posts: 7226
Joined: 14 Dec 2012, 00:25

### Re: Angular velocity or derivative of Euler angles

By using simRotateAroundAxis and some of the above mentioned API functions, you can convert from one representation to another.

You cannot directly transform a euler angle vector as you would transform a position or direction vector.

Cheers