Open jaybdub opened 10 years ago
Switched to a new class that does not inherit Eigen::Transform, but rather contains it. The reason for doing this is that several of the return types for the methods inherited in NamedTransform, are of type Eigen::Transform. Thus, NamedTransform could not be directly assigned from functions that return Eigen::Transform, like Eigen::Transform::Identity().
The new classed is named TfLink as shown below.
#ifndef KEYTRACK_TF_H
#define KEYTRACK_TF_H
#include <Eigen/Dense>
//using namespace Eigen;
namespace keytrack
{
class TfLink
{
private:
char* _a_name;
char* _b_name;
Eigen::Transform<float, 3, Eigen::Affine> _tf;
public:
TfLink(const char a_name[], const char b_name[])
{
_a_name = (char*)a_name;
_b_name = (char*)b_name;
_tf = Eigen::Transform<float, 3, Eigen::Affine>::Identity();
};
Eigen::Transform<float, 3, Eigen::Affine> tf()
{
return _tf;
};
char *a_name()
{
return _a_name;
};
char *b_name()
{
return _b_name;
};
};
}
#endif
Now I'm thinking scrap the class type to remove unneeded complexity. A simple struct with two strings representing each reference frame that the tf describes, and a tf object.
//To compile:
// g++ tf_eigen_test.cpp -I/home/john/eigen3
//#include "tf_eigen.h"
#include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
struct TfLink {
char* a;
char* b;
Transform<float, 3, Affine> tf;
};
int main(){
TfLink t;
t.a = "camera";
t.b = "robot";
Vector3f axis;
axis << 1,0,0;
t.tf = AngleAxisf(2.0f,axis);
cout << t.b << " as seen from " << t.a << endl;
cout << t.tf.matrix() << endl;
return 0;
}
Extended the Eigen::Transform class, to include names between the reference frames. I called this class keytrack::NamedTransform.
For reference on Transform class see Eigen/src/Geometry/Transform.h. Look here for information on template inheritance, and here for information on constructor inheritance.