-
Notifications
You must be signed in to change notification settings - Fork 1
/
transform_odom_to_map.cpp
74 lines (50 loc) · 1.78 KB
/
transform_odom_to_map.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
int main(int argc, char** argv){
ros::init(argc, argv, "robot_tf_publisher");
ros::NodeHandle n;
ros::Rate r(100);
tf::TransformBroadcaster broadcaster;
while(n.ok()){
broadcaster.sendTransform(
tf::StampedTransform(
tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.1, 0.0, 0.2)),
ros::Time::now(),"base_link", "cloud_frame"));
r.sleep();
}
}
*/
#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Vector3.h"
#include "geometry_msgs/Quaternion.h"
geometry_msgs::Pose posicao;
geometry_msgs::Quaternion orientacao;
void MsgCallback(const nav_msgs::Odometry::ConstPtr& msg)
{
posicao = msg->pose.pose;
orientacao = posicao.orientation;
ROS_INFO("foi");
}
int main(int argc, char** argv){
ros::init(argc, argv, "my_tf_broadcaster");
ros::NodeHandle node;
ros::Subscriber subscriber = node.subscribe("RosAria/pose", 1000, MsgCallback);
ros::Rate rate(10.0);
while (node.ok()){
tf::TransformBroadcaster br2;
tf::Transform transform2;
transform2.setOrigin( tf::Vector3(0.1, 0.0, 0.2) );
transform2.setRotation( tf::Quaternion(-1, 0, 0, 1) );
br2.sendTransform(tf::StampedTransform(transform2, ros::Time::now(), "base_link", "cloud_frame"));
tf::TransformBroadcaster br;
tf::Transform transform;
transform.setOrigin(tf::Vector3(posicao.position.x , posicao.position.y , posicao.position.z));
transform.setRotation(tf::Quaternion(orientacao.x,orientacao.y,orientacao.z,orientacao.w));
br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "odom", "map"));
rate.sleep();
}
ros::spin();
return 0;
};