12
12
#include < geometry_msgs/PointStamped.h>
13
13
#include < geodetic_utils/geodetic_conv.hpp>
14
14
#include < std_msgs/Float64.h>
15
+ #include < tf/transform_broadcaster.h>
15
16
16
17
bool g_is_sim;
17
18
bool g_publish_pose;
@@ -34,6 +35,9 @@ double g_covariance_orientation_x;
34
35
double g_covariance_orientation_y;
35
36
double g_covariance_orientation_z;
36
37
std::string g_frame_id;
38
+ std::string g_tf_child_frame_id;
39
+
40
+ std::shared_ptr<tf::TransformBroadcaster> p_tf_broadcaster;
37
41
38
42
void imu_callback (const sensor_msgs::ImuConstPtr& msg)
39
43
{
@@ -148,6 +152,18 @@ void gps_callback(const sensor_msgs::NavSatFixConstPtr& msg)
148
152
}
149
153
150
154
g_gps_transform_pub.publish (transform_msg);
155
+
156
+ // Fill up TF broadcaster
157
+ tf::Transform transform;
158
+ transform.setOrigin (tf::Vector3 (x, y, z));
159
+ transform.setRotation (tf::Quaternion (g_latest_imu_msg.orientation .x ,
160
+ g_latest_imu_msg.orientation .y ,
161
+ g_latest_imu_msg.orientation .z ,
162
+ g_latest_imu_msg.orientation .w ));
163
+ p_tf_broadcaster->sendTransform (tf::StampedTransform (transform,
164
+ ros::Time::now (),
165
+ g_frame_id,
166
+ g_tf_child_frame_id));
151
167
}
152
168
153
169
int main (int argc, char **argv) {
@@ -157,6 +173,7 @@ int main(int argc, char **argv) {
157
173
158
174
g_got_imu = false ;
159
175
g_got_altitude = false ;
176
+ p_tf_broadcaster = std::make_shared<tf::TransformBroadcaster>();
160
177
161
178
// Use different coordinate transform if using simulator
162
179
if (!pnh.getParam (" is_sim" , g_is_sim)) {
@@ -184,6 +201,8 @@ int main(int argc, char **argv) {
184
201
g_covariance_orientation_z, 0.11 );
185
202
ros::param::param<std::string>(" ~frame_id" ,
186
203
g_frame_id, " world" );
204
+ ros::param::param<std::string>(" ~tf_child_frame_id" ,
205
+ g_tf_child_frame_id, " gps_receiver" );
187
206
188
207
// Specify whether to publish pose or not
189
208
ros::param::param (" ~publish_pose" , g_publish_pose, false );
0 commit comments