当前位置: 首页 > news >正文

Interactive Marker Publish Pose All the Time (Interactive Marker通过topic一直发送其状态)

以下代码实现了:Interactive Marker通过topic一直发送其状态,而不只是交互时才发送。
几个要点:

  • 通过定时器rospy.Timer实现Publish
  • InteractiveMarkerServer feedback.pose的类型是geometry_msgs/Pose,而不是geometry_msgs/PoseStamped
#!/usr/bin/env pythonimport rospy
import copyfrom interactive_markers.interactive_marker_server import *
from visualization_msgs.msg import *
from geometry_msgs.msg import Point
from geometry_msgs.msg import Poseclass ObstaclePublisher:def __init__(self, obs_init_position: list):# self.server = Noneself.server = InteractiveMarkerServer("obstacle_controls")position = Point(obs_init_position[0], obs_init_position[1], obs_init_position[2])# include orientation# self.make6DofMarker(False, InteractiveMarkerControl.MOVE_ROTATE_3D, position, True)# without orientationself.make6DofMarker(False, InteractiveMarkerControl.MOVE_3D, position, False)self.ps = Pose()self.ps.position = position# a topic to publish obstacle's pose all the timeself.pub = rospy.Publisher('/obstacle_pose', Pose, queue_size=1)rospy.Timer(rospy.Duration(0.02), self.publish_obs_pose)rospy.loginfo("Publishing pose of the obstacle at topic: " + str(self.pub.name))self.server.applyChanges()def processFeedback(self, feedback):rospy.loginfo("You are operating the obstacle.")self.ps = feedback.poseself.server.applyChanges()def makeBox(self, msg):marker = Marker()marker.type = Marker.SPHEREmarker.scale.x = msg.scale * 0.2marker.scale.y = msg.scale * 0.2marker.scale.z = msg.scale * 0.2marker.color.r = 0.8marker.color.g = 0.1marker.color.b = 0.1marker.color.a = 1.0return markerdef makeBoxControl(self, msg):control = InteractiveMarkerControl()control.always_visible = Truecontrol.markers.append(self.makeBox(msg))msg.controls.append(control)return control###################################################################### Marker Creationdef normalizeQuaternion(self, quaternion_msg):norm = quaternion_msg.x**2 + quaternion_msg.y**2 + quaternion_msg.z**2 + quaternion_msg.w**2s = norm ** (-0.5)quaternion_msg.x *= squaternion_msg.y *= squaternion_msg.z *= squaternion_msg.w *= sdef make6DofMarker(self, fixed, interaction_mode, position, show_6dof=False):int_marker = InteractiveMarker()int_marker.header.frame_id = "world"int_marker.pose.position = positionint_marker.scale = 1int_marker.name = "Obstacle"int_marker.description = "Obstacle"# insert a obstacleself.makeBoxControl(int_marker)int_marker.controls[0].interaction_mode = interaction_modeif show_6dof:control = InteractiveMarkerControl()control.orientation.w = 1control.orientation.x = 1control.orientation.y = 0control.orientation.z = 0self.normalizeQuaternion(control.orientation)control.name = "rotate_x"control.interaction_mode = InteractiveMarkerControl.ROTATE_AXISif fixed:control.orientation_mode = InteractiveMarkerControl.FIXEDint_marker.controls.append(control)control = InteractiveMarkerControl()control.orientation.w = 1control.orientation.x = 1control.orientation.y = 0control.orientation.z = 0self.normalizeQuaternion(control.orientation)control.name = "move_x"control.interaction_mode = InteractiveMarkerControl.MOVE_AXISif fixed:control.orientation_mode = InteractiveMarkerControl.FIXEDint_marker.controls.append(control)control = InteractiveMarkerControl()control.orientation.w = 1control.orientation.x = 0control.orientation.y = 1control.orientation.z = 0self.normalizeQuaternion(control.orientation)control.name = "rotate_z"control.interaction_mode = InteractiveMarkerControl.ROTATE_AXISif fixed:control.orientation_mode = InteractiveMarkerControl.FIXEDint_marker.controls.append(control)control = InteractiveMarkerControl()control.orientation.w = 1control.orientation.x = 0control.orientation.y = 1control.orientation.z = 0self.normalizeQuaternion(control.orientation)control.name = "move_z"control.interaction_mode = InteractiveMarkerControl.MOVE_AXISif fixed:control.orientation_mode = InteractiveMarkerControl.FIXEDint_marker.controls.append(control)control = InteractiveMarkerControl()control.orientation.w = 1control.orientation.x = 0control.orientation.y = 0control.orientation.z = 1self.normalizeQuaternion(control.orientation)control.name = "rotate_y"control.interaction_mode = InteractiveMarkerControl.ROTATE_AXISif fixed:control.orientation_mode = InteractiveMarkerControl.FIXEDint_marker.controls.append(control)control = InteractiveMarkerControl()control.orientation.w = 1control.orientation.x = 0control.orientation.y = 0control.orientation.z = 1self.normalizeQuaternion(control.orientation)control.name = "move_y"control.interaction_mode = InteractiveMarkerControl.MOVE_AXISif fixed:control.orientation_mode = InteractiveMarkerControl.FIXEDint_marker.controls.append(control)self.server.insert(int_marker, self.processFeedback)def publish_obs_pose(self, *args):self.pub.publish(self.ps)if __name__ == "__main__":rospy.init_node("obstacle_controls")op = ObstaclePublisher([0.6, 0.6, 0.6])rospy.spin()

