00001 #include <ros/ros.h>
00002 #include <tf/transform_broadcaster.h>
00003 #include <tf/tf.h>
00004
00005 #include <uncertain_tf/UncertainTransformListener.h>
00006 #include <uncertain_tf/UncertainTransformBroadcaster.h>
00007
00008 #include <geometry_msgs/PoseArray.h>
00009
00010 using namespace uncertain_tf;
00011 using namespace std;
00012
00013 int main(int argc, char** argv)
00014 {
00015 ros::init(argc, argv, "my_tf_listener");
00016
00017 ros::NodeHandle node;
00018
00019 tf::TransformListener listener;
00020
00021 UncertainTransformBroadcaster utfb;
00022
00023 UncertainTransformListener ulistener;
00024
00025 ros::AsyncSpinner spinner(2);
00026 spinner.start();
00027
00029 {
00030 tf::Transform trans;
00031 trans.setOrigin(tf::Vector3(0,0,0));
00032 trans.setRotation(tf::Quaternion(0,0,0,1));
00033 utfb.sendTransform(tf::StampedTransform(trans,ros::Time(1),"/map","/base_link"));
00034 }
00035
00036 {
00037 tf::Transform trans;
00038 trans.setOrigin(tf::Vector3(1,0,0));
00039 trans.setRotation(tf::Quaternion(0,0,0,1));
00040 utfb.sendTransform(tf::StampedTransform(trans,ros::Time(1),"/base_link","/object"));
00041 }
00042
00043 {
00044 tf::Transform trans;
00045 trans.setOrigin(tf::Vector3(1,0,0));
00046 trans.setRotation(tf::Quaternion(0,0,0,1));
00047 utfb.sendTransform(tf::StampedTransform(trans,ros::Time(1),"/base_link","/gripper"));
00048 }
00049
00050 {
00051
00052 StampedCovariance stc;
00053 stc.resize(6,6);
00054 stc.setZero();
00055
00056
00057 stc(0,0) = 0.0025;
00058 stc(1,1) = 0.0025;
00059
00060 stc.frame_id_ = "/base_link";
00061 stc.stamp_ = ros::Time(1);
00062 utfb.sendCovariance(stc);
00063 }
00064
00065 ros::Duration(0.1).sleep();
00066
00067 {
00068 std::vector<StampedTransform> transform_samples;
00069 ulistener.sampleTransform("/gripper", "/object", ros::Time(1), transform_samples, 10);
00070 for (std::vector<StampedTransform>::iterator it = transform_samples.begin(); it != transform_samples.end(); ++it)
00071 {
00072 std::cout << (*it).getOrigin().x() << " " << (*it).getOrigin().y() << " "<< (*it).getOrigin().z() << std::endl;
00073 }
00074 }
00075
00076
00078 {
00079 tf::Transform trans;
00080 trans.setOrigin(tf::Vector3(0,0,0));
00081 trans.setRotation(tf::Quaternion(0,0,0,1));
00082 utfb.sendTransform(tf::StampedTransform(trans,ros::Time(2),"/map","/base_link"));
00083 }
00084
00085 {
00086 tf::Transform trans;
00087 trans.setOrigin(tf::Vector3(1,0,0));
00088 trans.setRotation(tf::Quaternion(0,0,0,1));
00089 utfb.sendTransform(tf::StampedTransform(trans,ros::Time(2),"/base_link","/gripper"));
00090 }
00091
00092 {
00093
00094 StampedCovariance stc;
00095 stc.resize(6,6);
00096 stc.setZero();
00097
00098
00099 stc(0,0) = 0.0025;
00100 stc(1,1) = 0.0025;
00101
00102 stc.frame_id_ = "/base_link";
00103 stc.stamp_ = ros::Time(2);
00104 utfb.sendCovariance(stc);
00105 }
00106
00107 ros::Duration(0.1).sleep();
00108
00109 std::cout << " now checking via time travel: " << std::endl;
00110
00111 {
00112 std::vector<StampedTransform> transform_samples;
00113
00114 ulistener.sampleTransform("/gripper", ros::Time(2), "/object", ros::Time(1), "/map", transform_samples, 10);
00115 for (std::vector<StampedTransform>::iterator it = transform_samples.begin(); it != transform_samples.end(); ++it)
00116 {
00117 std::cout << (*it).getOrigin().x() << " " << (*it).getOrigin().y() << " "<< (*it).getOrigin().z() << std::endl;
00118 }
00119 }
00120
00121 return 0;
00122 };
00123