Gazebo: Q&A Forum - RSS feedhttp://answers.gazebosim.org/questions/Open source question and answer forum for GazeboenCopyright Askbot, 2010-2011.Sun, 21 Apr 2019 09:23:17 -0500How to apply an extrinsic rotation to a link, programmatically?http://answers.gazebosim.org/question/22339/how-to-apply-an-extrinsic-rotation-to-a-link-programmatically/I have models written in SDF that I want to rotate at specific extrinsic angles before starting a Gazebo simulation with them. I have the roll, pitch and yaw of the pose of the link, I have the extrinsic roll, pitch and yaw of the desired rotation, and I want to find out the formula for obtaining the roll, pitch and yaw of the link, after the rotation, so that I can update the pose values in the SDF file.
I couldn't find a source for the Euler angle convention that Gazebo uses, but I can tell that it is using intrinsic angles because when I rotate a link on the X axis by changing its roll pose number, it rotates around the extrinsic X axis, but if I then change the pitch pose number, it doesn't rotate around the extrinsic Y axis but its own, intrinsic, Y axis.
I'll greatly appreciate any help, thank you!
**Edit:** I've managed to find out about a widely used [transformations library](https://www.lfd.uci.edu/~gohlke/code/transformations.py.html) and I've managed to write the following code:
Re = euler_matrix(arr[3]-np.pi, arr[4], arr[5], 'rxyz')
Rx = rotation_matrix(r_arr[0], [1, 0, 0])
Ry = rotation_matrix(r_arr[1], [0, 1, 0])
Rz = rotation_matrix(r_arr[2], [0, 0, 1])
M = concatenate_matrices(Re, Rx, Ry, Rz)
euler = euler_from_matrix(M, 'rxyz')
arr[3] = euler[0]
arr[4] = euler[1]
arr[5] = euler[2]
where r_arr contains the desired extrinsic rotations and arr[3:6] contains the current intrinsic rotations.
Here is the result:
![hand rotated 90 degrees on the Y axis](/upfiles/15558744315746221.png)
The hand has been rotated 90 degrees on the Y axis. The little finger didn't come out right, I think this is a numerical inaccuracy, the links of the little finger being the only ones with negative pitch from all the other fingers. If there is a better way, I'm open to suggestions.
I'm also attaching the [hand SDF file](/upfiles/15558746353024074.world).altvaliSun, 21 Apr 2019 09:23:17 -0500http://answers.gazebosim.org/question/22339/Compute roll, pitch and yaw from 3D vectorhttp://answers.gazebosim.org/question/22154/compute-roll-pitch-and-yaw-from-3d-vector/ Hi !
I'm trying to build SDF tree models from a description file.
The branches are modeled by cylinders.
For each cylinder, I have : x, y, z : coords of the cylinder, vx, vy, vz : vector supporting the cylinder.
Since the `<pose>` takes roll, pitch and yaw angles to build a cylinder, I have to compute them from the direction vector (vx, vy, vz).
Here's how I do it, using `numpy`:
`roll = np.arctan2(vz, vy)`
`pitch = np.arctan2(vx, vz)`
`yaw = np.arctan2(vy, vx)`
I'm not getting the results I want, some of the branches are clearly misplaced. I noticed that Gazebo places a cylinder along the z axis if you provide yaw, pitch, roll = 0, so I tried to rotate by 90° on the x axis like so :
`roll = np.arctan2(vz, vy) + 1.5708`
without success.
If you have any advice on how to get these Euler angles right, feel free to share !
Have a nice day.
LoicSun, 24 Mar 2019 08:48:23 -0500http://answers.gazebosim.org/question/22154/Calculate Pitch, Roll, Yaw (with python tensorflow)http://answers.gazebosim.org/question/19214/calculate-pitch-roll-yaw-with-python-tensorflow/Dear All,
I'm working with Gazebo through python in a virtual environment for simulating modular robots, and I'm having trouble to calculate the Euler angles (Pitch, Roll, Yaw) of the robots' parts using tensorflow. I provide tensorflow an orientation matrix witch I fetch from Gazebo, following examples I've seen around, however, the method Im trying to call is non existent. Obs: I did indstall tensorflow and tf in the virtual environment.
import tensorflow
explicit_quat = [orientation.x, orientation.y, orientation.z, orientation.w]
euler = tensorflow.transformations.euler_from_quaternion(explicit_quat)
# The ERROR: 'module' object has no attribute 'transformations'
I also tried it with the tf module, but I get the same.
Can you please help me?
Thank you!Karine MirasThu, 03 May 2018 11:32:51 -0500http://answers.gazebosim.org/question/19214/