order of quaternion elements in RaveVector

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

order of quaternion elements in RaveVector

baxelrod

Hi,

 

I am using the C++ interface to read the geometry data out of my robot’s xml file and have a question about the elements in the RaveVector type.  This type defines x, y, z, and w elements.  However, when the body in my xml file has no rotation, x is 1 and y, z and w are 0.  This is represents a 180 degree rotation about x if w is the real component of the quaternion.  Is this by design?  Or is x the real component and y=i, z=j, and w=k? 

 

Here is an excerpt from my code:

 

int main()

{

    OpenRAVE::RaveInitialize(true);

    OpenRAVE::EnvironmentBasePtr penv = OpenRAVE::RaveCreateEnvironment();

    penv->SetDebugLevel(OpenRAVE::Level_Debug);

   

    OpenRAVE::RobotBasePtr robot = penv->ReadRobotXMLFile(“myrobot.xml”);

   

    std::vector<OpenRAVE::KinBody::LinkPtr> llist = robot->GetLinks();

   

    for (unsigned int i=0; i<llist.size(); i++)

    {

        printf("[%d] %s\n", i, llist[i]->GetName().c_str());

        std::vector<OpenRAVE::KinBody::Link::GeometryPtr> geoms = llist[i]->GetGeometries();

       

        for (unsigned int j=0; j<geoms.size(); j++)

        {

            printf("  {%d} type: %s\n", j, geometry_map[geoms[j]->GetType()].c_str());

            printf("    xyz: %f %f %f\n",

                   geoms[j]->GetTransform().trans.x,

                   geoms[j]->GetTransform().trans.y,

                   geoms[j]->GetTransform().trans.z);

            printf("    quat: %f %f %f %f\n",

                   geoms[j]->GetTransform().rot.x,

                   geoms[j]->GetTransform().rot.y,

                   geoms[j]->GetTransform().rot.z,

                   geoms[j]->GetTransform().rot.w);

        }

    }

}

 

And my xml file is dead simple:

 

<KinBody name="test">

  <Body name="testbody" type="static" >

    <Geom type="box">

    </Geom>

  </Body>

</KinBody>

 

 

Ben Axelrod

Sr. Robotics Software Engineer

iRobot Corporation

8 Crosby Drive, M/S 8-1

Bedford, MA 01730

(781) 430-3315

[hidden email]

 


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

Mehmet Dogar-2
Hi Ben,

In openrave x the real component and y=i, z=j, and w=k.

In case you don't believe me (since I am not Rosen :) ) take a look at how a quaternion is formed from axis angle:
https://github.com/rdiankov/openrave/blob/master/include/openrave/geometry.h#L815

-Mehmet



On Fri, Oct 25, 2013 at 4:39 PM, Axelrod, Ben <[hidden email]> wrote:

Hi,

 

I am using the C++ interface to read the geometry data out of my robot’s xml file and have a question about the elements in the RaveVector type.  This type defines x, y, z, and w elements.  However, when the body in my xml file has no rotation, x is 1 and y, z and w are 0.  This is represents a 180 degree rotation about x if w is the real component of the quaternion.  Is this by design?  Or is x the real component and y=i, z=j, and w=k? 

 

Here is an excerpt from my code:

 

int main()

{

    OpenRAVE::RaveInitialize(true);

    OpenRAVE::EnvironmentBasePtr penv = OpenRAVE::RaveCreateEnvironment();

    penv->SetDebugLevel(OpenRAVE::Level_Debug);

   

    OpenRAVE::RobotBasePtr robot = penv->ReadRobotXMLFile(“myrobot.xml”);

   

    std::vector<OpenRAVE::KinBody::LinkPtr> llist = robot->GetLinks();

   

    for (unsigned int i=0; i<llist.size(); i++)

    {

        printf("[%d] %s\n", i, llist[i]->GetName().c_str());

        std::vector<OpenRAVE::KinBody::Link::GeometryPtr> geoms = llist[i]->GetGeometries();

       

        for (unsigned int j=0; j<geoms.size(); j++)

        {

            printf("  {%d} type: %s\n", j, geometry_map[geoms[j]->GetType()].c_str());

            printf("    xyz: %f %f %f\n",

                   geoms[j]->GetTransform().trans.x,

                   geoms[j]->GetTransform().trans.y,

                   geoms[j]->GetTransform().trans.z);

            printf("    quat: %f %f %f %f\n",

                   geoms[j]->GetTransform().rot.x,

                   geoms[j]->GetTransform().rot.y,

                   geoms[j]->GetTransform().rot.z,

                   geoms[j]->GetTransform().rot.w);

        }

    }

}

 

And my xml file is dead simple:

 

<KinBody name="test">

  <Body name="testbody" type="static" >

    <Geom type="box">

    </Geom>

  </Body>

</KinBody>

 

 

Ben Axelrod

Sr. Robotics Software Engineer

iRobot Corporation

8 Crosby Drive, M/S 8-1

Bedford, MA 01730

<a href="tel:%28781%29%20430-3315" value="+17814303315" target="_blank">(781) 430-3315

[hidden email]

 


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

baxelrod
In reply to this post by baxelrod
Thanks Mehmet and Rosen,

Now I see the [] operator and will use that to avoid confusion. 

But something should really be done about this IMHO.  It is very confusing to say that a quaternion is [w x y z], then in the class that you use to hold quaternions you have w, x, y, and z fields but they don't actually correspond.  x is rot[0], y is rot[1]...  Please comment the code in the very least.  Perhaps a note in the geometric conventions as well.

It seems to me that the root of the issue is that you are using RaveVector for both translations and rotations, you have w,x,y,z, fields, and you define w to be first for quaternions.  I think if any of these was changed the issue would go away.  There are a number of solutions, but unfortunately i think all require braking changes. 

Thanks,
Ben

Ben Axelrod

Sr. Robotics Software Engineer

iRobot Corporation

8 Crosby Drive, M/S 8-1

Bedford, MA 01730

(781) 430-3315

[hidden email]


From: [hidden email] [[hidden email]] on behalf of Rosen Diankov [[hidden email]]
Sent: Friday, October 25, 2013 10:07 PM
To: Axelrod, Ben
Subject: Re: [OpenRAVE-users] order of quaternion elements in RaveVector

hi ben,

quaternion is [w x y z] where

(cos(ang/2),axisx*sin(ang/2),axisy*sin(ang/2),axisz*sin(ang/2))

it probably makes it cleaner to access it via rot[0], rot[1], rot[2], rot[3]


in any case, here's the conventions openrave follows. i'd read them carefully since they could save you lots of time later:

http://www.openrave.org/docs/latest_stable/geometric_conventions/

best,




2013/10/26 Axelrod, Ben <[hidden email]>

Hi,

 

I am using the C++ interface to read the geometry data out of my robot’s xml file and have a question about the elements in the RaveVector type.  This type defines x, y, z, and w elements.  However, when the body in my xml file has no rotation, x is 1 and y, z and w are 0.  This is represents a 180 degree rotation about x if w is the real component of the quaternion.  Is this by design?  Or is x the real component and y=i, z=j, and w=k? 

 

Here is an excerpt from my code:

 

int main()

{

    OpenRAVE::RaveInitialize(true);

    OpenRAVE::EnvironmentBasePtr penv = OpenRAVE::RaveCreateEnvironment();

    penv->SetDebugLevel(OpenRAVE::Level_Debug);

   

    OpenRAVE::RobotBasePtr robot = penv->ReadRobotXMLFile(“myrobot.xml”);

   

    std::vector<OpenRAVE::KinBody::LinkPtr> llist = robot->GetLinks();

   

    for (unsigned int i=0; i<llist.size(); i++)

    {

        printf("[%d] %s\n", i, llist[i]->GetName().c_str());

        std::vector<OpenRAVE::KinBody::Link::GeometryPtr> geoms = llist[i]->GetGeometries();

       

        for (unsigned int j=0; j<geoms.size(); j++)

        {

            printf("  {%d} type: %s\n", j, geometry_map[geoms[j]->GetType()].c_str());

            printf("    xyz: %f %f %f\n",

                   geoms[j]->GetTransform().trans.x,

                   geoms[j]->GetTransform().trans.y,

                   geoms[j]->GetTransform().trans.z);

            printf("    quat: %f %f %f %f\n",

                   geoms[j]->GetTransform().rot.x,

                   geoms[j]->GetTransform().rot.y,

                   geoms[j]->GetTransform().rot.z,

                   geoms[j]->GetTransform().rot.w);

        }

    }

}

 

And my xml file is dead simple:

 

<KinBody name="test">

  <Body name="testbody" type="static" >

    <Geom type="box">

    </Geom>

  </Body>

</KinBody>

 

 

Ben Axelrod

Sr. Robotics Software Engineer

iRobot Corporation

8 Crosby Drive, M/S 8-1

Bedford, MA 01730

<a href="tel:%28781%29%20430-3315" value="&#43;17814303315" target="_blank">(781) 430-3315

[hidden email]

 


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

Rosen Diankov
Administrator
alex,

your confusion is stemming from the fact that you are using xyzw to label the quaternion fields: xyz always has to mean axis, w always has to mean the scalar component.

openrave doesn't do that, which is why we've never had a problem. if you look at the geometry.h header file and search for quaternion you will see comments like:

///< rot is a quaternion=(cos(ang/2),axisx*sin(ang/2),axisy*sin(ang/2),axisz*sin(ang/2))

/// \param[in] quat quaternion, (s,vx,vy,vz)

therefore for us x is always the scalar component and yzw is always the axis.

in any case, i'll add more comments. thanks for the feedback ;0)



2013/10/27 Axelrod, Ben <[hidden email]>
Thanks Mehmet and Rosen,

Now I see the [] operator and will use that to avoid confusion. 

But something should really be done about this IMHO.  It is very confusing to say that a quaternion is [w x y z], then in the class that you use to hold quaternions you have w, x, y, and z fields but they don't actually correspond.  x is rot[0], y is rot[1]...  Please comment the code in the very least.  Perhaps a note in the geometric conventions as well.

It seems to me that the root of the issue is that you are using RaveVector for both translations and rotations, you have w,x,y,z, fields, and you define w to be first for quaternions.  I think if any of these was changed the issue would go away.  There are a number of solutions, but unfortunately i think all require braking changes. 

Thanks,
Ben


Ben Axelrod

Sr. Robotics Software Engineer

iRobot Corporation

8 Crosby Drive, M/S 8-1

Bedford, MA 01730

<a href="tel:%28781%29%20430-3315" value="+17814303315" target="_blank">(781) 430-3315

[hidden email]


From: [hidden email] [[hidden email]] on behalf of Rosen Diankov [[hidden email]]
Sent: Friday, October 25, 2013 10:07 PM
To: Axelrod, Ben
Subject: Re: [OpenRAVE-users] order of quaternion elements in RaveVector

hi ben,

quaternion is [w x y z] where

(cos(ang/2),axisx*sin(ang/2),axisy*sin(ang/2),axisz*sin(ang/2))

it probably makes it cleaner to access it via rot[0], rot[1], rot[2], rot[3]


in any case, here's the conventions openrave follows. i'd read them carefully since they could save you lots of time later:

http://www.openrave.org/docs/latest_stable/geometric_conventions/

best,




2013/10/26 Axelrod, Ben <[hidden email]>

Hi,

 

I am using the C++ interface to read the geometry data out of my robot’s xml file and have a question about the elements in the RaveVector type.  This type defines x, y, z, and w elements.  However, when the body in my xml file has no rotation, x is 1 and y, z and w are 0.  This is represents a 180 degree rotation about x if w is the real component of the quaternion.  Is this by design?  Or is x the real component and y=i, z=j, and w=k? 

 

Here is an excerpt from my code:

 

int main()

{

    OpenRAVE::RaveInitialize(true);

    OpenRAVE::EnvironmentBasePtr penv = OpenRAVE::RaveCreateEnvironment();

    penv->SetDebugLevel(OpenRAVE::Level_Debug);

   

    OpenRAVE::RobotBasePtr robot = penv->ReadRobotXMLFile(“myrobot.xml”);

   

    std::vector<OpenRAVE::KinBody::LinkPtr> llist = robot->GetLinks();

   

    for (unsigned int i=0; i<llist.size(); i++)

    {

        printf("[%d] %s\n", i, llist[i]->GetName().c_str());

        std::vector<OpenRAVE::KinBody::Link::GeometryPtr> geoms = llist[i]->GetGeometries();

       

        for (unsigned int j=0; j<geoms.size(); j++)

        {

            printf("  {%d} type: %s\n", j, geometry_map[geoms[j]->GetType()].c_str());

            printf("    xyz: %f %f %f\n",

                   geoms[j]->GetTransform().trans.x,

                   geoms[j]->GetTransform().trans.y,

                   geoms[j]->GetTransform().trans.z);

            printf("    quat: %f %f %f %f\n",

                   geoms[j]->GetTransform().rot.x,

                   geoms[j]->GetTransform().rot.y,

                   geoms[j]->GetTransform().rot.z,

                   geoms[j]->GetTransform().rot.w);

        }

    }

}

 

And my xml file is dead simple:

 

<KinBody name="test">

  <Body name="testbody" type="static" >

    <Geom type="box">

    </Geom>

  </Body>

</KinBody>

 

 

Ben Axelrod

Sr. Robotics Software Engineer

iRobot Corporation

8 Crosby Drive, M/S 8-1

Bedford, MA 01730

<a href="tel:%28781%29%20430-3315" value="+17814303315" target="_blank">(781) 430-3315

[hidden email]

 


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users




------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

mklingen2
Rosen, I understand that you can represent quaternions in any way you wish (and in your case, you've chosen 'x' to be the scalar component), and everything works out just fine. However,  please note that virtually every other 3D library uses 'w' to represent the scalar component of the quaternion, and it has become a defacto standard. Naturally, people often want to integrate OpenRAVE with other libraries, and inevitably run into the quaternion ordering issue.

Recently, I ran into this issue while writing an RVIZ-based viewer for openrave. I've had to integrate OpenRAVE poses with those in Ogre, ROS pose messages, Bullet, and Eigen. In *all* of those other libraries, 'w' is the scalar component of a quaternion. Once I'd figured out that OpenRAVE uses 'x' to represent the scalar component, it was easy to write a conversion function and remember to use it every time, but before that things were failing in baffling ways.

I'm not sure what the solution to this problem is, but better documentation seems like a good start.
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

Michael Koval
I also ran into this issue. The documentation on OpenRAVE's geometry
conventions actually makes the problem worse because it says that
quaternions are "defined with the scalar value as the first component.
For example [w x y z]...". While this is technically correct, it also
implies that "q.w" is the first element (and, thus, the scalar value)
of the quaternion "q". However, that is not the case because
RaveVector stores components in the order [x y z w].

It would be great if you add a note about the order of components in
RaveVector to the geometry conventions page and to the relevant places
(RaveVector and RaveTransform?) in the doxygen comments. One of Ben's
two suggested solutions would be ideal, but they would both introduce
major breaking changes.

-Mike

On Sun, Oct 27, 2013 at 12:23 PM, mklingen2 <[hidden email]> wrote:

> Rosen, I understand that you can represent quaternions in any way you wish
> (and in your case, you've chosen 'x' to be the scalar component), and
> everything works out just fine. However,  please note that virtually every
> other 3D library uses 'w' to represent the scalar component of the
> quaternion, and it has become a defacto standard. Naturally, people often
> want to integrate OpenRAVE with other libraries, and inevitably run into the
> quaternion ordering issue.
>
> Recently, I ran into this issue while writing an RVIZ-based viewer for
> openrave. I've had to integrate OpenRAVE poses with those in Ogre, ROS pose
> messages, Bullet, and Eigen. In *all* of those other libraries, 'w' is the
> scalar component of a quaternion. Once I'd figured out that OpenRAVE uses
> 'x' to represent the scalar component, it was easy to write a conversion
> function and remember to use it every time, but before that things were
> failing in baffling ways.
>
> I'm not sure what the solution to this problem is, but better documentation
> seems like a good start.
>
>
>
> --
> View this message in context: http://openrave-users-list.185357.n3.nabble.com/order-of-quaternion-elements-in-RaveVector-tp4026802p4026808.html
> Sent from the OpenRAVE Users List mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

Chris Dellin
I can also confirm that I was definitely bitten by this confusion at
one point, and since then, I always make sure to copy-paste the same
code when working with OpenRAVE quaternions:

> OpenRAVE::Transform t = kinbody->GetTransform();
> px = t.trans.x;
> py = t.trans.y;
> pz = t.trans.z;
> qx = t.rot.y;
> qy = t.rot.z;
> qz = t.rot.w;
> qw = t.rot.x;

One suggestion that would lessen this confusion without breaking
existing code would be to add reference accessors to the RaveVector
class:

> T& qx() { return y; }
> T& qy() { return z; }
> T& qz() { return w; }
> T& qw() { return x; }

(You would probably want const versions too.)  This would allow
getting and setting of the components of a vector (if it represents a
quaternion) with the common names.

Cheers,
- Chris

On 10/27/13, Michael Koval <[hidden email]> wrote:

> I also ran into this issue. The documentation on OpenRAVE's geometry
> conventions actually makes the problem worse because it says that
> quaternions are "defined with the scalar value as the first component.
> For example [w x y z]...". While this is technically correct, it also
> implies that "q.w" is the first element (and, thus, the scalar value)
> of the quaternion "q". However, that is not the case because
> RaveVector stores components in the order [x y z w].
>
> It would be great if you add a note about the order of components in
> RaveVector to the geometry conventions page and to the relevant places
> (RaveVector and RaveTransform?) in the doxygen comments. One of Ben's
> two suggested solutions would be ideal, but they would both introduce
> major breaking changes.
>
> -Mike
>
> On Sun, Oct 27, 2013 at 12:23 PM, mklingen2 <[hidden email]> wrote:
>> Rosen, I understand that you can represent quaternions in any way you
>> wish
>> (and in your case, you've chosen 'x' to be the scalar component), and
>> everything works out just fine. However,  please note that virtually
>> every
>> other 3D library uses 'w' to represent the scalar component of the
>> quaternion, and it has become a defacto standard. Naturally, people often
>> want to integrate OpenRAVE with other libraries, and inevitably run into
>> the
>> quaternion ordering issue.
>>
>> Recently, I ran into this issue while writing an RVIZ-based viewer for
>> openrave. I've had to integrate OpenRAVE poses with those in Ogre, ROS
>> pose
>> messages, Bullet, and Eigen. In *all* of those other libraries, 'w' is
>> the
>> scalar component of a quaternion. Once I'd figured out that OpenRAVE uses
>> 'x' to represent the scalar component, it was easy to write a conversion
>> function and remember to use it every time, but before that things were
>> failing in baffling ways.
>>
>> I'm not sure what the solution to this problem is, but better
>> documentation
>> seems like a good start.
>>
>>
>>
>> --
>> View this message in context:
>> http://openrave-users-list.185357.n3.nabble.com/order-of-quaternion-elements-in-RaveVector-tp4026802p4026808.html
>> Sent from the OpenRAVE Users List mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register
>> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Openrave-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/openrave-users
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users
>


--
Christopher Dellin
[hidden email]

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

Rosen Diankov
Administrator
sorry guys, it looks like calling the axis part of the quaternion xyz and the scalar part w is just going to create more confusion.

i removed the confusing bit [w x y z] of guidelines on openrave.org on the tutorial and will add more comments.

thanks,



2013/10/28 Chris Dellin <[hidden email]>
I can also confirm that I was definitely bitten by this confusion at
one point, and since then, I always make sure to copy-paste the same
code when working with OpenRAVE quaternions:

> OpenRAVE::Transform t = kinbody->GetTransform();
> px = t.trans.x;
> py = t.trans.y;
> pz = t.trans.z;
> qx = t.rot.y;
> qy = t.rot.z;
> qz = t.rot.w;
> qw = t.rot.x;

One suggestion that would lessen this confusion without breaking
existing code would be to add reference accessors to the RaveVector
class:

> T& qx() { return y; }
> T& qy() { return z; }
> T& qz() { return w; }
> T& qw() { return x; }

(You would probably want const versions too.)  This would allow
getting and setting of the components of a vector (if it represents a
quaternion) with the common names.

Cheers,
- Chris

On 10/27/13, Michael Koval <[hidden email]> wrote:
> I also ran into this issue. The documentation on OpenRAVE's geometry
> conventions actually makes the problem worse because it says that
> quaternions are "defined with the scalar value as the first component.
> For example [w x y z]...". While this is technically correct, it also
> implies that "q.w" is the first element (and, thus, the scalar value)
> of the quaternion "q". However, that is not the case because
> RaveVector stores components in the order [x y z w].
>
> It would be great if you add a note about the order of components in
> RaveVector to the geometry conventions page and to the relevant places
> (RaveVector and RaveTransform?) in the doxygen comments. One of Ben's
> two suggested solutions would be ideal, but they would both introduce
> major breaking changes.
>
> -Mike
>
> On Sun, Oct 27, 2013 at 12:23 PM, mklingen2 <[hidden email]> wrote:
>> Rosen, I understand that you can represent quaternions in any way you
>> wish
>> (and in your case, you've chosen 'x' to be the scalar component), and
>> everything works out just fine. However,  please note that virtually
>> every
>> other 3D library uses 'w' to represent the scalar component of the
>> quaternion, and it has become a defacto standard. Naturally, people often
>> want to integrate OpenRAVE with other libraries, and inevitably run into
>> the
>> quaternion ordering issue.
>>
>> Recently, I ran into this issue while writing an RVIZ-based viewer for
>> openrave. I've had to integrate OpenRAVE poses with those in Ogre, ROS
>> pose
>> messages, Bullet, and Eigen. In *all* of those other libraries, 'w' is
>> the
>> scalar component of a quaternion. Once I'd figured out that OpenRAVE uses
>> 'x' to represent the scalar component, it was easy to write a conversion
>> function and remember to use it every time, but before that things were
>> failing in baffling ways.
>>
>> I'm not sure what the solution to this problem is, but better
>> documentation
>> seems like a good start.
>>
>>
>>
>> --
>> View this message in context:
>> http://openrave-users-list.185357.n3.nabble.com/order-of-quaternion-elements-in-RaveVector-tp4026802p4026808.html
>> Sent from the OpenRAVE Users List mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register
>> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Openrave-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/openrave-users
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users
>


--
Christopher Dellin
[hidden email]

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: order of quaternion elements in RaveVector

Rosen Diankov
Administrator
we add the following methods to the vector field if you guys think its best:

Vector GetQuaternionIJK()

dReal GetQuaternionScalar()




2013/10/28 Rosen Diankov <[hidden email]>
sorry guys, it looks like calling the axis part of the quaternion xyz and the scalar part w is just going to create more confusion.

i removed the confusing bit [w x y z] of guidelines on openrave.org on the tutorial and will add more comments.

thanks,



2013/10/28 Chris Dellin <[hidden email]>
I can also confirm that I was definitely bitten by this confusion at
one point, and since then, I always make sure to copy-paste the same
code when working with OpenRAVE quaternions:

> OpenRAVE::Transform t = kinbody->GetTransform();
> px = t.trans.x;
> py = t.trans.y;
> pz = t.trans.z;
> qx = t.rot.y;
> qy = t.rot.z;
> qz = t.rot.w;
> qw = t.rot.x;

One suggestion that would lessen this confusion without breaking
existing code would be to add reference accessors to the RaveVector
class:

> T& qx() { return y; }
> T& qy() { return z; }
> T& qz() { return w; }
> T& qw() { return x; }

(You would probably want const versions too.)  This would allow
getting and setting of the components of a vector (if it represents a
quaternion) with the common names.

Cheers,
- Chris

On 10/27/13, Michael Koval <[hidden email]> wrote:
> I also ran into this issue. The documentation on OpenRAVE's geometry
> conventions actually makes the problem worse because it says that
> quaternions are "defined with the scalar value as the first component.
> For example [w x y z]...". While this is technically correct, it also
> implies that "q.w" is the first element (and, thus, the scalar value)
> of the quaternion "q". However, that is not the case because
> RaveVector stores components in the order [x y z w].
>
> It would be great if you add a note about the order of components in
> RaveVector to the geometry conventions page and to the relevant places
> (RaveVector and RaveTransform?) in the doxygen comments. One of Ben's
> two suggested solutions would be ideal, but they would both introduce
> major breaking changes.
>
> -Mike
>
> On Sun, Oct 27, 2013 at 12:23 PM, mklingen2 <[hidden email]> wrote:
>> Rosen, I understand that you can represent quaternions in any way you
>> wish
>> (and in your case, you've chosen 'x' to be the scalar component), and
>> everything works out just fine. However,  please note that virtually
>> every
>> other 3D library uses 'w' to represent the scalar component of the
>> quaternion, and it has become a defacto standard. Naturally, people often
>> want to integrate OpenRAVE with other libraries, and inevitably run into
>> the
>> quaternion ordering issue.
>>
>> Recently, I ran into this issue while writing an RVIZ-based viewer for
>> openrave. I've had to integrate OpenRAVE poses with those in Ogre, ROS
>> pose
>> messages, Bullet, and Eigen. In *all* of those other libraries, 'w' is
>> the
>> scalar component of a quaternion. Once I'd figured out that OpenRAVE uses
>> 'x' to represent the scalar component, it was easy to write a conversion
>> function and remember to use it every time, but before that things were
>> failing in baffling ways.
>>
>> I'm not sure what the solution to this problem is, but better
>> documentation
>> seems like a good start.
>>
>>
>>
>> --
>> View this message in context:
>> http://openrave-users-list.185357.n3.nabble.com/order-of-quaternion-elements-in-RaveVector-tp4026802p4026808.html
>> Sent from the OpenRAVE Users List mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register
>> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Openrave-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/openrave-users
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users
>


--
Christopher Dellin
[hidden email]

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users