Added function to convert from a Rot3 to a vector quaternion that works in matlab. Fixed plot2DTrajectory to actually plot poses when there are no marginals

release/4.3a0
Alex Cunningham 2013-03-25 17:58:11 +00:00
parent 06be7b4926
commit e8cb5491f0
4 changed files with 25 additions and 3 deletions

View File

@ -418,6 +418,7 @@ virtual class Rot3 : gtsam::Value {
double pitch() const; double pitch() const;
double yaw() const; double yaw() const;
// Vector toQuaternion() const; // FIXME: Can't cast to Vector properly // Vector toQuaternion() const; // FIXME: Can't cast to Vector properly
Vector quaternion() const;
}; };
virtual class Pose2 : gtsam::Value { virtual class Pose2 : gtsam::Value {

View File

@ -345,6 +345,12 @@ namespace gtsam {
*/ */
Quaternion toQuaternion() const; Quaternion toQuaternion() const;
/**
* Converts to a generic matrix to allow for use with matlab
* In format: w x y z
*/
Vector quaternion() const;
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;

View File

@ -343,6 +343,17 @@ Quaternion Rot3::toQuaternion() const {
return Quaternion(rot_); return Quaternion(rot_);
} }
/* ************************************************************************* */
Vector Rot3::quaternion() const {
Quaternion q = toQuaternion();
Vector v(4);
v(0) = q.w();
v(1) = q.x();
v(2) = q.y();
v(3) = q.z();
return v;
}
/* ************************************************************************* */ /* ************************************************************************* */
pair<Matrix3, Vector3> RQ(const Matrix3& A) { pair<Matrix3, Vector3> RQ(const Matrix3& A) {

View File

@ -42,11 +42,15 @@ for i = 0:keys.size-1
end end
% Draw final covariance ellipse % Draw final covariance ellipse
if ~isempty(lastIndex) && haveMarginals if ~isempty(lastIndex)
lastKey = keys.at(lastIndex); lastKey = keys.at(lastIndex);
lastPose = values.at(lastKey); lastPose = values.at(lastKey);
P = marginals.marginalCovariance(lastKey); if haveMarginals
gtsam.plotPose2(lastPose, 'g', P); P = marginals.marginalCovariance(lastKey);
gtsam.plotPose2(lastPose, 'g', P);
else
gtsam.plotPose2(lastPose, 'g', []);
end
end end
if ~holdstate if ~holdstate