当前位置:网站首页>mqtt-ros模拟发布一个自定义消息类型
mqtt-ros模拟发布一个自定义消息类型
2022-06-30 12:19:00 【huashuideyu】
mqtt-ros
#!/usr/bin/env python3
#coding = 'utf-8'
import rospy
import datetime
import time
from ros_mqtt_communication.msg import data
def velocity_publisher():
# ROS节点初始化
rospy.init_node('data_publisher', anonymous=True)
# 创建一个Publisher,发布名为/data_info的topic,消息类型为learning_topic::data,队列长度10
data_info_pub = rospy.Publisher('/data_info', data, queue_size=10)
#设置循环的频率
rate = rospy.Rate(1)
while not rospy.is_shutdown():
# 初始化learning_topic::data类型的消息
data_msg = data()
data_msg.time= time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
data_msg.location = 1;
data_msg.cage = 1;
data_msg.broiler_state= 1;
data_msg.number = 1;
# 发布消息
data_info_pub.publish(data_msg)
rospy.loginfo("Publsh data message[%s]",
data_msg)
# 按照循环频率延时
rate.sleep()
if __name__ == '__main__':
try:
velocity_publisher()
except rospy.ROSInterruptException:
pass
边栏推荐
- Dqn notes
- Substrate 源码追新导读: 质押额度大幅度削减, RocksDB可以完全被Disable
- 60 个神级 VS Code 插件!!
- FlinkSQL自定义UDAF使用的三种方式
- 【OpenGL】OpenGL Examples
- Mysql中 begin..end使用遇到的坑
- Redis cache problem
- Substrate 源码追新导读: 波卡系波卡权重计算全面更新, Governance 2.0 版本的优化和调整
- Scratch drawing square electronic society graphical programming scratch grade examination level 2 true questions and answers analysis June 2022
- "Xiaodeng" user personal data management in operation and maintenance
猜你喜欢
How to use the plug-in mechanism to gracefully encapsulate your request hook
电机控制park变换公式推导
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)
Some commonly used hardware information of the server (constantly updated)
电机控制Clarke(α/β)等幅值变换推导
黑马笔记---List系列集合与泛型
市值蒸发650亿后,“口罩大王”稳健医疗,盯上了安全套
Tencent cloud Database Engineer competency certification was launched, and people from all walks of life talked about talent training problems
黑马笔记---集合(Collection的常用方法与遍历方式)
Redis-緩存問題
随机推荐
【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle
Idea has a new artifact, a set of code to adapt to multiple terminals!
60 divine vs Code plug-ins!!
Qt中的事件处理
Problems and analysis in JMeter performance testing. How many problems have you encountered?
Two batches of pure milk are unqualified? Michael responded that he was conducting a large-scale screening and sampling inspection of products
Clipboardjs - development learning summary 1
JMeter之事务控制器
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (II)
论文解读(AGC)《Attributed Graph Clustering via Adaptive Graph Convolution》
【OpenGL】OpenGL Examples
Introduction to sub source code updating: mid May: uniques NFT module and nomination pool
When MySQL judges that the execution condition is null, it returns 0. Correct parameter count in the call to native function 'isnull',
JMeter性能测试工作中遇到的问题及剖析,你遇到了几个?
第十三章 信号(三)- 示例演示
Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
Charles打断点修改请求数据&响应数据
【OpenGL】OpenGL Examples
问卷星问卷抓包分析
江西财经大学智慧江财登录分析