Advertisement
Guest User

tryc

a guest
Jan 22nd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import rospy
  4. import random
  5. from geometry_msgs.msg import Twist, Pose
  6.  
  7. MULT = 1
  8.  
  9. def callback(data):
  10. pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=10)
  11. if data.linear.x != 0.0 and random.random() < 0.2:
  12. data.angular.z = random.uniform(-1.0, 1.0)*MULT
  13. elif data.angular.z != 0.0 and random.random() < 0.2:
  14. data.linear.x *= -1
  15. pub.publish(data)
  16.  
  17. def listen():
  18. rospy.init_node('emmerdeur', anonymous=True)
  19. rospy.Subscriber('teleop/cmd_vel', Twist, callback)
  20. rospy.spin()
  21.  
  22. if __name__ == '__main__':
  23. try:
  24. listen()
  25. except rospy.ROSInterruptException:
  26. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement