Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <Eigen/StdVector>
  2. #include <iostream>
  3. #include <stdint.h>
  4.  
  5.  
  6. #include "g2o/types/sba/types_six_dof_expmap.h"
  7. #include <cmath>
  8. #include <g2o/types/slam3d/se3quat.h>
  9. #include <g2o/types/slam3d/vertex_se3.h>
  10.  
  11. using namespace Eigen;
  12. using namespace std;
  13. #define PI 3.14159265
  14.  
  15. int main(int argc, const char* argv[]){
  16.  
  17.  
  18. /* Poses:
  19. The camera moves on circle on the z plane
  20. Create the Gt poses and add them as vertices VertexSE3Expmap
  21. */
  22. vector<g2o::SE3Quat,
  23. aligned_allocator<g2o::SE3Quat> > true_poses;
  24. int n=20;
  25. double angle_step=360.0/(double)n/180.0*PI;
  26. int overall_vertex_counter=0;
  27. for (int i=0; i<n; i++)
  28. {
  29. Vector3d t(sin(angle_step*i),
  30. -cos(angle_step*i),
  31. -1 );
  32.  
  33. Eigen::Quaterniond q(1.0, 0, 0, 0);
  34. g2o::SE3Quat pose(q, t);
  35. true_poses.push_back(pose);
  36.  
  37. //create a vertex representing the pose
  38. g2o::VertexSE3 * v_se3
  39. = new g2o::VertexSE3();
  40. v_se3->setId(overall_vertex_counter);
  41. v_se3->setEstimate(pose);
  42.  
  43.  
  44. if (i<2){
  45. v_se3->setFixed(true);
  46. }
  47. v_se3->setHessianIndex(overall_vertex_counter);
  48.  
  49. //optimizer.addVertex(v_se3);
  50. for (int di = 0; di < v_se3->dimension(); di++)
  51. {
  52. std::cout << "hessian(" << di << "," << di << ")=" << v_se3->hessian(di, di) << "\n";
  53. }
  54. overall_vertex_counter++;
  55.  
  56. }
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement