rospy的publisher和init_node

2023-05-16

文章目录

    • 1,class Publiser (发布者)
    • 2, rospy.init_node (初始化节点)

1,class Publiser (发布者)

废话不多说,先看官方文档对这个api的解释

class Publisher(Topic):
    """
    Class for registering as a publisher of a ROS topic.
    """
    '''这里说的是Publisher类的作用,注册为ROS topic的发布者'''
    def __init__(self,name,data_class,subscriber_listener=None,
                 tcp_nodelay=False,latch=False,
                 headers=None,queue_size=None):
        '''
        下面是对各个参数的解释
        Constructor
        @param name:resource name of topic,e.g.laser
        topic的资源名,比如激光。
        @type name:str
        类型str
        @param data_class: message class for serialization
        @type data_class:L{message} class
        消息序列化的类
        @param subscriber_listener:listener for 
        subscriber_listener events.may be None.
        @type subscriber_listener:L{SubscribeListemer}
        订阅者类,可以为空
        @param tcp_nodelay: If True,sets TCP_NODELAY on publisher‘s socket (disables Nagle algorithm).This result in lower latency publishing at the cost of efficiency.
        @type tcp_nodelay:boll
        tcp节点延迟,如果为真的话,设置节点延迟在tcp节点上。这个结果以降低发布者的效率为代价。
        @param latch: If True, the last message published is
        'latched', meaning that any future subscribers will be sent
        that message immediately upon connection。
        @type  latch: bool
        如果为真的话,最新的信息是latched,指的是在连接的时候,未来的订阅着,会第一时间发送message。
        @param headers: If not None, a dictionary with additional header
        key-values being used for future connections.
        @type  headers: dict
        请求头
         @param queue_size: The queue size used for asynchronously
        publishing messages from different threads.  A size of zero
        means an infinite queue, which can be dangerous.  When the
        keyword is not being used or when None is passed all
        publishing will happen synchronously and a warning message
        will be printed.
        @type  queue_size: int
        来自不同的线程,为了异步发送消息被使用的队列大小。
        初始化为0的队列是很危险的。当参数没有被使用或者为空的时候,所有的消息将被同步发送,一个警告的消息被打印在控制台上。
        '''

2, rospy.init_node (初始化节点)

def init_node(name,argv=None,anonymous=False,log_level=None,
              disable_rostime=False,disable_rosout=False,disable_signals=False,xmlrpc_port=0,tcpros_port=0):
    '''
     Register client node with the master under the specified name.
    This MUST be called from the main Python thread unless
    disable_signals is set to True. Duplicate calls to init_node are
    only allowed if the arguments are identical as the side-effects of
    this method are not reversible.
    注册客户端节点到master,使用指定的名字。这必须从python的主线程调用除非disable_signals被设置为true。对init_node的重复调用是被允许的,只有参数完全一样,而且这种方法是不可逆的。
    @param name: Node's name. This parameter must be a base name,
        meaning that it cannot contain namespaces (i.e. '/')
    @type  name: str
    node节点名字。
     @param argv: Command line arguments to this program, including
        remapping arguments (default: sys.argv). If you provide argv
        to init_node(), any previously created rospy data structure
        (Publisher, Subscriber, Service) will have invalid
        mappings. It is important that you call init_node() first if
        you wish to provide your own argv.
    @type  argv: [str]
    这个程序的命令行参数,包括映射参数。如果你提供argv到init_node(),之前任何已经创建的rospy数据结构(publisher,subscriber,service)都将失效。首先调用init_node()非常重要,如果您希望提供自己的argv。
    @param anonymous: if True, a name will be auto-generated for the
        node using name as the base.  This is useful when you wish to
        have multiple instances of the same node and don't care about
        their actual names (e.g. tools, guis). name will be used as
        the stem of the auto-generated name. NOTE: you cannot remap
        the name of an anonymous node.  
    @type anonymous: bool
    如果为真,一个名字将会自动生成对于节点,来作为base名称。这是有用的,当你希望有多个节点,而不关心她们的名字。name将会被使用作为自动生成名字的词干。注意:你不能重新映射
匿名节点的名称。
	@param log_level: log level for sending message to /rosout and log
        file, which is INFO by default. For convenience, you may use
        rospy.DEBUG, rospy.INFO, rospy.ERROR, rospy.WARN, rospy.FATAL
    @type  log_level: int
    对于发送信息来说的日志等级,到/rosout and log file,默认等级是default.For convenience, you may use
        rospy.DEBUG, rospy.INFO, rospy.ERROR, rospy.WARN, rospy.FATAL。
     @param disable_signals: If True, rospy will not register its own
        signal handlers. You must set this flag if (a) you are unable
        to call init_node from the main thread and/or you are using
        rospy in an environment where you need to control your own
        signal handling (e.g. WX). If you set this to True, you should
        call rospy.signal_shutdown(reason) to initiate clean shutdown.

        NOTE: disable_signals is overridden to True if
        roslib.is_interactive() is True.
        
    @type  disable_signals: bool
    如果为true,rospy将不会注册他的唯一的信号处理器。你必须设置这个flag,如果在一个你正在使用的主线程的环境中你需要控制你的信号你不能调用init_node()。如果你设置为true,你应该调用rospy.signal_shutdowm(reason)去初始化优雅的关闭。
     @param disable_rostime: for internal testing only: suppresses
        automatic subscription to rostime
    @type  disable_rostime: bool
    对内部测试来说,压制自动订阅到rostime.
      @param disable_rosout: for internal testing only: suppress
        auto-publication of rosout
    @type  disable_rostime: bool
    对内部测试来说,压制rosout的自动发布。
     @param xmlrpc_port: If provided, it will use this port number for the client XMLRPC node.
    @type  xmlrpc_port: int
    如果提供的话,对client XMLPRC node来说,它将使用这个端口数字。
    @param tcpros_port: If provided, the TCPROS server will listen for
        connections on this port
    @type  tcpros_port: int
    如果提供的话,TCPROS服务将会监听端口的链接。
    
    '''
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

