1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| #include <iostream> #include <stdio.h> #include <vector> #include <iomanip> #include <unistd.h> #include <pangolin/pangolin.h> #include <Eigen/Core> #include <Eigen/Dense>
using namespace std; using namespace Eigen;
int main(int argc, char **argv) {
pangolin::CreateWindowAndBind("Trajectory Viewer", 1024, 768); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
pangolin::OpenGlRenderState s_cam( pangolin::ProjectionMatrix(1024, 768, 500, 500, 512, 389, 0.1, 1000), pangolin::ModelViewLookAt(0, -0.1, -1.8, 0, 0, 0, 0.0, -1.0, 0.0) );
pangolin::View &d_cam = pangolin::CreateDisplay() .SetBounds(0.0, 1.0, 0.0, 1.0, -1024.0f / 768.0f) .SetHandler(new pangolin::Handler3D(s_cam));
vector<Isometry3d, Eigen::aligned_allocator<Isometry3d>> poses;
Eigen::Isometry3d T_camera = Eigen::Isometry3d::Identity(); cout<<"T_camera: "<<endl; cout<<T_camera.matrix()<<endl; poses.push_back(T_camera);
Eigen::Isometry3d Tcb_1= Eigen::Isometry3d::Identity(); Matrix3d R1 = AngleAxisd(M_PI/2,Vector3d(1, 0, 0)).toRotationMatrix(); Matrix3d R2 = AngleAxisd(-3*M_PI/4,Vector3d(0, 1, 0)).toRotationMatrix(); Matrix3d Rcb_1 = R2 * R1 ; Eigen::Vector3d tcb_1; tcb_1 << -0.03, 0, -0.231; Tcb_1.rotate(Rcb_1); Tcb_1.pretranslate(tcb_1); cout<<"Tcb_1: "<<endl; cout<<Tcb_1.matrix()<<endl; poses.push_back(Tcb_1);
while (!pangolin::ShouldQuit()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); d_cam.Activate(s_cam); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glLineWidth(2);
for (size_t i = 0; i < poses.size(); i++) { Vector3d Ow = poses[i].translation(); Vector3d Xw = poses[i] * (0.1 * Vector3d(1, 0, 0)); Vector3d Yw = poses[i] * (0.1 * Vector3d(0, 1, 0)); Vector3d Zw = poses[i] * (0.1 * Vector3d(0, 0, 1)); glBegin(GL_LINES); glColor3f(1.0, 0.0, 0.0); glVertex3d(Ow[0], Ow[1], Ow[2]); glVertex3d(Xw[0], Xw[1], Xw[2]); glColor3f(0.0, 1.0, 0.0); glVertex3d(Ow[0], Ow[1], Ow[2]); glVertex3d(Yw[0], Yw[1], Yw[2]); glColor3f(0.0, 0.0, 1.0); glVertex3d(Ow[0], Ow[1], Ow[2]); glVertex3d(Zw[0], Zw[1], Zw[2]); glEnd(); } pangolin::FinishFrame(); } }
|