My Project 1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
SmbStaticTransforms.cpp
Go to the documentation of this file.
1/*
2Copyright 2023 by Julian Nubert, Robotic Systems Lab, ETH Zurich.
3All rights reserved.
4This file is released under the "BSD-3-Clause License".
5Please see the LICENSE file that has been included as part of this package.
6 */
7
8// Implementation
10
11// ROS
12#include <ros/ros.h>
13#include <tf/transform_listener.h>
14
15// Workspace
18
19namespace smb_se {
20
21SmbStaticTransforms::SmbStaticTransforms(const std::shared_ptr<ros::NodeHandle> privateNodePtr) : holistic_fusion::StaticTransformsTf() {
22 REGULAR_COUT << GREEN_START << " Initializing static transforms..." << COLOR_END << std::endl;
23}
24
26 // Super Method
28
29 // Print to console --------------------------
30 REGULAR_COUT << COLOR_END << " Looking up transforms in TF-tree." << std::endl;
31 REGULAR_COUT << COLOR_END << " Transforms between the following frames are required:" << std::endl;
32 REGULAR_COUT << COLOR_END << " Waiting for up to 100 seconds until they arrive..." << std::endl;
33
34 // Temporary variable
35 static tf::StampedTransform transform;
36
37 // Look up transforms ----------------------------
38 ros::Rate rosRate(10);
39 rosRate.sleep();
40
41 // Imu to LiDAR Link ---
42 REGULAR_COUT << COLOR_END << " Waiting for transform for 10 seconds.";
43 listener_.waitForTransform(imuFrame_, lidarOdometryFrame_, ros::Time(0), ros::Duration(1.0));
44 listener_.lookupTransform(imuFrame_, lidarOdometryFrame_, ros::Time(0), transform);
45 // I_Lidar
47 std::cout << YELLOW_START << "Smb-StaticTransforms" << COLOR_END
48 << " Translation I_Lidar: " << rv_T_frame1_frame2(imuFrame_, lidarOdometryFrame_).translation() << std::endl;
49 // Lidar_I
51
52 // Imu to VIO Link ---
53 REGULAR_COUT << COLOR_END << " Waiting for transform for 10 seconds.";
54 listener_.waitForTransform(imuFrame_, vioOdometryFrame_, ros::Time(0), ros::Duration(1.0));
55 listener_.lookupTransform(imuFrame_, vioOdometryFrame_, ros::Time(0), transform);
56 // I_VIO
58 std::cout << YELLOW_START << "Smb-StaticTransforms" << COLOR_END
59 << " Translation I_VIO: " << rv_T_frame1_frame2(imuFrame_, vioOdometryFrame_).translation() << std::endl;
60 // VIO_I
62
63 // Wheel Frames ---
65 << RED_START
66 << " As the Wheels are turning, we only use the position of the wheels frames and use the orientation of the baseLinkFrame_ frame."
67 << COLOR_END << std::endl;
68 // Left Wheel
69 REGULAR_COUT << COLOR_END << " Waiting for transform for 10 seconds.";
70 listener_.waitForTransform(imuFrame_, wheelLinearVelocityLeftFrame_, ros::Time(0), ros::Duration(1.0));
71 listener_.lookupTransform(imuFrame_, wheelLinearVelocityLeftFrame_, ros::Time(0), transform);
72 // I_WheelLeft
73 Eigen::Isometry3d T_I_WheelLeft;
74 holistic_fusion::tfToIsometry3(tf::Transform(transform), T_I_WheelLeft);
75 // Overwrite the orientation with the one of the baseLinkFrame_
76 T_I_WheelLeft.matrix().block<3, 3>(0, 0) = rv_T_frame1_frame2(imuFrame_, baseLinkFrame_).matrix().block<3, 3>(0, 0);
78 std::cout << YELLOW_START << "Smb-StaticTransforms" << COLOR_END
79 << " Translation I_WheelLeft: " << rv_T_frame1_frame2(imuFrame_, wheelLinearVelocityLeftFrame_).translation()
80 << ", Rotation: " << T_I_WheelLeft.matrix().block<3, 3>(0, 0) << std::endl;
81 // WheelLeft_I
83 // Right Wheel
84 REGULAR_COUT << COLOR_END << " Waiting for transform for 10 seconds.";
85 listener_.waitForTransform(imuFrame_, wheelLinearVelocityRightFrame_, ros::Time(0), ros::Duration(1.0));
86 listener_.lookupTransform(imuFrame_, wheelLinearVelocityRightFrame_, ros::Time(0), transform);
87 // I_WheelRight
88 Eigen::Isometry3d T_I_WheelRight;
89 holistic_fusion::tfToIsometry3(tf::Transform(transform), T_I_WheelRight);
90 // Overwrite the orientation with the one of the baseLinkFrame_
91 T_I_WheelRight.matrix().block<3, 3>(0, 0) = rv_T_frame1_frame2(imuFrame_, baseLinkFrame_).matrix().block<3, 3>(0, 0);
93 std::cout << YELLOW_START << "Smb-StaticTransforms" << COLOR_END
94 << " Translation I_WheelRight: " << rv_T_frame1_frame2(imuFrame_, wheelLinearVelocityRightFrame_).translation()
95 << ", Rotation: " << T_I_WheelRight.matrix().block<3, 3>(0, 0) << std::endl;
96 // WheelRight_I
98
99 REGULAR_COUT << GREEN_START << " Transforms looked up successfully." << COLOR_END << std::endl;
100 return true;
101}
102
103} // namespace smb_se
#define REGULAR_COUT
#define COLOR_END
#define GREEN_START
#define RED_START
#define YELLOW_START
Eigen::Isometry3d & lv_T_frame1_frame2(const std::string &frame1, const std::string &frame2)
const Eigen::Isometry3d & rv_T_frame1_frame2(const std::string &frame1, const std::string &frame2) const
SmbStaticTransforms(const std::shared_ptr< ros::NodeHandle > privateNodePtr)
void tfToIsometry3(const tf::Transform &tf_T, Eigen::Isometry3d &T)