My Project 1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
Position3StaticTransforms.cpp
Go to the documentation of this file.
1/*
2Copyright 2024 by Julian Nubert & Timon Mathis, Robotic Systems Lab & Autonomous 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
14// Workspace
16
17namespace position3_se {
18
19Position3StaticTransforms::Position3StaticTransforms(const std::shared_ptr<ros::NodeHandle> privateNodePtr, bool usePrism, bool useGnss)
21 std::cout << YELLOW_START << "StaticTransformsTf" << GREEN_START << " Initializing static transforms..." << COLOR_END << std::endl;
22
23 // Set Bools
24 usePrism_ = usePrism;
25 useGnss_ = useGnss;
26}
27
29 // Print to console --------------------------
30 std::cout << YELLOW_START << "StaticTransformsTf" << COLOR_END << " Looking up transforms in TF-tree." << std::endl;
31 std::cout << YELLOW_START << "StaticTransformsTf" << COLOR_END << " Transforms between the following frames are required:" << std::endl;
32 std::cout << YELLOW_START << "StaticTransformsTf" << COLOR_END << " " << prismPositionMeasFrame_ << ", " << imuFrame_ << std::endl;
33 std::cout << YELLOW_START << "StaticTransformsTf" << COLOR_END << " " << gnssPositionMeasFrame_ << ", " << imuFrame_ << std::endl;
34 std::cout << YELLOW_START << "StaticTransformsTf" << COLOR_END << " Waiting for up to 100 seconds until they arrive..." << std::endl;
35
36 // Temporary variable
37 static tf::StampedTransform transform;
38
39 // Look up transforms ----------------------------
40 // Sleep before subscribing, otherwise sometimes dying in the beginning of rosbag
41 ros::Rate rosRate(10);
42 rosRate.sleep();
43
44 // Imu to Prism Link ---
45 if (usePrism_) {
46 listener_.waitForTransform(imuFrame_, prismPositionMeasFrame_, ros::Time(0), ros::Duration(5.0));
47 listener_.lookupTransform(imuFrame_, prismPositionMeasFrame_, ros::Time(0), transform);
48
49 // I_Prism
51 std::cout << YELLOW_START << "PositionEstimator" << COLOR_END << " Translation I_Prism: " << std::endl
52 << rv_T_frame1_frame2(imuFrame_, prismPositionMeasFrame_).translation() << std::endl;
53 std::cout << YELLOW_START << "PositionEstimator" << COLOR_END << " Rotation I_Prism: " << std::endl
54 << rv_T_frame1_frame2(imuFrame_, prismPositionMeasFrame_).rotation() << std::endl;
55 // Prism_I
57 }
58
59 // Imu to GNSS Antenna Link (for Position) ---
60 if (useGnss_) {
61 listener_.waitForTransform(imuFrame_, gnssPositionMeasFrame_, ros::Time(0), ros::Duration(5.0));
62 listener_.lookupTransform(imuFrame_, gnssPositionMeasFrame_, ros::Time(0), transform);
63
64 // I_Gnss1
66 std::cout << YELLOW_START << "PositionEstimator" << COLOR_END << " Translation I_Gnss: " << std::endl
67 << rv_T_frame1_frame2(imuFrame_, gnssPositionMeasFrame_).translation() << std::endl;
68 std::cout << YELLOW_START << "PositionEstimator" << COLOR_END << " Rotation I_Gnss: " << std::endl
69 << rv_T_frame1_frame2(imuFrame_, gnssPositionMeasFrame_).rotation() << std::endl;
70 // Gnss1_I
72 }
73
74 // Imu to CPT7 Link (for Offline Pose) ---
75 if (useGnss_) {
76 listener_.waitForTransform(imuFrame_, gnssOfflinePoseMeasFrame_, ros::Time(0), ros::Duration(5.0));
77 listener_.lookupTransform(imuFrame_, gnssOfflinePoseMeasFrame_, ros::Time(0), transform);
78
79 // I_Gnss2
81 std::cout << YELLOW_START << "PositionEstimator" << COLOR_END << " Translation I_Gnss2: " << std::endl
82 << rv_T_frame1_frame2(imuFrame_, gnssOfflinePoseMeasFrame_).translation() << std::endl;
83 std::cout << YELLOW_START << "PositionEstimator" << COLOR_END << " Rotation I_Gnss2: " << std::endl
84 << rv_T_frame1_frame2(imuFrame_, gnssOfflinePoseMeasFrame_).rotation() << std::endl;
85 // Gnss2_I
87 }
88
89 // Wrapping up --------------------------
90 std::cout << YELLOW_START << "StaticTransformsTf" << GREEN_START << " Transforms looked up successfully." << COLOR_END << std::endl;
91
92 // Call parent class
94 return true;
95}
96
97} // namespace position3_se
#define COLOR_END
#define GREEN_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
Position3StaticTransforms(const std::shared_ptr< ros::NodeHandle > privateNodePtr, bool usePrism, bool useGnss)
void tfToIsometry3(const tf::Transform &tf_T, Eigen::Isometry3d &T)