## For instruction on writing tutorials ## http://www.ros.org/wiki/WritingTutorials ####R############################### ##FILL ME IN #################################### ## for a custom note with links: ## note = This tutorial assumes you completed the [[urdf/Tutorials/Create your own urdf file|create your own urdf file]] tutorial. ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0= ## descriptive title for the tutorial ## title = Using the robot state publisher on your own robot ## multi-line description to be displayed in search ## description = This tutorial explains how you can publish the state of your robot to [[tf]], using the robot state publisher. ## the next tutorial description (optional) ## next = For a detailed tutorial on how to use the robot_state_publisher in combination with a urdf, take a look at ## links to next tutorial (optional) ## next.0.link=[[urdf/Tutorials/Using urdf with robot_state_publisher|this tutorial]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = #################################### <> {{{#!wiki caution tf is deprecated in favor of [[tf2]]. [[tf2]] provides a superset of the functionality of tf and is actually now the implementation under the hood. If you're just learning now it's strongly recommended to use the [[tf2/Tutorials]] instead. }}} <> When you are working with a robot that has many relevant frames, it becomes quite a task to publish them all to tf. The robot state publisher is a tool that will do this job for you. {{attachment:frames2.png||height="408px",width="471px"}} The robot state publisher helps you to broadcast the state of your robot to the [[tf|tf transform library]]. The robot state publisher internally has a kinematic model of the robot; so given the joint positions of the robot, the robot state publisher can compute and broadcast the 3D pose of each link in the robot. You can use the robot state publisher as a standalone ROS node or as a library: == Running as a ROS node == === robot_state_publisher === The easiest way to run the robot state publisher is as a node. For normal users, this is the recommended usage. You need two things to run the robot state publisher: * A [[urdf]] xml robot description loaded on the [[Parameter Server]]. * A source that publishes the joint positions as a <>. Please read the following sections on how to configure the parameters and topics for [[robot_state_publisher]]. <> === Example launch file === Once you have setup the XML robot description and a source for joint position information, simply create a launch file like this one: {{{ }}} == Running as a library == Advanced users can also run the robot state publisher as a library, from within their own C++ code. After you include the header: {{{ #include }}} all you need is the constructor which takes in a [[kdl|KDL tree]] {{{ RobotStatePublisher(const KDL::Tree& tree); }}} and now, every time you want to publish the state of your robot, you call the publishTransforms functions: {{{ // publish moving joints void publishTransforms(const std::map& joint_positions, const ros::Time& time); // publish fixed joints void publishFixedTransforms(); }}} The first argument is a map with joint names and joint positions, and the second argument is the time at which the joint positions were recorded. It is okay if the map does not contain all the joint names. It is also okay if the map contains some joints names that are not part of the kinematic model. But note if you don't tell the joint state publisher about some of the joints in your kinematic model, then your tf tree will not be complete. ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE