wpr_simulation/scripts/demo_vel_ctrl.py
2022-06-21 11:19:25 +08:00

18 lines
476 B
Python
Executable File

#!/usr/bin/env python3
# coding=utf-8
import rospy
from geometry_msgs.msg import Twist
if __name__ == "__main__":
rospy.init_node("demo_vel_ctrl")
# 发布速度控制话题
vel_pub = rospy.Publisher("cmd_vel",Twist,queue_size=10)
# 构建速度消息包并赋值
vel_msg = Twist()
vel_msg.linear.x = 0.1
# 构建发送频率对象
rate = rospy.Rate(10)
while not rospy.is_shutdown():
vel_pub.publish(vel_msg)
rate.sleep()