[eigen] Re: Quaternion initialization from Block/segment (Eigen 3 beta 1)

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On a similar note.
Is it possible to do the following in a smarter way?

X_new.segment(3,4) = Eigen::Vector4d(q.x(), q.y(), q.z(), q.w());


Since the Quaternion class allows to be initialized using a Vector4d, shouldn't it be possible to set it back as well?
either
X_new.segment(3,4) = q;
or even just
Eigen::Vector4d vec = q;

Neither compiles.

-Jens

On 22/07/2010, at 18.33, Jens Andersen wrote:

> Hi from a long time lurker, one-time poster 
> 
> I'm trying to use eigen to efficiently work with a quaternion stored inside an Eigen::VectorXd (a state vector in an EKF-based SLAM)
> 
> I have attempted to do the following:
> 
> Eigen::VectorXd myvector;
> Eigen::Quaternion q(myvector.segment(3,4));
> 
> I'm not sure whether this method avoids the copy?
> 
> This doesn't work however, and gives the following error:
> /some/path/SLAM/src/Eigen/src/Geometry/Quaternion.h:443:0 
> /some/path/SLAM/src/Eigen/src/Geometry/Quaternion.h:443: error: incomplete type 'Eigen::ei_quaternionbase_assign_impl<Eigen::Block<Eigen::Matrix<double, -0x00000000000000001, 1, 0, -0x00000000000000001, 1>, -0x00000000000000001, 1, true>, -0x00000000000000001, 1>' used in nested name specifier
> 
> To me, this makes me think that Quaternion doesn't understand Eigen::Block. Is this the case or am I doing something wrong?
> 
> I can "work-around" it by doing 
> Eigen::Quaternion q(Eigen::Vector4d(myvector.segment(3,4))); 
> but this seems sort of unclean (And presumably requires more copying?)
> 
> Thanks,
> -Jens
> 




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/