Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0be932c1 authored by Fabien Grzeskowiak's avatar Fabien Grzeskowiak
Browse files

add clock controller

parent ac6f1813
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
import rospy
import sys
import math
from time import sleep
from rosgraph_msgs.msg import Clock
myargv = rospy.myargv(argv=sys.argv)
script, sleep_time, delta_time = myargv
sleep_time = float(sleep_time)
delta_time = float(delta_time)
def publish_clock():
# initialize node
rospy.init_node('clock_controller', anonymous = False)
### Set up clock publisher
clock_pub = rospy.Publisher('clock', Clock, queue_size = 1)
clock_pub2 = rospy.Publisher('myclock', Clock, queue_size = 1)
msg = Clock()
msg.clock = rospy.Time()
current_time = 0
while not rospy.is_shutdown():
### Publish clock
secs = int(current_time)
nsecs = 1e9 * (current_time - secs)
msg.clock = rospy.Time(secs,nsecs)
clock_pub.publish(msg)
clock_pub2.publish(msg)
current_time += delta_time
sleep(sleep_time)
if __name__ == '__main__':
publish_clock()
......@@ -12,7 +12,7 @@ rospy.init_node('joy_to_twist', anonymous = True)
#### Setup joy_to_twist Publisher
joy_to_twist_pub = rospy.Publisher(topic, Twist, queue_size = 5)
joy_to_twist_pub = rospy.Publisher(topic, Twist, queue_size = 1)
msg = Twist()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment