test_publisher_twist_step.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
00016 
00017 
00018 import rospy
00019 import math
00020 import random
00021 from geometry_msgs.msg import Twist
00022 
00023 
00024 def velPub():
00025   rospy.init_node("test_publisher_twist", anonymous=True)
00026 
00027   pub_vel = rospy.Publisher("command", Twist, queue_size=1)
00028   rospy.sleep(1.0)
00029 
00030   freq = 10.0
00031   r = rospy.Rate(freq)
00032   
00033   vel_msg = Twist()
00034 
00035   while not rospy.is_shutdown():
00036     time = rospy.Time.now()
00037     since_start = 0.0
00038     vel = random.uniform(-1.5, 1.5)
00039     while since_start < random.uniform(2.0, 5.0):
00040       since_start = (rospy.Time.now() - time).to_sec()
00041 
00042       vel_msg.angular.z = vel
00043       pub_vel.publish(vel_msg)
00044       r.sleep()
00045 
00046 if __name__ == '__main__':
00047   try:
00048       velPub()
00049   except rospy.ROSInterruptException: pass


cob_omni_drive_controller
Author(s): Christian Connette, Mathias Lüdtke
autogenerated on Thu Jun 6 2019 21:19:19