Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / examples / TimeTF / TimeTF.pde @ c1426757

History | View | Annotate | Download (710 Bytes)

1
/* 
2
 * rosserial Time and TF Example
3
 * Publishes a transform at current time
4
 */
5

    
6
#include <ros.h>
7
#include <ros/time.h>
8
#include <tf/transform_broadcaster.h>
9

    
10
ros::NodeHandle  nh;
11

    
12
geometry_msgs::TransformStamped t;
13
tf::TransformBroadcaster broadcaster;
14

    
15
char base_link[] = "/base_link";
16
char odom[] = "/odom";
17

    
18
void setup()
19
{
20
  nh.initNode();
21
  broadcaster.init(nh);
22
}
23

    
24
void loop()
25
{  
26
  t.header.frame_id = odom;
27
  t.child_frame_id = base_link;
28
  t.transform.translation.x = 1.0; 
29
  t.transform.rotation.x = 0.0;
30
  t.transform.rotation.y = 0.0; 
31
  t.transform.rotation.z = 0.0; 
32
  t.transform.rotation.w = 1.0;  
33
  t.header.stamp = nh.now();
34
  broadcaster.sendTransform(t);
35
  nh.spinOnce();
36
  delay(10);
37
}