My Project 1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
AnymalStaticTransforms.cpp
Go to the documentation of this file.
1/*
2Copyright 2024 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
19// Macro Constant
20#define TF_WAIT_TIME 30.0
21
22namespace anymal_se {
23
24AnymalStaticTransforms::AnymalStaticTransforms(const std::shared_ptr<ros::NodeHandle> privateNodePtr) : holistic_fusion::StaticTransformsTf() {
25 REGULAR_COUT << GREEN_START << " Initializing static transforms..." << COLOR_END << std::endl;
26}
27
29 // Print to console --------------------------
30 REGULAR_COUT << " Looking up transforms in TF-tree." << std::endl;
31 REGULAR_COUT << " Transforms between the following frames are required: " << lioOdometryFrame_ << ", " << gnssFrame_ << ", " << imuFrame_
32 << ", " << baseLinkFrame_ << std::endl;
33 REGULAR_COUT << " Waiting for up to " << TF_WAIT_TIME << " seconds until they arrive..." << std::endl;
34
35 // Temporary variable
36 static tf::StampedTransform transform;
37
38 // Look up transforms ----------------------------
39 // Sleep before subscribing, otherwise sometimes dying in the beginning of rosbag
40 ros::Rate rosRate(10);
41 rosRate.sleep();
42
43 // Imu to LiDAR Link ---
44 REGULAR_COUT << " Looking up transform from " << imuFrame_ << " to " << lioOdometryFrame_ << std::endl;
45 listener_.waitForTransform(imuFrame_, lioOdometryFrame_, ros::Time(0), ros::Duration(TF_WAIT_TIME));
46 listener_.lookupTransform(imuFrame_, lioOdometryFrame_, ros::Time(0), transform);
47 // I_Lidar
49 REGULAR_COUT << " Translation I_Lidar: " << rv_T_frame1_frame2(imuFrame_, lioOdometryFrame_).translation() << std::endl;
50 // Lidar_I
52
53 // Imu to GNSS Link ---
54 try {
55 REGULAR_COUT << " Looking up transform from " << imuFrame_ << " to " << gnssFrame_ << std::endl;
56 listener_.waitForTransform(imuFrame_, gnssFrame_, ros::Time(0), ros::Duration(TF_WAIT_TIME));
57 listener_.lookupTransform(imuFrame_, gnssFrame_, ros::Time(0), transform);
58 // I_Gnss
60 REGULAR_COUT << " Translation I_GnssL: " << rv_T_frame1_frame2(imuFrame_, gnssFrame_).translation() << std::endl;
61 // GnssL_I
63 } catch (const tf2::LookupException& e) {
64 REGULAR_COUT << RED_START << " Could not find transformations for GNSS in TF tree." << COLOR_END << std::endl;
65 }
66
67 REGULAR_COUT << GREEN_START << " Transforms looked up successfully." << COLOR_END << std::endl;
68
69 // Call parent class
71 return true;
72}
73
74} // namespace anymal_se
#define TF_WAIT_TIME
#define REGULAR_COUT
#define COLOR_END
#define GREEN_START
#define RED_START
AnymalStaticTransforms(const std::shared_ptr< ros::NodeHandle > privateNodePtr)
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
void tfToIsometry3(const tf::Transform &tf_T, Eigen::Isometry3d &T)