Size: 5995
Comment:
|
Size: 5991
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 24: | Line 24: |
* [[Topics]]: Nodes can ''publish'' Messages to a Topic as well receive messages by '''subscrib'''ing to a Topic. * [[Messages]]: ROS data type used when subscribing or publishing to a Topic. |
* [[Topics]]: Nodes can ''publish'' messages to a topic as well ''subscribe'' to a topic to receive messages. * [[Messages]]: ROS data type used when subscribing or publishing to a topic. |
Line 28: | Line 28: |
* [[roscore]]: Master + rosout + Parameter Server (Parameter server will be introduced later) | * [[roscore]]: Master + rosout + parameter server (parameter server will be introduced later) |
Line 31: | Line 31: |
A node really isn't much more than an executable file within a ROS Package. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Nodes and provide or use a service. | A node really isn't much more than an executable file within a ROS package. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Nodes and provide or use a service. |
Note: This tutorial assumes that you have completed the previous tutorials: Gerando um pacote no ROS. |
![]() |
Um pouco mais sobre nós(''nodes'') no ROS
Description: Este tutorial apresenta os conceitos introdutórios sobre os componentes básicos do ROS (também referenciados como ROS Graph) e discute o uso das ferramentas utilizadas via terminal: roscore, rosnode e rosrun.Tutorial Level: BEGINNER
Next Tutorial: Entendendo tópicos no ROS
Contents
Quick Overview of Graph Concepts
Nodes: A node is an executable that uses a ROS communicate with other nodes.
Topics: Nodes can publish messages to a topic as well subscribe to a topic to receive messages.
Messages: ROS data type used when subscribing or publishing to a topic.
Master: Name service for ROS (i.e. helps nodes find each other)
rosout: ROS equivalent of stdout/stderr
roscore: Master + rosout + parameter server (parameter server will be introduced later)
Nodes
A node really isn't much more than an executable file within a ROS package. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Nodes and provide or use a service.
Client Libraries
ROS client libraries allow nodes written in different programming languages to communicate:
- rospy = python client library
- roscpp = c++ client library
roscore
roscore is the first thing you should run when using ROS.
Please run:
$ roscore
You will see something similar to:
... logging to ~/ros/ros/log/3a5749c2-965f-11de-8875-001b21201aa8/roslaunch-aqy-3581.log ... loading XML file [~/ros/ros/tools/roslaunch/roscore.xml] Added core node of type [rosout/rosout] in namespace [/] started roslaunch server http://aqy:56911/ SUMMARY ======== NODES starting new master (master configured for auto start) process[master]: started with pid [3613] ROS_MASTER_URI=http://aqy:11311/ setting /run_id to 3a5749c2-965f-11de-8875-001b21201aa8 +PARAM [/run_id] by /roslaunch +PARAM [/roslaunch/uris/aqy:56911] by /roslaunch process[rosout-1]: started with pid [3628] started core service [/rosout] +SERVICE [/rosout/get_loggers] /rosout http://aqy:53163/ +SERVICE [/rosout/set_logger_level] /rosout http://aqy:53163/ +SUB [/time] /rosout http://aqy:53163/ +PUB [/rosout_agg] /rosout http://aqy:53163/ +SUB [/rosout] /rosout http://aqy:53163/
Open up a new terminal, let's use rosnode to see what running roscore did...
Using rosnode
rosnode displays information about the ROS nodes that are currently running. The rosnode list command lists these active nodes:
$ rosnode list
- You will see:
/rosout
This showed us that there is only one node running: rosout. This is always running as it collects and logs nodes' debugging output.
The rosnode info command returns information about a specific node.
$ rosnode info /rosout
This gave us some more information about rosout, such as the fact that it publishes /rosout_agg.
-------------------------------------------------------------------------------- Node [/rosout] Publications: * /rosout_agg [roslib/Log] Subscriptions: * /time [unknown type] * /rosout [unknown type] Services: * /rosout/set_logger_level * /rosout/get_loggers contacting node http://foo.local:54614/ ... Pid: 5092
Now, let's see some more nodes. For this, we're going to use rosrun to bring up another node.
Using rosrun
rosrun allows you to use the package name to directly run a node within a package (without having to know the package path).
Usage:
$ rosrun [package_name] [node_name]
So now we can run the turtlesim_node in the turtlesim package, in a new terminal:
$ rosrun turtlesim turtlesim_node
You will see the turtlesim window:
NOTE: The turtle may look different in your turtlesim window. Don't worry about it.
In a new terminal:
$ rosnode list
You will see something similar to:
/rosout /turtlesim
One powerful feature of ROS is that you can reassign Names from the command-line.
Go back to the rosrun turtlesim window and use ctrl-C to stop the node. Now let's re-run it, but this time use a Remapping Argument to change the node's name:
rosrun turtlesim turtlesim_node __name:=my_turtle
Now, if we go back and use rosnode list:
$ rosnode list
- You will see something similar to:
/rosout /my_turtle
We see our new /my_turtle node. Let's use another rosnode command, ping, to test that it's up:
$ rosnode ping my_turtle
rosnode: node is [/my_turtle] pinging /my_turtle with a timeout of 3.0s xmlrpc reply from http://aqy:42235/ time=1.152992ms xmlrpc reply from http://aqy:42235/ time=1.120090ms xmlrpc reply from http://aqy:42235/ time=1.700878ms xmlrpc reply from http://aqy:42235/ time=1.127958ms
Review
What was covered:
- rosnode = ros+node : ROS tool to get information about a node.
- rosrun = ros+run : runs a node from a given package.
Now that you understand how ROS nodes work, let's look at how ROS topics work. Also, feel free to press Ctrl-C to stop turtlesim_node.