相关文章:

Interactive Marker Publish Pose All the Time (Interactive Marker通过topic一直发送其状态)

以下代码实现了:Interactive Marker通过topic一直发送其状态,而不只是交互时才发送。 几个要点: 通过定时器rospy.Timer实现PublishInteractiveMarkerServer feedback.pose的类型是geometry_msgs/Pose,而不是geometry_msgs/PoseS…...

前后端分离------后端创建笔记(04)前后端对接

本文章转载于【SpringBootVue】全网最简单但实用的前后端分离项目实战笔记 - 前端_大菜007的博客-CSDN博客 仅用于学习和讨论,如有侵权请联系 源码:https://gitee.com/green_vegetables/x-admin-project.git 素材:https://pan.baidu.com/s/…...

一站式自动化测试平台-Autotestplat

3.1 自动化平台开发方案 3.1.1 功能需求 3.1.3 开发时间计划 如果是刚入门、但有一点代码基础的测试人员,大概 3 个月能做出演示版(Demo)进行自动化测试,6 个月内胜任开展工作中项目的自动化测试。 如果是有自动化测试基础的测试人员,大概 …...

Ansible Service模块,使用 Ansible Service模块进行服务管理

Ansible 是一种自动化工具,它可以简化配置管理、应用程序部署和任务自动化等操作。Ansible 的 Service 模块是其中一个重要的模块,它提供了管理服务的功能,使得在远程主机上启动、停止、重启和重新加载服务变得简单和可靠。本文将介绍 Ansibl…...

共识算法初探

共识机制的背景 加密货币都是去中心化的,去中心化的基础就是P2P节点众多,那么如何吸引用户加入网络成为节点,有那些激励机制?同时,开发的重点是让多个节点维护一个数据库,那么如何决定哪个节点写入&#x…...

Oracle查询表字段名并拼接

在数据库使用中,我们常常需要,获取一张表的全部字段,那该如何查询呢? 查询表字段名 SELECT column_name FROM all_tab_columns WHERE table_name table_name; 只需将引号中的table_name,替换为自己的表名&#xff0…...

8 张图 | 剖析 Eureka 的首次同步注册表

注册表对于注册中心尤为重要,所有的功能都是围绕这个注册表展开。比如服务 A 要想访问服务 B,就得知道服务 B 的 IP 地址和端口号吧。如下图所示,传统的方式就是服务 A 知道了服务 B 的地址后,发送 HTTP 请求到对应的 API 地址上。…...

github ssh配置

1、生成公钥 用下面的命令生成公钥 ssh-keygen -t rsa -b 4096 -C 邮箱 生成的公钥默认在文件夹 ~/.ssh/ 下的 id_rsa.pub 2、在github配置本地的公钥 先复制本地公钥文件中的内容 cat ~/.ssh/id_rsa.pub 打开github的settings > SSH and GPG keys > new SSH key …...

