• Diff for "pt_BR/ROS/Tutorials/UnderstandingNodes"
Differences between revisions 74 and 75
Revision 74 as of 2011-09-01 16:56:37
Size: 6149
Comment:
Revision 75 as of 2012-06-03 15:47:21
Size: 6156
Editor: AlexBravo
Comment: Fixed a typo and added machine_name
Deletions are marked like this. Additions are marked like this.
Line 24: Line 24:
 * [[Topics]]: Nodes can ''publish'' messages to a topic as well ''subscribe'' to a topic to receive messages.
Line 26: Line 25:
 * [[Topics]]: Nodes can ''publish'' messages to a topic as well as ''subscribe'' to a topic to receive messages.
Line 67: Line 67:
ROS_MASTER_URI=http://bvo:11311/ ROS_MASTER_URI=http://machine_name:11311/
Line 100: Line 100:
-------------------------------------------------------------------------------- ------------------------------------------------------------------------
Line 112: Line 112:
contacting node http://foo.local:54614/ ... contacting node http://machine_name:54614/ ...

Note: This tutorial assumes that you have completed the previous tutorials: Gerando um pacote no ROS.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

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

Quick Overview of Graph Concepts

  • Nodes: A node is an executable that uses ROS to communicate with other nodes.

  • Messages: ROS data type used when subscribing or publishing to a topic.

  • Topics: Nodes can publish messages to a topic as well as subscribe to a topic to receive messages.

  • 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 can also 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/log/9cf88ce4-b14d-11df-8a75-00251148e8cf/roslaunch-bvo-13039.log
    Checking log directory for disk usage. This may take awhile.
    Press Ctrl-C to interrupt
    Done checking log file disk usage. Usage is <1GB.
    
    started roslaunch server http://bvo:33919/
    ros_comm version 1.4.7
    
    SUMMARY
    ========
    
    PARAMETERS
     * /rosversion
     * /rosdistro
    
    NODES
    
    auto-starting new master
    process[master]: started with pid [13054]
    ROS_MASTER_URI=http://machine_name:11311/
    
    setting /run_id to 9cf88ce4-b14d-11df-8a75-00251148e8cf
    process[rosout-1]: started with pid [13067]
    started core service [/rosout]

If roscore does not initialize, you probably have a network configuration issue. See Network Setup - Single Machine Configuration

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 [rosgraph_msgs/Log]
    
    Subscriptions:
     * /rosout [unknown type]
    
    Services:
     * /rosout/set_logger_level
     * /rosout/get_loggers
    
    contacting node http://machine_name: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. First, we need to compile the turtlesim package:

$ rosmake turtlesim

Then, in a new terminal:

$ rosrun turtlesim turtlesim_node

You will see the turtlesim window:

  • turtlesim.png

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:

  • roscore = ros+core : master (provides name service for ROS) + rosout (stdout/stderr) + parameter server (parameter server will be introduced later)
  • 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.

Wiki: pt_BR/ROS/Tutorials/UnderstandingNodes (last edited 2020-04-22 02:22:08 by PedroAlcantara)