-
Notifications
You must be signed in to change notification settings - Fork 1
/
calibration_node.cpp
50 lines (41 loc) · 1.08 KB
/
calibration_node.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <ros/ros.h>
#include <tf/transform_datatypes.h>
#include <tf/transform_listener.h>
#include <iostream>
using namespace ros;
int main(int argc, char **argv)
{
init(argc, argv, "Sweep");
NodeHandle n;
tf::TransformListener tfListener;
tf::StampedTransform tf1, tf2;
Rate r(10);
while(ok())
{
Time now = Time::now();
if(!tfListener.waitForTransform("laser_link", "camera", now, Duration(3.0)))
continue;
if(!tfListener.waitForTransform("camera_init_2", "laser_link", now, Duration(3.0)))
continue;
try
{
tfListener.lookupTransform("laser_link", "camera", now, tf1);
tfListener.lookupTransform("camera_init_2", "laser_link", now, tf2);
tf::Transform tf3 = tf1 * tf2;
ROS_INFO("TF: %.2f, %.2f, %.2f / %.2f, %.2f, %.2f, %.2f",
tf3.getOrigin()[0],
tf3.getOrigin()[1],
tf3.getOrigin()[2],
tf3.getRotation().getAxis()[0],
tf3.getRotation().getAxis()[1],
tf3.getRotation().getAxis()[2],
tf3.getRotation().getW());
}catch(tf::TransformException e)
{
ROS_ERROR("%s", e.what());
}
spinOnce();
r.sleep();
}
return 0;
}