当前位置:网站首页>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
边栏推荐
- Analysis of smart jiangcai login in Jiangxi University of Finance and Economics
- 【驚了】迅雷下載速度竟然比不上虛擬機中的下載速度
- Double dqn notes
- 【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度
- 60 个神级 VS Code 插件!!
- [surprised] the download speed of Xunlei is not as fast as that of the virtual machine
- Pharmacy management system
- Substrate 源码追新导读: Call调用索引化, 存储层事物化全面完成
- Introduction to the novelty of substrat source code: indexing of call calls and fully completing the materialization of storage layer
- FlinkSQL自定义UDAF使用的三种方式
猜你喜欢

如何利用AI技术优化独立站客服系统?听听专家怎么说!

Today in history: Microsoft acquires PowerPoint developers; SGI and MIPS merge

Instructions for legend use in SuperMap iclient3d 11i for cesium 3D scene

NoSQL - redis configuration and optimization

Analysis of smart jiangcai login in Jiangxi University of Finance and Economics

60 个神级 VS Code 插件!!

MATLAB小技巧(22)矩阵分析--逐步回归

Tencent two sides: @bean and @component are used on the same class. What happens?
![[QNX Hypervisor 2.2用户手册]6.2.3 Guest与外部之间通信](/img/ca/9065325ce8882d95fb24c82fb62abc.png)
[QNX Hypervisor 2.2用户手册]6.2.3 Guest与外部之间通信

Efficient elliptic curve point addition and multiplication in scrypt
随机推荐
RDS MySQL数据迁移PolarDB MySQL费用可以转过去吗?
Introduction to the novelty of substrat source code: indexing of call calls and fully completing the materialization of storage layer
FlinkSQL自定义UDATF实现TopN
NoSQL - redis configuration and optimization
FFMpeg AVBufferPool 的理解与掌握
Tencent two sides: @bean and @component are used on the same class. What happens?
rpm2rpm 打包步骤
Unity脚本程序的开发
Some commonly used hardware information of the server (constantly updated)
江西财经大学智慧江财登录分析
Mysql中 begin..end使用遇到的坑
Today in history: Microsoft acquires PowerPoint developers; SGI and MIPS merge
[one day learning awk] Fundamentals
图解使用Navicat for MySQL创建存储过程
Mysql判断计算结果,除以100
Unity脚本的基础语法(4)-访问其他游戏对象
Lichuang EDA learning notes 10 common connector component identification and passive buzzer driving circuit
[one day learning awk] array usage
Flink SQL console, group not recognized_ Concat function?
Swagger2 automatically generates API documents