How to get deviation for self balancing robot.
-
- Posts: 19
- Joined: 30 Dec 2020, 15:32
How to get deviation for self balancing robot.
I am using sim.getObjectOrientation to get the orientation for self balancing robot.I need to get the robots deviation from its own Z axis.Initially I tried using world frame as reference and it works fine for initial position as I get orientation at index 3 as -1.57. But when I rotate the bot to,the orientation changes to 1.57.Is there anything I could do to get the same deviation irrespective of its orientation wrt the world frame.
Re: How to get deviation for self balancing robot.
Hello,
working with orientation can be tricky or difficult to wrap your head around. There are at least 3 ways you can understand an orientation:
Now you can check the alignment of one of above axes, and compare it with the world reference axes. There you can easily extract various angles.
Cheers
working with orientation can be tricky or difficult to wrap your head around. There are at least 3 ways you can understand an orientation:
- using quaternions: this is rather difficult to understand, but very convenient for calculations. e.g. sim.getObjectQuaternion
- using Euler angles: this is easier to understand, but not very convenient for calculations. e.g. sim.getObjectOrientation
- using a rotation matrix: this is probably the easiest to visualize. In CoppeliaSim you can get the transformation matrix for a reference frame: sim.getObjectMatrix
Code: Select all
local m=sim.getObjectMatrix(objectHandle,-1)
local unitXAxis={m[1],m[5],m[9]}
local unitYAxis={m[2],m[6],m[10]}
local unitZAxis={m[3],m[7],m[11]}
Cheers