ROS学习手记 - 3 理解ROS中的基本概念_ROS_Nodes

在上次我们完成了一趟简单的package的Create,Build之后,我们要玩正儿八经的ROS,在此之前,我们有很多概念需要理解。按照如下列表进展。

  1. Understanding ROS Nodes

    This tutorial introduces ROS graph concepts and discusses the use ofroscore,rosnode, androsrun commandline tools.

  2. Understanding ROS Topics

    This tutorial introduces ROS topics as well as using therostopic andrqt_plot commandline tools.

  3. Understanding ROS Services and Parameters

    This tutorial introduces ROS services, and parameters as well as using therosservice androsparam commandline tools.


Understanding ROS Nodes

roscore,rosnode, androsrun commandline tools

       This tutorial introduces ROS graph concepts and discusses the use of roscore, rosnode, androsrun commandline tools.

       Prerequisites

          For this tutorial we will use a lightweight simulator, please install it using

        $ sudo apt-get install ros-<distro>-ros-tutorials
          Replace '<distro>' with the name of your ROS distribution (e.g. hydro, groovy, electric, fuerte etc.)

       Using roscore

      roscore is the first thing you should run when using ROS.

           Please run:

        $ roscore

       Using rosnode
           Open up a new terminal, and let's use rosnode to see what runningroscore did

         exbot@ubuntu:~$ rosnode list
         /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.

exbot@ubuntu:~$ rosnode info /rosout
--------------------------------------------------------------------------------
Node [/rosout]
Publications: 
 * /rosout_agg [rosgraph_msgs/Log]

Subscriptions: 
 * /rosout [unknown type]

Services: 
 * /rosout/set_logger_level
 * /rosout/get_loggers


contacting node http://ubuntu:40455/ ...
Pid: 3903

          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.

          Then, in a new terminal:

           $ rosrun turtlesim turtlesim_node
          In a new terminal:

           $ rosnode list

          You will see something similar to:

           /rosout
           /turtlesim

         Close the turtlesim window to stop the node (or go back to therosrun turtlesim terminal and usectrl-C). 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 anotherrosnode 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.


总结一下:

0, 准备工作:装了个 ros-hydro-ros-tutotials

1, 运行 roscore 作为运行ROS基础,
     它是一个后台的服务,提供rosout node, 类似stdout, stderr。
     除此之外,roscore还提供了:master, rosout, parameter server

2, 运行一个新的ros node是新开一个Terminal,用rosrun命令
     Usage:
           $ rosrun [package_name] [node_name]
           $ rosrun turtlesim turtlesim_node
3, node运行时,还可以改一下node的名字
     这个叫做remapping,用处是:让你通过命令行,在多个configuration下,运行同一个node. 不太懂,暂时放下。

4, node运行时,rosnode是get info about a node工具
   查看node:运行rosnode list来查看运行的node
   可以ping它:$rosnode ping nodename
   查看rosnode info /rosnode_name 的工具,用来查看rosnode 的info,如:
       $ rosnode info /rosout
  




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值