← Back to search

[ROS in 5 mins] 057 - How to publish the position of a robot using TransformBroadcaster in python

The Construct Robotics Institute 6:51

6,814 views · 87 likes Watch on YouTube ↗

Hi all,

welcome to this "ROS In 5 Minutes" videos series.

In today's videos we are going to see how to publish the position of a robot with Python by using the TransformBroadcaster.

For that we are going to use Robot Ignite Academy, which is the best platform if you want to Learn ROS really fast.

But before we start, if you are new to ROS, we recommend you taking one of the the folloinwg courses:

ROS In 5 Days (Python) - http://bit.ly/2SnLTEw
ROS In 5 Days (C++) - http://bit.ly/2SfeHix

To make your life easier, here we have the code used on the video:

#! /usr/bin/env python

from tf import TransformBroadcaster
import rospy
from rospy import Time

def main():
rospy.init_node('my_broadcaster')

b = TransformBroadcaster()

translation = (0.0, 0.0, 0.0)
rotation = (0.0, 0.0, 0.0, 1.0)
rate = rospy.Rate(5) # 5hz

x, y = 0.0, 0.0

while not rospy.is_shutdown():
if x GREATER_THAN 2:
x, y = 0.0, 0.0

x += 0.1
y += 0.1

translation = (x, y, 0.0)

b.sendTransform(translation, rotation, Time.now(), 'ignite_robot', '/world')
rate.sleep()

if __name__ == '__main__':
main()


Bear in mind that GREATER_THAN you have to substitute for the symbols, given that YouTube don't allow those symbols here.

At the end, whether you like the video or not, please leave a comment on the comments section below giving your opinion.

Thanks for watching.

Category (YouTube): Science & Technology

Playback is via YouTube's official embedded player. Data from YouTube; Exumo is not affiliated with YouTube.