Go to the documentation of this file.00001
00002
00003
00004
00005 #include <ros.h>
00006 #include <ros/time.h>
00007 #include <tf/tf.h>
00008 #include <tf/transform_broadcaster.h>
00009
00010 ros::NodeHandle nh;
00011
00012 geometry_msgs::TransformStamped t;
00013 tf::TransformBroadcaster broadcaster;
00014
00015 double x = 1.0;
00016 double y = 0.0;
00017 double theta = 1.57;
00018
00019 char base_link[] = "/base_link";
00020 char odom[] = "/odom";
00021
00022 int main(void) {
00023 nh.initNode();
00024 broadcaster.init(nh);
00025
00026
00027 while (1) {
00028
00029 double dx = 0.2;
00030 double dtheta = 0.18;
00031 x += cos(theta)*dx*0.1;
00032 y += sin(theta)*dx*0.1;
00033 theta += dtheta*0.1;
00034 if (theta > 3.14)
00035 theta=-3.14;
00036
00037
00038 t.header.frame_id = odom;
00039 t.child_frame_id = base_link;
00040
00041 t.transform.translation.x = x;
00042 t.transform.translation.y = y;
00043
00044 t.transform.rotation = tf::createQuaternionFromYaw(theta);
00045 t.header.stamp = nh.now();
00046
00047 broadcaster.sendTransform(t);
00048 nh.spinOnce();
00049
00050 wait_ms(10);
00051 }
00052 }
00053