In today’s video, we are going to learn what are ROS Services, how to list them and how to call a ROS Service.
Step1. Create a project in Robot Ignite Academy(RIA)
We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the ROS Basics in 5 Days course unit 5 as an example today.
Step2. ROS service
Compare to the topic, the ROS service is a more syncronize why to communicate between nodes. You’ll also get feedback after a service is done. You can see all the service available with
rosservice list
and check any of them with
rosservice info /SERVICE
To call a service, use
rosservice call /SERVICE "SERVICE MSG"
For example, to call the /gazebo/delete_model service, we have to pass the model name you want to delete like the following.
In today’s video we are going to learn how to compile a ROS Message.
For that we are going to use Robot Ignite Academy, which is the best tool if you want Learn ROS Fast.
Before we start, if you are new to ROS and want to Learn ROS Fast, I highly recommend you to take any of the following courses on Robot Ignite Academy:
We love feedback, so, whether you like the video or not, please share your thoughts on the comments section below.
Step1. Create a project in Robot Ignite Academy(RIA)
We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the ROS Basic in 5 days course unit 4 as an example today.
Step2. Create a package
We’ll create a package for our code with the following command.
cd ~/catkin_ws/src
catkin_create_pkg financial_market rospy
We also need one folder for our message definition
cd financial_market
mkdir msg
Let’s call our message SharePrice.msg with the following definition
string name
float32 price
In the package.xml file, please uncomment the following part.
Then we compile the message with the following command
cd ~/catkin_ws
catkin_make
Please source the file after compile.
source devel/setup.bash
You can then check the message with
rosmsg info financial_market/SharePrice
In your python code, you can then add from financial_market.msg import SharePrice to use the message.
Want to learn more?
If you are interested in this topic, please check our ROS Basics In 5 Days (Python) course. You’ll learn how to create service and action message in ROS as well.
How does your robot know which way is forward? Is it in the x-axis, or y-axis? Positive or negative?
In this video we are going to look at the convention for coordinate frames. This convention is specified in REP 103 – Standard Units of Measure and Coordinate Conventions. In this part 1, we will look at the coordinate frame for linear motion.
Step 1. Create a project in ROS Development Studio(ROSDS)
According to the REP03 standard, the positive x means forward, the positive y means left and positive z means up. Although you can check the REP03 standard with your hand, it’s better to see how it works in ROS. The ROSDS helps you follow our tutorial in a fast pace without dealing without setting up an environment locally. If you haven’t had an account yet, you can create a free account here. Let’s launch a AR Drone simulation from Simulations->AR.Drone.
Step 2. Check it with the command
You can publish to the cmd_vel topic to move the drone with the following command.
rostopic pub -1 /cmd_vel [TAB] [TAB]
When you press tab while typing the command, ROS will do auto-compilation for you. You can see that it directly find the message type is called geometry msgs/Twist and there are linear x y z and angular x y x value in this message. To check it, change the value of linear x to some positive value. The drone will move forward like the REP03 standard said. You can also send to the linear y and z to check if it’s true. In the next post. We will talk about the angular part.
Did you like this video? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.
If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.
Pick a Shell from the Tools menu and run the following commands.
First, start the ROS master – we need this to run any ROS commands. We’re starting this program in the background:
user:~$ nohup roscore &
[1] 1501
user:~$ nohup: ignoring input and appending output to 'nohup.out'
user:~$
Before we proceed, let’s check the ROS topics currently available:
user:~$ rostopic list
/rosout
/rosout_agg
Now start the obiwan_pub.py program:
user:~$ cd catkin_ws/src
user:~/catkin_ws/src$ ./obiwan_pub.py
Again, check the list of available ROS topics. Pick another Shell from the Tools menu and run:
user:~$ rostopic list
/help_msg
/rosout
/rosout_agg
Now we have a new topic /help_msg, obviously created by the obiwan_pub.py program. Running it is the only thing we have done since the last time we checked the list of messages, right?
Okay, do not take my word for it; let’s spy on the /help_msg topic to confirm:
Now we know that that topic uses a message of type std_msgs/String and has a Publisher named /sos_2.
But what has this got to with the obiwan_pub node? Everything – let’s see that in the next step.
Step 3: Unravel the mysterious “Publisher” /sos_2
In the previous step, we saw that /sos_2 was listed as a Publisher on the topic /help_msg, and we suspected that this has to do with the obiwan_pub.py program. Now, let’s examine the obiwan_pub.py code to see if we have some clues.
obiwan_pub.py
#! /usr/bin/env python
import rospy
from std_msgs.msg import String
rospy.init_node("sos_2")
rate = rospy.Rate(2)
help_msg = String()
help_msg.data = "help me Obi-Wan Kenobi, you're my only hope"
pub = rospy.Publisher('/help_msg', String, queue_size = 1)
while not rospy.is_shutdown():
pub.publish(help_msg)
rate.sleep()
On line 6, we have the statement rospy.init_node("sos_2"), so we now know that:
/sos_2 was created by this program!
/sos_2 is a ROS node, because it says rospy.init_node...
Also on line 10, we have this statement: pub=rospy.Publisher('/help_msg',String,queue_size=1), confirming that:
The code actually creates a Publisher on the /help_msg topic. Bingo!
Step 4: Master the Concept – What is a ROS Publisher?
Combining all the points in the previous steps, we can see that a ROS Publisher…
is a ROS node (program).
creates a particular type of ROS message. In this case, it’s std_msgs/String, as can be seen on lines 4,7-8 of the code.
sends (publishes) a message over a channel called “topic”, as can be seen on lines 10 then 12 of the code.
In short, a ROS publisher is a ROS node that publishes a specific type of ROS message over a given ROS topic. “Interested” nodes (Subscribers) can access messages so published.
And that was it!
Extra: Video
Prefer to watch a video demonstrating the steps above? We have one for you below!
Related Resources
A previous video about ROS nodes: [irp posts=”10305″ name=”ROS in 5 mins – 005 – What is a ROS Node?”]
If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:
In today’s video we are going to see what is ROS Subscriber and how to see a list of them in a ROS Topic.
Before we start, if you are new to ROS and want to Learn ROS Fast, I highly recommend you to take any of the following courses on Robot Ignite Academy:
We love feedback, so, whether you like the video or not, please leave a comment on the comments section below so that we can interact and learn from each other.
Step1. Create a project in Robot Ignite Academy(RIA)
We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the ROS Basics in 5 Days course unit 0 as an example today.
Step2. What is ROS Subscriber?
Let’s start by visualizing the relationship between nodes with
rqt_graph
You can see that the nodes are communicating using the topics. A node can be a publisher publishing some topic or a subscriber to some topic. A topic can even have as many subscribers as you want.