Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import rospy
- import random
- from geometry_msgs.msg import Twist, Pose
- MULT = 1
- def callback(data):
- pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=10)
- if data.linear.x != 0.0 and random.random() < 0.2:
- data.angular.z = random.uniform(-1.0, 1.0)*MULT
- elif data.angular.z != 0.0 and random.random() < 0.2:
- data.linear.x *= -1
- pub.publish(data)
- def listen():
- rospy.init_node('emmerdeur', anonymous=True)
- rospy.Subscriber('teleop/cmd_vel', Twist, callback)
- rospy.spin()
- if __name__ == '__main__':
- try:
- listen()
- except rospy.ROSInterruptException:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement