-2

i am trying to use Eigen::Quaternionf. But i am getting when i just want to asign one Quaternion an error.

oldQuat = pos;

both are Eigen::Quaternionf, the following error is given. Is must be because the Methods are declared as constant (see: http://eigen.tuxfamily.org/dox/classEigen_1_1Quaternion.html)

Fehler: passing 'const Quaternionf {aka const Eigen::Quaternion<float>}' as 'this' argument of 'Eigen::Quaternion<Scalar, Options>& Eigen::Quaternion<Scalar, Options>::operator=(const Eigen::Quaternion<Scalar, Options>&) [with _Scalar = float, int _Options = 0, Eigen::Quaternion<Scalar, Options> = Eigen::Quaternion<float>]' discards qualifiers [-fpermissive]

I have to idea on how to get past this error. Thanks in advance

edit:

for (itCanon = canonicalValues.begin(), itTraj = exampleTraj.begin(); itCanon != canonicalValues.end(); ++itCanon,  itTraj++)
    {

        const SampledTrajectoryV2::TrajData& state = *itTraj;

        Eigen::Vector3f axis;
        axis << itTraj->getPosition(1), itTraj->getPosition(2), itTraj->getPosition(3);
        Eigen::AngleAxisf angleAxis(itTraj->getPosition(0), axis);

        Eigen::Quaternionf pos(angleAxis);
        pos.normalize();


    //Error in both these lines! Same error both times.
        Eigen::Vector3f vecVel = calcAngularVelocity(oldQuat, pos);
        oldQuat = pos;

        // D0 element R3x3 nicht kompatibel mit quat

        result[*itCanon] = - A_Z*(B_Z*2*log(pos) - TAU * vecVel);
}

oldQuat is declared in the header. as are A_z, B_Z and TAU.

Lenny
  • 111
  • 1
  • 3
  • 13

1 Answers1

-1

Eigen::Quaternionf<S, O>::operator= is declared as non const, but oldQuat is a const object (I suspect). Change it to non-const.

erenon
  • 18,838
  • 2
  • 61
  • 93
  • No it’s not. In fact, `operator=` isn’t provided at all, it’s implicitly defined (according to the documentation). – Konrad Rudolph Dec 02 '14 at 16:45
  • @KonradRudolph : Then one of the members (which types might depend on the template arugments) has a `const` `operator=` – erenon Dec 02 '14 at 16:53
  • No, they don’t either. You are misreading OP’s error message. – Konrad Rudolph Dec 02 '14 at 16:56
  • @KonradRudolph : I'm waiting to your correct answer, then. – erenon Dec 02 '14 at 16:58
  • Since the OP hasn’t provided sufficient context I cannot give a complete answer but I’m guessing my comment below the question is correct. But you’re also misunderstanding the intent of comments: just because I don’t know the correct answer doesn’t mean I shouldn’t point out errors in your answer – quite the contrary. – Konrad Rudolph Dec 02 '14 at 17:02
  • @KonradRudolph: True. I suspect `Quaternionf` inherits from `Eigen::Quaternionf`. Since it's const, operator= cannot be used. I'll update my answer. – erenon Dec 02 '14 at 17:07