1 #include "header/worldInterface.h" 5 this->callerName = callerName;
6 std::cout <<
"[" << callerName <<
"][WORLD_INTERFACE] Start"<< std::endl;
12 int WorldInterface::waitReady(std::string objName){
19 std::string objTopic =
"/" + objName;
20 tfListener.waitForTransform(
"world", objTopic, ros::Time(0), ros::Duration(3.0));
26 int WorldInterface::waitReady(std::string firstFrame, std::string secondFrame){
33 std::string firstFrameTopic =
"/" + firstFrame;
34 std::string secondFrameTopic =
"/" + secondFrame;
36 tfListener.waitForTransform(firstFrameTopic, secondFrameTopic, ros::Time(0), ros::Duration(3.0));
42 int WorldInterface::getT(Eigen::Matrix4d* xTx_eigen, std::string firstFrame, std::string secondFrame){
43 std::string firstFrameTopic =
"/" + firstFrame;
44 std::string secondFrameTopic =
"/" + secondFrame;
46 tf::StampedTransform wTt_tf;
50 tfListener.lookupTransform(firstFrameTopic, secondFrameTopic, ros::Time(0), wTt_tf);
52 }
catch (tf::TransformException &ex) {
53 ROS_ERROR(
"%s",ex.what());
54 ros::Duration(1.0).sleep();
57 *xTx_eigen = CONV::transfMatrix_tf2eigen(wTt_tf);
63 int WorldInterface::getwT(Eigen::Matrix4d* wTt_eigen, std::string objName){
65 std::string topic =
"/" + objName;
66 tf::StampedTransform wTt_tf;
69 tfListener.lookupTransform(
"world", topic, ros::Time(0), wTt_tf);
71 }
catch (tf::TransformException &ex) {
72 ROS_ERROR(
"%s",ex.what());
73 ros::Duration(1.0).sleep();
76 *wTt_eigen = CONV::transfMatrix_tf2eigen(wTt_tf);
82 int WorldInterface::getwPos(Eigen::Vector3d* pos, std::string robotName){
84 tf::StampedTransform wTv_tf;
86 std::string topic =
"/" + robotName;
88 tfListener.lookupTransform(
"world", topic, ros::Time(0), wTv_tf);
90 }
catch (tf::TransformException &ex) {
91 ROS_ERROR(
"%s",ex.what());
92 ros::Duration(1.0).sleep();
95 Eigen::Matrix4d wTvother_eigen = CONV::transfMatrix_tf2eigen(wTv_tf);
96 *pos = wTvother_eigen.topRightCorner<3,1>();
WorldInterface(std::string callerName)
WorldInterface.