[ROS In 5 Minutes] 003 - How to create a ROS Publisher
The Construct Robotics Institute 5:05
10,438 views · 101 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 create a ROS Publisher.
But before we start, if you want to Learn ROS Fast, we recommend you the following courses:
ROS In 5 Days (Python) - http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-basics-in-5-days/
ROS In 5 Days (C++) - http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-courses-ros-basics-in-5-days-c/
We have a POST that contains the content of this video: on http://www.theconstructsim.com/ros-5-minutes-003-create-ros-publisher/, but if you want a summary, we have it here too.
Regarding to the creation of the ROS Publisher, the commands used on the video to create a package named "tutorial" which depends on the "rospy" package were the following:
cd catkin_ws/src/
catkin_create_pkg tutorial rospy
roscd tutorial
And the code used to create the publisher called "tutorial" that publishes on a topic called "/say_hello" was the following:
#! /usr/bin/env python
import rospy
from std_msgs.msg import String
rospy.init_node('tutorial')
publisher = rospy.Publisher('/say_hello', String, queue_size=1)
rate = rospy.Rate(3) # 3hz
while not rospy.is_shutdown():
publisher.publish('Hey! Welcome to Robot Ignite Academy.')
rate.sleep()
So easy, isn't it?
Remember that the python file must be a executable. You cam make it executable with the following command (supposing the name of your file is publisher.py):
chmod +x publisher.py
After running your publisher with "rosrun tutorial publisher.py", you can see what is being published with:
rostopic echo /say_hello
That is it for today, guys. I hope you enjoy the video.
Whether you like the video or not, please leave a comment on the comments section below, so we can interact and learn from each other.
Welcome to this "ROS In 5 Minutes" videos series.
In today's videos we are going to see how to create a ROS Publisher.
But before we start, if you want to Learn ROS Fast, we recommend you the following courses:
ROS In 5 Days (Python) - http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-basics-in-5-days/
ROS In 5 Days (C++) - http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-courses-ros-basics-in-5-days-c/
We have a POST that contains the content of this video: on http://www.theconstructsim.com/ros-5-minutes-003-create-ros-publisher/, but if you want a summary, we have it here too.
Regarding to the creation of the ROS Publisher, the commands used on the video to create a package named "tutorial" which depends on the "rospy" package were the following:
cd catkin_ws/src/
catkin_create_pkg tutorial rospy
roscd tutorial
And the code used to create the publisher called "tutorial" that publishes on a topic called "/say_hello" was the following:
#! /usr/bin/env python
import rospy
from std_msgs.msg import String
rospy.init_node('tutorial')
publisher = rospy.Publisher('/say_hello', String, queue_size=1)
rate = rospy.Rate(3) # 3hz
while not rospy.is_shutdown():
publisher.publish('Hey! Welcome to Robot Ignite Academy.')
rate.sleep()
So easy, isn't it?
Remember that the python file must be a executable. You cam make it executable with the following command (supposing the name of your file is publisher.py):
chmod +x publisher.py
After running your publisher with "rosrun tutorial publisher.py", you can see what is being published with:
rostopic echo /say_hello
That is it for today, guys. I hope you enjoy the video.
Whether you like the video or not, please leave a comment on the comments section below, so we can interact and learn from each other.
Category (YouTube): Science & Technology
Playback is via YouTube's official embedded player. Data from YouTube; Exumo is not affiliated with YouTube.