test_publisher_twist_step.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import rospy
19 import math
20 import random
21 from geometry_msgs.msg import Twist
22 
23 
24 def velPub():
25  rospy.init_node("test_publisher_twist", anonymous=True)
26 
27  pub_vel = rospy.Publisher("command", Twist, queue_size=1)
28  rospy.sleep(1.0)
29 
30  freq = 10.0
31  r = rospy.Rate(freq)
32 
33  vel_msg = Twist()
34 
35  while not rospy.is_shutdown():
36  time = rospy.Time.now()
37  since_start = 0.0
38  vel = random.uniform(-1.5, 1.5)
39  while since_start < random.uniform(2.0, 5.0):
40  since_start = (rospy.Time.now() - time).to_sec()
41 
42  vel_msg.angular.z = vel
43  pub_vel.publish(vel_msg)
44  r.sleep()
45 
46 if __name__ == '__main__':
47  try:
48  velPub()
49  except rospy.ROSInterruptException: pass


cob_base_controller_utils
Author(s): Felix Messmer , Mathias L├╝dtke
autogenerated on Fri Nov 8 2019 03:46:51