GazeboToTf.cpp
Go to the documentation of this file.
1 /*
2  * GazeboToTf.cpp
3  *
4  * Created on: Oct 25, 2020
5  * Author: marco
6  */
7 
9 
10 namespace rsm {
11 
13  ros::NodeHandle privateNh("~");
14  privateNh.param < std::string
15  > ("odom_topic", _odom_topic, "/ground_truth/state");
16  privateNh.param < std::string > ("map_frame", _map_frame, "map");
17  privateNh.param < std::string
18  > ("robot_frame", _robot_frame, "robot_footprint");
19 
21  this);
22 }
23 
25  // TODO Auto-generated destructor stub
26 }
27 
28 void GazeboToTf::odomCallback(const nav_msgs::Odometry::ConstPtr &msg) {
29  geometry_msgs::TransformStamped transformStamped;
30 
31  transformStamped.header.stamp = ros::Time::now();
32  transformStamped.header.frame_id = _map_frame;
33  transformStamped.child_frame_id = _robot_frame;
34  transformStamped.transform.translation.x = msg->pose.pose.position.x;
35  transformStamped.transform.translation.y = msg->pose.pose.position.y;
36  transformStamped.transform.translation.z = 0;
37  transformStamped.transform.rotation.x = msg->pose.pose.orientation.x;
38  transformStamped.transform.rotation.y = msg->pose.pose.orientation.y;
39  transformStamped.transform.rotation.z = msg->pose.pose.orientation.z;
40  transformStamped.transform.rotation.w = msg->pose.pose.orientation.w;
41 
42  _tf_broadcaster.sendTransform(transformStamped);
43 }
44 
45 }
46 
void odomCallback(const nav_msgs::Odometry::ConstPtr &msg)
Definition: GazeboToTf.cpp:28
std::string _odom_topic
Definition: GazeboToTf.h:24
ros::Subscriber _odom_subscriber
Definition: GazeboToTf.h:26
tf2_ros::TransformBroadcaster _tf_broadcaster
Definition: GazeboToTf.h:27
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual ~GazeboToTf()
Definition: GazeboToTf.cpp:24
ros::NodeHandle _nh
Definition: GazeboToTf.h:25
bool param(const std::string &param_name, T &param_val, const T &default_val) const
std::string _map_frame
Definition: GazeboToTf.h:24
void sendTransform(const geometry_msgs::TransformStamped &transform)
static Time now()
std::string _robot_frame
Definition: GazeboToTf.h:24


rsm_additions
Author(s): Marco Steinbrink
autogenerated on Mon Feb 28 2022 23:28:21