rospy的publisher和init_node 的相关文章

  • node基础之三:http 模块

    1 导入模块 const http require http 2 创建服务 const server http createServer request response gt 获取请求方法 request method 获取请求 url
  • npm指令执行前执行自定义代码

    1 基本逻辑 npm start执行前执行node bin wb handle scripts wb node bin wb handle npm start wb handle源码 删除deleteNodeModules配置的最后一级目录
  • nginx基本介绍(安装、常用命令、反向代理)

    文章目录 引言 一 nginx是什么 二 nginx的下载和安装 1 下载 2 windows下安装 3 运行 4 外部服务器无法访问问题 三 nginx的常用命令 四 nginx config 五 FileZilla 1 什么是FileZ
  • Node.js 版本管理工具 n 使用指南

    Node js 版本更新很快 目前 node v20 x 已经发布 我们在使用时避免不了会需要切换不同的 Node js 的版本来使用不同版本的特性 所以就出现了像 windows 上的 nvm MacOS 上的 n 工具 本文就介绍一下如
  • 初识pnpm

    初识pnpm 介绍 pnpm和npm yarn一样 都是包管理器 但是pnpm节约磁盘空间并且安装很快 所有的报会存储在硬盘的同一个位置 多个项目使用了同一个包时 在pnpm中他们是公用的 只会存储一遍 下次需要用到这个包时就会从硬盘中查找
  • React + Umi + Dva + Antd 简述 及创建项目过程简述

    React 你的第一个组件 React React是前端三大主流框架之一 你可以在React里传递多种类型的参数 如声明代码 帮助你渲染出UI 也可以是静态的HTML DOM元素 也可以传递动态变量 甚至是可交互的应用组件 安装react框
  • 解决node.js+MYSQL读/写date类型数据有异样,且相差8个小时的问题

    既将读 写格式为 2021 05 04T16 00 00 000Z 的数据 转换为本地日期时间 2021 05 05 格式 一 读取异样处理 例如 在数据库中date类型数据原本为 2021 05 05 但是直接打印出来确是下面这样 dat
  • express脚手架安装和使用,node添加跨域处理

    前言 node的脚手架 express generator 的安装和使用 安装 步骤一 全局安装脚手架 npm i express generator g cnpm i express generator g 可以运行命令 express
  • node快速创建一个工程项目

    1 安装express npm install g express 2 新建一个工程 指定使用ejs模板引擎 express e 文件名 3 安装需要的模块 cd 文件名 npm install 4 启动 SET DEBUG 文件名 npm
  • 在 __init__ 中定义成员与在 python 中的类体中定义成员之间的区别?

    做和做有什么区别 class a def init self self val 1 to doing class a val 1 def init self pass class a def init self self val 1 这创建
  • 我可以使用 __init__.py 定义全局变量吗?

    我想定义一个在包的所有子模块中都可用的常量 我以为最好的地方是在 init py根包的文件 但我不知道该怎么做 假设我有几个子包 每个子包都有几个模块 如何从这些模块访问该变量 当然 如果这是完全错误的 并且有更好的选择 我想知道 你应该能
  • __init__ 的目的

    我读了一些书 但无法像我想的那样完全理解这一点 我正在从 LPTHW 教程中制作一个 选择你自己的冒险 小游戏 这是完整的脚本 http codepad org YWVUlHnU http codepad org YWVUlHnU 我不明白
  • Python:在祖父母目录中导入文件

    等级制度 scripts web script1 py tests script2 py common utils py 我如何在 script1 和 script2 中导入 utils 并且仍然能够单独运行这些脚本 即 python sc
  • git 添加 . -> 对于新文件仍然“无需提交”

    我在 Git 上遇到了困难 我似乎无法添加我的文件 我跑了ls显示文件位于当前目录中 然后运行git add then git status这表明 没有什么可承诺的 JJ Computer first app JJ git init Rei
  • Android系统服务是从哪里启动的?

    在 嵌入式Android 一书中 它说 在 init rc 中 只有一个操作才会导致命令的执行 服务声明仅用于描述服务 它们实际上并不启动任何东西 第246页 那么 Android系统服务 例如servicemanager vold 是从哪
  • 使用 Swift 组合创建计时器发布器

    我一直在看通过 SwiftUI 的数据流 WWDC 演讲 https developer apple com videos play wwdc2019 226 他们有一张包含示例代码的幻灯片 其中使用连接到 SwiftUI 视图的计时器发布
  • 什么是 -[NSURL _fastCharacterContents]:?

    所以我在一个方法中调用它 id initWithContentURL NSString url if self super init NSLog xSheetMusicViewController url Casting an NSStri
  • 将符号链接添加到脚本到 rc.d 文件夹中以在系统启动期间启动进程[关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我使用的是 Fedora 15 我正在尝试添加 MYSql 守护进程以在系统启动期间启动 我明白我必须将其添加到rc5 d因为它是默认目标并且是gra
  • Python 日志记录:为什么 __init__ 被调用两次?

    我正在尝试将 python 日志记录与配置文件和自己的处理程序一起使用 这在某种程度上是有效的 真正让我困惑的是 init 被叫两次并且 del 被调用一次 当我删除整个配置文件内容并直接在代码中创建处理程序时 init 被调用一次并且 d
  • init 中的 Swift 通用约束

    我有通用的 我希望能够用特定的约束来初始化它 约束仅用于初始化 班里的其他人并不关心 这是一个简化的示例 struct Generic

随机推荐

  • FlinkSQL CDC实现同步oracle数据到mysql

    环境准备 1 flink 1 13 0 2 oracle 11g 3 flink connector oracle cdc 2 1 0 1 oracle环境配置 首先需要安装oracle环境 xff0c 参考 https blog csdn
  • MySQL窗口函数OVER()

    下面的讲解将基于这个employee2表 mysql gt SELECT FROM employee2 43 43 43 43 43 43 id name age salary dept id 43 43 43 43 43 43 3 小肖
  • ubuntu安装mysql详细过程

    1 安装mysql server sudo apt install mysql server 2 登录 sudo mysql u root p 两点要注意 添加sudo password中 任意密码都能登录 3 修改登录密码 ALTER U
  • 修改docker容器端口映射的方法

    大家都知道docker run可以指定端口映射 xff0c 但是容器一旦生成 xff0c 就没有一个命令可以直接修改 通常间接的办法是 xff0c 保存镜像 xff0c 再创建一个新的容器 xff0c 在创建时指定新的端口映射 有没有办法不
  • 【操作系统入门到成神系列 五】CPU 是如何执行任务的

    作者简介 xff1a 大家好 xff0c 我是 xff0c 独角兽企业的Java开发工程师 xff0c Java领域新星创作者 个人公众号 xff1a xff08 回复 技术书籍 可获千本电子书籍 xff09 系列专栏 xff1a Java
  • 群晖docker镜像源更换为阿里云镜像源

    群晖硬件 xff1a DS218 43 系统版本 xff1a DSM 7 0 41890 docker版本 xff1a 20 10 3 1233 前言 xff1a 除了群晖自带的应用之外 xff0c docker里也拥有及其丰富的软件 xf
  • 学好Windows编程要看的书籍

    本文是接着前面的学好C 43 43 要阅读的书籍而写的 xff0c 如果想了解C 43 43 的学习的话请先看学好C 43 43 要阅读的书籍 xff1a http blog csdn net a809146548 article deta
  • Git分支与标签(干货!!!)

    目录 一 Git分支 分支的概念 xff1a 分支的类别 xff1a 分支策略 xff1a 分支命令 xff1a git操作之pull拉取远程指定分支以及push推送到远程指定分支 xff1a 1 pull操作 2 push操作 二 Tag
  • 单片机结构及一些寄存器

    SCM 将通用微计算机基本功能部件集成在一块芯片上构成的一种专用微计算机系统 SCM 61 CPU 43 OSC 43 ROM 43 RAM 43 T C 43 INT 43 BEC 43 I O 43 UART CPU 中央处理器 OSC
  • Git Gui

    目录 1 什么是Git Gui 2 什么是ssh key 3 git github生成密钥并通过 第一步 xff1a 本地电脑配置 1 配置用户名和邮箱 xff08 如果已经配置 xff0c 就跳过 xff09 2 检查下自己之前有没有已经
  • 韦东山百问网freeRTOS教程

    欢迎阅读韦东山百问网freeRTOS教程 xff01 韦东山百问网freeRTOS教程 文档 100ask net
  • 金三银四跳槽季,Linux面试题放送

    进入金三银四 xff0c 很多小伙伴有被动跳槽的打算 xff0c 所以更新一些Linux面试题 xff0c 希望能帮到大家 xff01 一 你之前在公司使用linux命令做什么 我们公司之前测试系统搭建在linux上 xff0c 使用lin
  • 【软件测试】简历中的项目经历可以怎么写?

    工作这10多年来 xff0c 也经常做招聘的工作 xff0c 面试过的人超过50人次了 xff0c 而看过的候选人的简历则有几百份了 xff0c 但是清晰且能突出重点的简历 xff0c 确实很少遇到 这里基本可以说明一个问题 xff0c 很
  • 一名高级的Javaer,应该了解的 MYSQL 高级知识点

    SQL查询流程 1 通过客户端 服务器通信协议与 MySQL 建立连接2 查询缓存 xff0c 这是 MySQL 的一个可优化查询的地方 xff0c 如果开启了 Query Cache 且在查询缓存过程中查 询到完全相同的 SQL 语句 x
  • 激光slam基础入门笔记2——位姿表示与变换矩阵

    前言 xff1a 初步了解位置与位姿 xff1a 参考链接 xff1a 机器人学 1 0 位置与姿态概述 已注销 的博客 CSDN博客 位置和姿态 二维空间位姿表示与变换矩阵推导 xff1a 参考链接 xff1a 机器人学 1 1 二维空间
  • 【githubgirl】自主导航无人机的硬件组成与搭建方案

    不久前 xff0c 浙江大学 FASTLAB 实验室 xff0c 在 GitHub 上开源了一套自主导航无人机的硬件组成与搭建方案 xff1a Fast Drone 250 该项目可应用于无人机在未知环境中的自主飞行 xff0c 集群飞行等
  • React路由传参的几种方式

    react路由传值有三种方式 xff1a 1 props params 方法 xff0c 该方法可以传递一个或多个值 xff0c 但是每个值的类型都是字符串 xff0c 没法传递一个对象 xff1b 2 query方法 xff0c 该方法类
  • 文章五:Python 网络爬虫实战:使用 Beautiful Soup 和 Requests 抓取网页数据

    一 简介 本篇文章将介绍如何使用 Python 编写一个简单的网络爬虫 xff0c 从网页中提取有用的数据 我们将通过以下几个部分展开本文的内容 xff1a 网络爬虫的基本概念Beautiful Soup 和 Requests 库简介选择一
  • 无人机目标检测:使用YOLOv4在VisDrone数据集上进行目标检测任务

    在本篇博客中 我们将探讨如何使用YOLOv4在VisDrone数据集上进行无人机目标检测任务 目标检测是计算机视觉中的一个重要任务 可以用于自动驾驶汽车 无人机监测和视频分析等多种应用 YOLOv4是一种实时目标检测算法 以其速度和准确性而
  • rospy的publisher和init_node

    文章目录 1 xff0c class Publiser xff08 发布者 xff09 2 rospy init node 初始化节点 1 xff0c class Publiser xff08 发布者 xff09 废话不多说 xff0c 先