[ROS in 5 mins] 027 – What is ROS Service

[ROS in 5 mins] 027 – What is ROS Service

Hello ROS Developers!

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.

rosservice call /gazebo/delete_model "model_name: 'cafe_table'"

Want to learn more?

If you are new to ROS, I highly recommend you to take any of the following courses on Robot Ignite Academy:

ROS Basics In 5 Days (Python) 
ROS Basics In 5 Days (C++) 

We love feedback, so, whether you like the video or not, please share your thoughts in the comments section below.

 

Edit by: Tony Huang

[ROS in 5 mins] 024 – How to compile a ROS  Message

[ROS in 5 mins] 024 – How to compile a ROS Message

 

Hello ROS Developers!

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.

...
  <build_depend>message_generation</build_depend>
...
  <run_depend>message_runtime</run_depend>
...

In the CMakeLists.txt, change the following part to compile the message.

...
find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  message_generation
)
...
add_message_files(
   FILES
   SharePrice.msg
#   Message2.msg
)
...
generate_messages(
   DEPENDENCIES
   std_msgs  # Or other packages containing msgs
)
...
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES my_sense_package
  CATKIN_DEPENDS rospy message_runtime
#  DEPENDS system_lib
)
...

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.

 

Edit by: Tony Huang

[ROS in 5 mins] 023 – Understanding ROS Coordinate Frame (Part 1)

[ROS in 5 mins] 023 – Understanding ROS Coordinate Frame (Part 1)

 

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.

RELATED LINKS

REP 103
ROS Development Studio (ROSDS)
Robot Ignite Academy

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.

Want to learn more?

If you want to learn more about ROS, please check our Robot Ignite Academy.

 

Edit by: Tony Huang


Feedback

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.

[ROS in 5 mins] 022 – What is a ROS publisher?

[ROS in 5 mins] 022 – What is a ROS publisher?

In this post, we will see what a ROS publisher is all about in just about five minutes! We’ll also see how it relates to ROS nodes and topics.

Let’s go!

Step 1: Grab a copy of the Project (ROSject) on ROSDS

Get it here: http://www.rosject.io/l/18f83296-0e7e-4c5c-95a7-2d3e3d6430d4/.

Once you have copied the project, open it up.

Step 2: Run the obiwan_pub.py program

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:

user:~$ rostopic info /help_msg
Type: std_msgs/String

Publishers:
 * /sos_2 (http://rosdscomputer:38619/)

Subscribers: None

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:

Feedback

Did you like this post? Whatever the case, please leave a comment in 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 in the comments area and we will do a post or video about it.

Thank you!

[ROS in 5 mins] 021 – What is a ROS Subscriber

[ROS in 5 mins] 021 – What is a ROS Subscriber

 

Hello ROS Developers!

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.

For example, if you use the following command

rostopic echo /camera/rgb/image_raw __name:=subscriber1 > /dev/null

You can add a new subscriber called subscriber1 to the /camera/rgb/image_raw topic and you can add more subscribers if you want.

 

Edit by: Tony Huang

Pin It on Pinterest