def start():
global left_motor_pub,right_motor_pub
# publishing to "turtle1/cmd_vel" to control turtle1
global pub
pub = rospy.Publisher('turtle1/cmd_vel', Twist)
left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
# subscribed to joystick inputs on topic "joy"
rospy.Subscriber("joy", Joy, callback)
# starts the node
rospy.init_node('Joy2Turtle')
rospy.spin()
评论列表
文章目录