SHARE
TWEET

tryc

a guest Jan 22nd, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top