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
/*
2
Copyright 2024 by Julian Nubert, Robotic Systems Lab, ETH Zurich.
3
All rights reserved.
4
This file is released under the "BSD-3-Clause License".
5
Please see the LICENSE file that has been included as part of this package.
6
*/
7
8
// Implementation
9
#include "
anymal_estimator_graph/AnymalStaticTransforms.h
"
10
11
// ROS
12
#include <ros/ros.h>
13
#include <tf/transform_listener.h>
14
15
// Workspace
16
#include "
anymal_estimator_graph/constants.h
"
17
#include "
holistic_fusion_ros/util/conversions.h
"
18
19
// Macro Constant
20
#define TF_WAIT_TIME 30.0
21
22
namespace
anymal_se
{
23
24
AnymalStaticTransforms::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
28
bool
AnymalStaticTransforms::findTransformations
() {
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
48
holistic_fusion::tfToIsometry3
(tf::Transform(transform),
lv_T_frame1_frame2
(
imuFrame_
,
lioOdometryFrame_
));
49
REGULAR_COUT
<<
" Translation I_Lidar: "
<<
rv_T_frame1_frame2
(
imuFrame_
,
lioOdometryFrame_
).translation() << std::endl;
50
// Lidar_I
51
lv_T_frame1_frame2
(
lioOdometryFrame_
,
imuFrame_
) =
rv_T_frame1_frame2
(
imuFrame_
,
lioOdometryFrame_
).inverse();
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
59
holistic_fusion::tfToIsometry3
(tf::Transform(transform),
lv_T_frame1_frame2
(
imuFrame_
,
gnssFrame_
));
60
REGULAR_COUT
<<
" Translation I_GnssL: "
<<
rv_T_frame1_frame2
(
imuFrame_
,
gnssFrame_
).translation() << std::endl;
61
// GnssL_I
62
lv_T_frame1_frame2
(
gnssFrame_
,
imuFrame_
) =
rv_T_frame1_frame2
(
imuFrame_
,
gnssFrame_
).inverse();
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
70
holistic_fusion::StaticTransformsTf::findTransformations
();
71
return
true
;
72
}
73
74
}
// namespace anymal_se
TF_WAIT_TIME
#define TF_WAIT_TIME
Definition
AnymalStaticTransforms.cpp:20
AnymalStaticTransforms.h
REGULAR_COUT
#define REGULAR_COUT
Definition
DynamicFactorGraphStateKey.h:16
COLOR_END
#define COLOR_END
Definition
HolisticFusionDualGraph.h:21
GREEN_START
#define GREEN_START
Definition
HolisticFusionDualGraph.h:18
RED_START
#define RED_START
Definition
HolisticFusionDualGraph.h:20
anymal_se::AnymalStaticTransforms::lioOdometryFrame_
std::string lioOdometryFrame_
Definition
AnymalStaticTransforms.h:34
anymal_se::AnymalStaticTransforms::AnymalStaticTransforms
AnymalStaticTransforms(const std::shared_ptr< ros::NodeHandle > privateNodePtr)
Definition
AnymalStaticTransforms.cpp:24
anymal_se::AnymalStaticTransforms::findTransformations
bool findTransformations() override
Definition
AnymalStaticTransforms.cpp:28
anymal_se::AnymalStaticTransforms::gnssFrame_
std::string gnssFrame_
Definition
AnymalStaticTransforms.h:35
holistic_fusion::StaticTransformsTf::findTransformations
bool findTransformations() override
Definition
StaticTransformsTf.cpp:20
holistic_fusion::StaticTransformsTf::listener_
tf::TransformListener listener_
Definition
StaticTransformsTf.h:27
holistic_fusion::StaticTransformsTf::StaticTransformsTf
StaticTransformsTf()=default
holistic_fusion::StaticTransforms::imuFrame_
std::string imuFrame_
Definition
StaticTransforms.h:47
holistic_fusion::StaticTransforms::baseLinkFrame_
std::string baseLinkFrame_
Definition
StaticTransforms.h:48
holistic_fusion::TransformsDictionary< Eigen::Isometry3d >::lv_T_frame1_frame2
Eigen::Isometry3d & lv_T_frame1_frame2(const std::string &frame1, const std::string &frame2)
Definition
TransformsDictionary.h:62
holistic_fusion::TransformsDictionary< Eigen::Isometry3d >::rv_T_frame1_frame2
const Eigen::Isometry3d & rv_T_frame1_frame2(const std::string &frame1, const std::string &frame2) const
Definition
TransformsDictionary.h:76
anymal_se
Definition
AnymalEstimator.h:40
holistic_fusion
Absolute.
Definition
AdmissibleGtsamSymbols.h:11
holistic_fusion::tfToIsometry3
void tfToIsometry3(const tf::Transform &tf_T, Eigen::Isometry3d &T)
Definition
conversions.cpp:70
constants.h
conversions.h
ros
examples
anymal_estimator_graph
src
lib
AnymalStaticTransforms.cpp
Generated by
1.15.0