-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_node.cpp
47 lines (30 loc) · 1002 Bytes
/
error_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
#include <ros/ros.h>
#include <tf/tf.h>
#include <gazebo_msgs/LinkStates.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include <sensor_msgs/NavSatFix.h>
#include <iostream>
geometry_msgs::Point gaz_xyz;
geometry_msgs::Point ekf_xyz;
void gaz_callback( const gazebo_msgs::LinkStates& sl ){
gaz_xyz = sl.pose[1].position;
}
void ekf_callback( const geometry_msgs::PoseWithCovarianceStamped& p ){
ekf_xyz = p.pose.pose.position;
}
int main( int argc, char** argv ){
ros::init( argc, argv, "error_node" );
ros::NodeHandle nh;
ros::Subscriber sub_gaz, sub_ekf;
sub_gaz = nh.subscribe( "/gazebo/link_states", 1, &gaz_callback );
sub_ekf = nh.subscribe( "/ekf/posterior", 1, &ekf_callback );
ros::Rate rate( 10 );
while( nh.ok() ){
std::cout << std::setw(15) << gaz_xyz.x - ekf_xyz.x
<< std::setw(15) << gaz_xyz.y - ekf_xyz.y
<< std::setw(15) << gaz_xyz.z - ekf_xyz.z << std::endl;
ros::spinOnce();
rate.sleep();
}
return 0;
}