Skip to Content
Robot Operating System Cookbook
book

Robot Operating System Cookbook

by Kumar Bipin
June 2018
Intermediate to advanced
484 pages
11h 36m
English
Packt Publishing
Content preview from Robot Operating System Cookbook

Writing a TF broadcaster

First, we will create a ros package in our workspace or copy the chapter3_tutorials/tf_tutorials file from GitHub:

$ catkin_create_pkg tf_tutorials tf roscpp rospy turtlesim 

Next, we will create the tf_tutorials/src/turtle_tf_broadcaster.cpp file and add the source code:

#include <ros/ros.h> #include <tf/transform_broadcaster.h> #include <turtlesim/Pose.h> std::string turtle_name; void poseCallback(const turtlesim::PoseConstPtr& msg){ static tf::TransformBroadcaster br; tf::Transform transform; transform.setOrigin( tf::Vector3(msg->x, msg->y, 0.0) ); tf::Quaternion q; q.setRPY(0, 0, msg->theta); transform.setRotation(q); br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "world", turtle_name)); } ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mobile Intelligent Autonomous Systems

Mobile Intelligent Autonomous Systems

Jitendra R. Raol, Ajith K. Gopal
Wheeled Mobile Robotics

Wheeled Mobile Robotics

Gregor Klancar, Andrej Zdesar, Saso Blazic, Igor Skrjanc

Publisher Resources

ISBN: 9781783987443Supplemental Content