Skip to content

Commit 2ee7e53

Browse files
Added two pose publisher for integration with MSF. The first is as per Pull raulmur#33 (thx Marc) the second w.r.t IMU
1 parent 281d925 commit 2ee7e53

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

include/Tracking.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "MapPublisher.h"
3939

4040
#include<tf/transform_broadcaster.h>
41+
#include "geometry_msgs/PoseStamped.h"
4142

4243

4344
namespace ORB_SLAM
@@ -180,6 +181,11 @@ class Tracking
180181

181182
// Transfor broadcaster (for visualization in rviz)
182183
tf::TransformBroadcaster mTfBr;
184+
185+
// Pose broadcaster
186+
ros::NodeHandle n;
187+
ros::Publisher PosPub = n.advertise<geometry_msgs::PoseStamped>("ORB_SLAM/pose", 5);
188+
ros::Publisher Pos2Pub = n.advertise<geometry_msgs::PoseStamped>("ORB_SLAM/pose_transformed", 5);
183189
};
184190

185191
} //namespace ORB_SLAM

src/Tracking.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include<fstream>
3838

3939

40+
41+
4042
using namespace std;
4143

4244
namespace ORB_SLAM
@@ -312,6 +314,35 @@ void Tracking::GrabImage(const sensor_msgs::ImageConstPtr& msg)
312314
tf::Transform tfTcw(M,V);
313315

314316
mTfBr.sendTransform(tf::StampedTransform(tfTcw,ros::Time::now(), "ORB_SLAM/World", "ORB_SLAM/Camera"));
317+
318+
geometry_msgs::PoseStamped poseMSG, poseMSGtransformed;
319+
poseMSG.pose.position.x = tfTcw.getOrigin().x();
320+
poseMSG.pose.position.y = tfTcw.getOrigin().y();
321+
poseMSG.pose.position.z = tfTcw.getOrigin().z();
322+
poseMSG.pose.orientation.x = tfTcw.getRotation().x();
323+
poseMSG.pose.orientation.y = tfTcw.getRotation().y();
324+
poseMSG.pose.orientation.z = tfTcw.getRotation().z();
325+
poseMSG.pose.orientation.w = tfTcw.getRotation().w();
326+
poseMSG.header.frame_id = "VSLAM";
327+
poseMSG.header.stamp = ros::Time::now();
328+
PosPub.publish(poseMSG);
329+
330+
tf::Transform tfTci, tfTiw;
331+
tfTci.setOrigin( tf::Vector3(9.0, 0.0, 0.0) ); // Note Translation are given in the parent frame
332+
tfTci.setRotation( tf::createQuaternionFromRPY(M_PI/2,M_PI/2,0) );
333+
334+
tfTiw = tfTci.inverse()*tfTcw;
335+
336+
poseMSG.pose.position.x = tfTiw.getOrigin().x();
337+
poseMSG.pose.position.y = tfTiw.getOrigin().y();
338+
poseMSG.pose.position.z = tfTiw.getOrigin().z();
339+
poseMSG.pose.orientation.x = tfTiw.getRotation().x();
340+
poseMSG.pose.orientation.y = tfTiw.getRotation().y();
341+
poseMSG.pose.orientation.z = tfTiw.getRotation().z();
342+
poseMSG.pose.orientation.w = tfTiw.getRotation().w();
343+
poseMSG.header.frame_id = "VSLAM_at_imu";
344+
poseMSG.header.stamp = ros::Time::now();
345+
Pos2Pub.publish(poseMSGtransformed);
315346
}
316347

317348
}

0 commit comments

Comments
 (0)