From: Andrew Howard <andrew.howard@gm...>  20050107 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 xy 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 moreorless upright on a flat surface (I presume this is what you have). A. On Fri, 07 Jan 2005 11:26:33 +0100, Jonathan ILIAS <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 postholiday blues > Get a FREE limited edition SourceForge.net tshirt from ThinkGeek. > It's fun and FREE  well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Playerstagegazebo mailing list > Playerstagegazebo@... > https://lists.sourceforge.net/lists/listinfo/playerstagegazebo > 