## Re: [PlayerStage-Gazebo] Problem getting rotation in gazebo 0.4.0

 Re: [PlayerStage-Gazebo] Problem getting rotation in gazebo 0.4.0 From: Jonathan ILIAS - 2005-01-10 08:22:27 ```Andrew Howard a =E9crit : > Hmmm, looks like a problem with the quatern -> euler conversion. This > could be because of a bug in the conversion function, or (more likely) > it could be intrinsic to the geometry (more than one Euler angle maps > to the given orientation). This is why Euler angles suck. >=20 > A better (more stable) way to determine the orientation is to rotate a > unit vector and use the atan2() of the x-y projection; e.g. (off the > top of my head, so probably buggy): >=20 > a =3D GzCoordPositionAdd(GzVectorSet(1.0, 0, 0), GzVectorZero(), > quat_rotation); > z_rotation =3D atan2(a.y, a.x); >=20 > This will work so long as the robot remains more-or-less upright on a > flat surface (I presume this is what you have). >=20 Thank you for your help. I just wanted to reply that Quaternion got the=20 same problem when i remembered that there were two robots :) Argh... so many time spent with a stupid problem... Sorry, i'll get=20 seven coffes and will run seven time around my computer saying "i'll not=20 make a stupid mistake again, i'll not make a stupid mistake again, ..." ;= ) Thank you again, your post doesn't solve my problem but get me learn a=20 little more about euler angles. Have a good day ! --=20 Jonathan ILIAS ```

 [PlayerStage-Gazebo] Problem getting rotation in gazebo 0.4.0 From: Jonathan ILIAS - 2005-01-07 10:26:32 ```Hello, We had to create our own model. It is based (not inherited) on Pioneer2DX. I'm just begining to learn hacking gazebo, so maybe there is an easier solution i don't know... I want to export the model position and rotation via a custom way (we currently do not plan to implement a player client, maybe in a future). Thus, in the method IfaceTransmitData of my Model, I do something like this : void Miro::IfaceTransmitData() { GzVector position; GzQuatern quat_rotation; GzVector euler_rotation; gz_superviseur_lock(this->superviseur_iface,1); // export the position position = this->GetPosition (); this->superviseur_iface->data->position[0] = position.x; this->superviseur_iface->data->position[1] = position.y; this->superviseur_iface->data->position[2] = position.z; // export the rotation quat_rotation = this->chassis->GetRotation (); // to euler as we just want rotation with the ground plane //(around z axis) euler_rotation = GzQuaternToEuler(quat_rotation); this->superviseur_iface->data->orientation = euler_rotation.z; printf ("\nrot = %f\n", (float)euler_rotation.z, (float)euler_rotation.y, (float)euler_rotation.x); gz_superviseur_unlock(this->superviseur_iface); } And the output of gazebo is : z = 3.141593 z = 0.000000 Time 0.002 0.020 [-0.018] 0.190 [8644%] z = 3.141593 z = 0.000000 Time 0.024 0.040 [-0.016] 0.190 [777%] z = 3.141593 z = 0.000000 Time 0.044 0.060 [-0.016] 0.190 [431%] z = 3.141593 I dont understand why one time z is 0 (correct orientation) and one time it is PI. If i move the robot driving the wheels, i got something like this : z = 2.708632 Time 21.942 21.960 [-0.018] 1.440 [ 7%] z = 3.141593 z = 2.714418 Time 21.964 21.980 [-0.016] 1.440 [ 7%] z = 3.141593 z = 2.720204 Time 21.982 22.000 [-0.018] 1.440 [ 7%] z = 3.141593 If the robot hits something, the wrong orientation value changes, but remain stable : z = 0.647221 Time 6.349 6.360 [-0.011] 1.630 [ 26%] z = -3.116178 z = 0.648426 Time 6.364 6.380 [-0.016] 1.630 [ 26%] z = -3.116178 z = 0.649611 Time 6.383 6.400 [-0.017] 1.630 [ 26%] z = -3.116178 z = 0.650776 Time 6.409 6.420 [-0.011] 1.650 [ 26%] z = -3.116178 Any idea about this ? i'm quite lost... -- Jonathan ILIAS ```
 Re: [PlayerStage-Gazebo] Problem getting rotation in gazebo 0.4.0 From: Andrew Howard - 2005-01-07 17:26:15 ```Hmmm, looks like a problem with the quatern -> euler conversion. This could be because of a bug in the conversion function, or (more likely) it could be intrinsic to the geometry (more than one Euler angle maps to the given orientation). This is why Euler angles suck. A better (more stable) way to determine the orientation is to rotate a unit vector and use the atan2() of the x-y projection; e.g. (off the top of my head, so probably buggy): a = GzCoordPositionAdd(GzVectorSet(1.0, 0, 0), GzVectorZero(), quat_rotation); z_rotation = atan2(a.y, a.x); This will work so long as the robot remains more-or-less upright on a flat surface (I presume this is what you have). A. On Fri, 07 Jan 2005 11:26:33 +0100, Jonathan ILIAS wrote: > Hello, > > We had to create our own model. It is based (not inherited) on Pioneer2DX. > > I'm just begining to learn hacking gazebo, so maybe there is an easier > solution i don't know... > > I want to export the model position and rotation via a custom way (we > currently do not plan to implement a player client, maybe in a future). > > Thus, in the method IfaceTransmitData of my Model, I do something like > this : > > void Miro::IfaceTransmitData() > { > GzVector position; > GzQuatern quat_rotation; > GzVector euler_rotation; > > gz_superviseur_lock(this->superviseur_iface,1); > > // export the position > position = this->GetPosition (); > this->superviseur_iface->data->position[0] = position.x; > this->superviseur_iface->data->position[1] = position.y; > this->superviseur_iface->data->position[2] = position.z; > > // export the rotation > quat_rotation = this->chassis->GetRotation (); > // to euler as we just want rotation with the ground plane > //(around z axis) > euler_rotation = GzQuaternToEuler(quat_rotation); > this->superviseur_iface->data->orientation = euler_rotation.z; > > printf ("\nrot = %f\n", (float)euler_rotation.z, > (float)euler_rotation.y, (float)euler_rotation.x); > > gz_superviseur_unlock(this->superviseur_iface); > } > > And the output of gazebo is : > > z = 3.141593 > > z = 0.000000 > Time 0.002 0.020 [-0.018] 0.190 [8644%] > z = 3.141593 > > z = 0.000000 > Time 0.024 0.040 [-0.016] 0.190 [777%] > z = 3.141593 > > z = 0.000000 > Time 0.044 0.060 [-0.016] 0.190 [431%] > z = 3.141593 > > I dont understand why one time z is 0 (correct orientation) and one time > it is PI. > > If i move the robot driving the wheels, i got something like this : > z = 2.708632 > Time 21.942 21.960 [-0.018] 1.440 [ 7%] > z = 3.141593 > > z = 2.714418 > Time 21.964 21.980 [-0.016] 1.440 [ 7%] > z = 3.141593 > > z = 2.720204 > Time 21.982 22.000 [-0.018] 1.440 [ 7%] > z = 3.141593 > > If the robot hits something, the wrong orientation value changes, but > remain stable : > z = 0.647221 > Time 6.349 6.360 [-0.011] 1.630 [ 26%] > z = -3.116178 > > z = 0.648426 > Time 6.364 6.380 [-0.016] 1.630 [ 26%] > z = -3.116178 > > z = 0.649611 > Time 6.383 6.400 [-0.017] 1.630 [ 26%] > z = -3.116178 > > z = 0.650776 > Time 6.409 6.420 [-0.011] 1.650 [ 26%] > z = -3.116178 > > Any idea about this ? i'm quite lost... > > -- > Jonathan ILIAS > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Playerstage-gazebo mailing list > Playerstage-gazebo@... > https://lists.sourceforge.net/lists/listinfo/playerstage-gazebo > ```
 Re: [PlayerStage-Gazebo] Problem getting rotation in gazebo 0.4.0 From: Jonathan ILIAS - 2005-01-10 08:22:27 ```Andrew Howard a =E9crit : > Hmmm, looks like a problem with the quatern -> euler conversion. This > could be because of a bug in the conversion function, or (more likely) > it could be intrinsic to the geometry (more than one Euler angle maps > to the given orientation). This is why Euler angles suck. >=20 > A better (more stable) way to determine the orientation is to rotate a > unit vector and use the atan2() of the x-y projection; e.g. (off the > top of my head, so probably buggy): >=20 > a =3D GzCoordPositionAdd(GzVectorSet(1.0, 0, 0), GzVectorZero(), > quat_rotation); > z_rotation =3D atan2(a.y, a.x); >=20 > This will work so long as the robot remains more-or-less upright on a > flat surface (I presume this is what you have). >=20 Thank you for your help. I just wanted to reply that Quaternion got the=20 same problem when i remembered that there were two robots :) Argh... so many time spent with a stupid problem... Sorry, i'll get=20 seven coffes and will run seven time around my computer saying "i'll not=20 make a stupid mistake again, i'll not make a stupid mistake again, ..." ;= ) Thank you again, your post doesn't solve my problem but get me learn a=20 little more about euler angles. Have a good day ! --=20 Jonathan ILIAS ```