ROS(1)

#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
def velocity_publisher():
	rospy.init_node('velocity_publish',anonymous=True)
	turtle_vel_pub=rospy.Publisher('/turtle1/cmd_vel',Twist,queue_size=10)
	rate=rospy.Rate(10)
	while not rospy.is_shutdown():
		vel_msg=Twist()
		vel_msg.linear.x=0.5
		vel_msg.angular.z=0.2
		turtle_vel_pub.publish(vel_msg)
		rospy.loginfo("publish turtle velocity command[%0.2f m/s,%0.2f rad/s]",vel_msg.linear.x,vel_msg.angular.z)
		rate.sleep()
if __name__=='__main__':
	try:
		velocity_publisher()
	except rospy.ROSInterruptException:
		pass
#!/usr/bin/env python
import rospy
from turtlesim.msg import Pose
def poseCallback(msg):
	rospy.loginfo('turtle pose:x:%0.6f,y:%0.6f',msg.x,msg.y)
def pose_subscriber():
	rospy.init_node('pose_subscriber',anonymous=True)
	rospy.Subscriber('/turtle1/pose',Pose,poseCallback)
	rospy.spin()
if __name__=='__main__':
	pose_subscriber()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我是小z呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值