Skip to content

Commit 3107249

Browse files
author
Marco Tranzatto
authored
Merge pull request #29 from ethz-asl/feature/publish_tf
Publish TF of local ENU frame
2 parents 3b99f25 + ff525e9 commit 3107249

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/gps_to_pose_conversion_node.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <geometry_msgs/PointStamped.h>
1313
#include <geodetic_utils/geodetic_conv.hpp>
1414
#include <std_msgs/Float64.h>
15+
#include <tf/transform_broadcaster.h>
1516

1617
bool g_is_sim;
1718
bool g_publish_pose;
@@ -34,6 +35,9 @@ double g_covariance_orientation_x;
3435
double g_covariance_orientation_y;
3536
double g_covariance_orientation_z;
3637
std::string g_frame_id;
38+
std::string g_tf_child_frame_id;
39+
40+
std::shared_ptr<tf::TransformBroadcaster> p_tf_broadcaster;
3741

3842
void imu_callback(const sensor_msgs::ImuConstPtr& msg)
3943
{
@@ -148,6 +152,18 @@ void gps_callback(const sensor_msgs::NavSatFixConstPtr& msg)
148152
}
149153

150154
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));
151167
}
152168

153169
int main(int argc, char **argv) {
@@ -157,6 +173,7 @@ int main(int argc, char **argv) {
157173

158174
g_got_imu = false;
159175
g_got_altitude = false;
176+
p_tf_broadcaster = std::make_shared<tf::TransformBroadcaster>();
160177

161178
// Use different coordinate transform if using simulator
162179
if (!pnh.getParam("is_sim", g_is_sim)) {
@@ -184,6 +201,8 @@ int main(int argc, char **argv) {
184201
g_covariance_orientation_z, 0.11);
185202
ros::param::param<std::string>("~frame_id",
186203
g_frame_id, "world");
204+
ros::param::param<std::string>("~tf_child_frame_id",
205+
g_tf_child_frame_id, "gps_receiver");
187206

188207
// Specify whether to publish pose or not
189208
ros::param::param("~publish_pose", g_publish_pose, false);

0 commit comments

Comments
 (0)