void ROSOutput3DWrapper::publishTrackedFrame(Frame* kf) { lsd_slam_viewer::keyframeMsg fMsg; fMsg.id = kf->id(); fMsg.time = kf->timeStampNs()/1000000.0; fMsg.isKeyframe = false; memcpy(fMsg.camToWorld.data(),kf->getScaledCamToWorld().cast<float>().data(),sizeof(float)*7); fMsg.fx = kf->fx(publishLvl); fMsg.fy = kf->fy(publishLvl); fMsg.cx = kf->cx(publishLvl); fMsg.cy = kf->cy(publishLvl); fMsg.width = kf->width(publishLvl); fMsg.height = kf->height(publishLvl); fMsg.pointcloud.clear(); liveframe_publisher.publish(fMsg); SE3 camToWorld = se3FromSim3(kf->getScaledCamToWorld()); geometry_msgs::PoseStamped pMsg; pMsg.pose.position.x = camToWorld.translation()[0]; pMsg.pose.position.y = camToWorld.translation()[1]; pMsg.pose.position.z = camToWorld.translation()[2]; pMsg.pose.orientation.x = camToWorld.so3().unit_quaternion().x(); pMsg.pose.orientation.y = camToWorld.so3().unit_quaternion().y(); pMsg.pose.orientation.z = camToWorld.so3().unit_quaternion().z(); pMsg.pose.orientation.w = camToWorld.so3().unit_quaternion().w(); if (pMsg.pose.orientation.w < 0) { pMsg.pose.orientation.x *= -1; pMsg.pose.orientation.y *= -1; pMsg.pose.orientation.z *= -1; pMsg.pose.orientation.w *= -1; } pMsg.header.stamp = ros::Time(kf->timeStampNs()/1000000.0); pMsg.header.frame_id = "world"; pose_publisher.publish(pMsg); }
Sim3 Sim3 ::from_SE3(const SE3 & se3) { return Sim3(ScSO3(1.,se3.so3()),se3.translation()); }