|
37 | 37 | #include<fstream> |
38 | 38 |
|
39 | 39 |
|
| 40 | + |
| 41 | + |
40 | 42 | using namespace std; |
41 | 43 |
|
42 | 44 | namespace ORB_SLAM |
@@ -312,6 +314,35 @@ void Tracking::GrabImage(const sensor_msgs::ImageConstPtr& msg) |
312 | 314 | tf::Transform tfTcw(M,V); |
313 | 315 |
|
314 | 316 | 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); |
315 | 346 | } |
316 | 347 |
|
317 | 348 | } |
|
0 commit comments