
are going to see how to create our ROS Publisher for that you're going to use
this platform so let's launch here a course ROS Basics in Five Days to
have the ROS environment running after launch the course we just have to
wait some minutes in yeah everything will be right to use let's wait until
the web show loads and okay in order to create a publisher
we need a package so let's create here a package in the previous video we
have shown how to create a ROS package so if you need more details
just take a look on the other video so let's create here a package called
tutorial and tutorial and depends on rospy here already on the source
folder let's create a file new file let's call publisher it's a Python file
let's open it and since is a Python file and let me change in here to change the
font size and so you can see it better okay in this case is a python file so usr/
bin/env python to create a publisher we first need rospy in this
case import rospy and we are going to publish a String messages so from
std_msgs.msg import String and since it's a Python package we first
have to initialize our node rospy.init_node since it's a ROSNOde and call it
tutorial and we need a publisher equals rospy.Publisher we have to say the
the name of the topic in this case let's say the topic is going to be say_hello and the
type of the message published it is going to be a String and let's put
this queue_size = 1 so we have to publish in a certain frequency so we
have to define a variable called rate and let's say we are going to
publish three messages per second is for example so while rospy is running
while ROS is running so while not rospy.is_shutdown we publish
our message publisher publish let's publish Hey! and let's wait and for example
this sleep controls the frequency in which our message is published in this case
going to publish three messages per second so easy. Now let's to run this
code and see how it goes if you for example we just rosnode list we will
see here we have a four nodes we don't have a node still we still don't have a
node called tutorial when we run our node we will see this node and
rostopic list we don't have any topic called say_hello if you see
rostopic list here we have a big list but not
the topic /say_hello okay so let's just run our code so rosrun the
tutorial package the name of our file is publisher so publisher and okay let's
run and let me see tutorials/src folder okay our file is not executable
executable yes so let's make it executable and now let's run our
node and yeah It should be running already if we see here now the list of
node now have here six and we have here the node if we check the topics
we now can see the say_ hello probably yeah it's in here now to see
this the message being published by this node
we just rostopic echo and the name of the topic here you
have it the "Hey!" message is being published. So easy, no? We just need to specify a
publisher the frequency in which the message is going to be published and
publish the message I hope you guys enjoyed the video if you liked it don't
forget to subscribe our channel give us a thumbs up and press the bell for a new
video every single day thanks for watching
[ROS Projects] - My Robotic Manipulator - Basic URDF and RViz [ROS Q&A] Mesure distance traveled with Odometry with BB8 How to have a Turtlebot 3 simulation in Gazebo with ROS running in 5 mins [ROS Tutorials] ROS Perception #Unit3: Object Recognition and flat surfaces How to Convert Python to Exe and Create An Installer [ROS Q&A] How to have any Gazebo Simulation running in 5 minutes [ROS Q&A] How to Start Programming Drones using ROS [ROS Q&A] 053 - How to Move a Robot to a Certain Point Using Twist [ROS Q&A] How to convert a laser scan into a pointcloud How to build a Mobile Robot for Gazebo