#!/usr/bin/env python3

import rospy
from rosgraph_msgs.msg import Clock
import time

def publish_simulated_time():
    rospy.init_node('sim_time_publisher')
    pub = rospy.Publisher('/clock', Clock, queue_size=10)
    
    rate = 100  # 每秒发布100次
    sleep_duration = 1.0 / rate  # 每次发布后的睡眠时间

    while not rospy.is_shutdown():
        current_wall_time = time.time()
        simulated_time = current_wall_time / 10.0  # 1/10 speed
        
        clock_msg = Clock()
        clock_msg.clock = rospy.Time.from_sec(simulated_time)
        pub.publish(clock_msg)

        time.sleep(sleep_duration)

if __name__ == '__main__':
    try:
        publish_simulated_time()
    except rospy.ROSInterruptException:
        pass