c51单片机串口通信(中断方式接收数据)(单片机--单片机通信)示例代码 附proteus图

单片机一般采用中断方式接受数据,这样便于及时处理 #include "reg51.h" #include "myheader.h" #define uchar unsigned char int szc[10]{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; int bufferc[6]{0}; int sza[6]{0x01,0x02,0x0…...

腾讯面试题算法还原【游戏安全】

本题的参考链接:https://share.weiyun.com/5Xg2b7v 其实拿到这个题我就感觉在哪里看过,后来想想是在旺仔那里看到的,以下是旺仔写的分析过程可以参考一下https://bbs.kanxue.com/thread-276536.htm 但是这个题要比旺仔拿到的那个要增加些许…...

vue + less 实现动态主题换肤功能

文章目录 前言一、前提条件1. 初始化vue项目2. 安装插件 二、新建文件夹主题theme1.style.less文件2.model.js文件3.theme.js文件theme文件夹最终效果 三、修改vue.config.js文件四、页面上的具体使用1. index.vue 页面2. index.vue 页面注意点说明3. index.vue 效果 五、在js中…...

matlab使用教程(15)—图论基础

1.有向图和无向图 1.1什么是图? 图是表示各种关系的节点和边的集合: • 节点 是与对象对应的顶点。 • 边 是对象之间的连接。 • 图的边有时会有权重 ,表示节点之间的每个连接的强度(或一些其他属性)。 这些定…...

【量化课程】02_4.数理统计的基本概念

2.4_数理统计的基本概念 数理统计思维导图 更多详细内容见notebook 1.基本概念 总体:研究对象的全体,它是一个随机变量,用 X X X表示。 个体:组成总体的每个基本元素。 简单随机样本:来自总体 X X X的 n n n个相互…...

【计算机视觉|生成对抗】改进的生成对抗网络(GANs)训练技术

本系列博文为深度学习/计算机视觉论文笔记,转载请注明出处 标题:Improved Techniques for Training GANs 链接:[1606.03498v1] Improved Techniques for Training GANs (arxiv.org) 摘要 本文介绍了一系列应用于生成对抗网络(G…...

SQLyog中导入CSV文件入库到MySQL中

1.在数据库中新建一个表,设置列名(与待导入文件一致),字段可以多出几个都可以 2.右键表名,导入- - >导入使用本地加载的CSV数据 选择使用加载本地CVS数据 3.指定好转义字符,将终止设置为,号(英文状态下…...

Spring Security6 最新版配置该怎么写,该如何实现动态权限管理

Spring Security 在最近几个版本中配置的写法都有一些变化,很多常见的方法都废弃了,并且将在未来的 Spring Security7 中移除,因此又补充了一些新的内容,重新发一下,供各位使用 Spring Security 的小伙伴们参考。 接下…...

CommandLineRunner 和 ApplicationRunner 用于Spring Boot 应用启动后执行特定逻辑

CommandLineRunner 和 ApplicationRunner 都是 Spring Boot 中用于在应用启动后执行特定逻辑的接口。它们的主要区别在于传递的参数类型和执行顺序。下面我将为您详细解释它们的用途、使用案例以及执行顺序。 CommandLineRunner CommandLineRunner 是一个接口,它有…...

一、Dubbo 简介与架构

一、Dubbo 简介与架构 1.1 应用架构演进过程 单体应用:JEE、MVC分布式应用:SOA、微服务化 1.2 Dubbo 简介一种分布式 RPC 框架,对专业知识(序列化/反序列化、网络、多线程、设计模式、性能优化等)进行了更高层的抽象和…...

软考:中级软件设计师:文件管理,索引文件结构,树型文件结构,位示图,数据传输方式,微内核

软考:中级软件设计师: 提示:系列被面试官问的问题,我自己当时不会,所以下来自己复盘一下,认真学习和总结,以应对未来更多的可能性 关于互联网大厂的笔试面试,都是需要细心准备的 (1…...

实践-CNN卷积层

实践-CNN卷积层 1 卷积层构造2 整体流程3 BatchNormalization效果4 参数对比5 测试效果 1 卷积层构造 2 整体流程 根据网络结构来写就可以了。 池化 拉平 训练一个网络需要2-3天的时间。用经典网络来,一些细节没有必要去扣。 损失函数: fit模型&…...

AliceSoft游戏文件处理终极指南:从入门到精通的完整解决方案

AliceSoft游戏文件处理终极指南:从入门到精通的完整解决方案 【免费下载链接】alice-tools Tools for extracting/editing files from AliceSoft games. 项目地址: https://gitcode.com/gh_mirrors/al/alice-tools AliceSoft游戏文件处理工具Alice-Tools是一…...

ens33网络接口DOWN状态诊断与修复:从基础命令到Netplan配置

1. 为什么ens33接口会突然DOWN掉? 最近在调试Ubuntu虚拟机时,突然发现网络连接断了。用ip addr一看,ens33接口的状态赫然显示着"DOWN"。这种情况在虚拟化环境中其实很常见,我遇到过不下十次。通常表现为:虚拟…...

李慕婉-仙逆-造相Z-Turbo应用:自动化小说解析与视觉化内容生成系统

李慕婉-仙逆-造相Z-Turbo应用:自动化小说解析与视觉化内容生成系统 想象一下,你是一家网络文学平台的内容运营。每天,海量的新章节需要配图,作者们渴望看到自己笔下的人物和世界被具象化,读者则期待更沉浸的阅读体验。…...

用STM32F103和0.96寸OLED做个桌面电子宠物:从GIF动图到屏幕显示的完整流程

用STM32F103和0.96寸OLED打造智能桌面电子宠物:从动图处理到交互设计的完整指南 在嵌入式开发的世界里,没有什么比亲手打造一个会动的电子宠物更有成就感了。想象一下,你的桌面上有一个由0.96寸OLED屏幕和STM32F103微控制器驱动的小生命&…...

从VASP的POSCAR到精美插图:一条ASE可视化流水线搭建指南

从VASP的POSCAR到精美插图:一条ASE可视化流水线搭建指南 在计算材料学研究中,我们常常需要处理大量的结构文件,尤其是VASP计算产生的POSCAR文件。这些文件包含了材料的原子坐标和晶格信息,但直接阅读文本文件很难直观理解材料的几…...

Qwen3-VL-8B-Instruct-GGUF实战:上传图片秒懂内容,智能问答体验分享

Qwen3-VL-8B-Instruct-GGUF实战:上传图片秒懂内容,智能问答体验分享 1. 模型概述与核心优势 Qwen3-VL-8B-Instruct-GGUF是阿里通义最新推出的中量级多模态模型,它最大的特点可以用一句话概括:用8B参数实现72B级别的视觉语言理解…...

如何在5分钟内成为资源下载高手:res-downloader的终极指南

如何在5分钟内成为资源下载高手:res-downloader的终极指南 【免费下载链接】res-downloader 视频号、小程序、抖音、快手、小红书、直播流、m3u8、酷狗、QQ音乐等常见网络资源下载! 项目地址: https://gitcode.com/GitHub_Trending/re/res-downloader res-do…...

网站SEO优化是否需要长期维护

网站SEO优化是否需要长期维护 在当前竞争激烈的互联网环境中,网站的SEO优化已经成为每个企业和个人网站的重要策略之一。许多人在初期投入后,常常会有一个疑问,那就是“网站SEO优化是否需要长期维护?”本文将从问题分析、原因说明…...

UE5地牢生成实战:从零搭建程序化地下城(附完整蓝图逻辑)

UE5地牢生成实战:从零搭建程序化地下城(附完整蓝图逻辑) 在游戏开发中,程序化内容生成(PCG)技术正变得越来越重要。想象一下,你正在开发一款Roguelike游戏,每次玩家进入地牢都能获得全新的探索体验——这正…...

面试-Linear Attention的学习

Linear Attention 学习笔记 0. Linear Attention 的目的与背景 0.1 标准 Attention 的瓶颈 在 Transformer 的标准 Self-Attention 机制中,注意力分数的计算方式如下: Attention(Q,K,V)=softmax(QKTd)V \text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqr…...