Skip to content
Snippets Groups Projects
Commit ee6b2463 authored by Daniel Christoph's avatar Daniel Christoph
Browse files

Update build/sim/location_monitor/scripts/bot_listener.py

parent beb23e9a
Branches
No related merge requests found
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from datetime import datetime
from gazebo_msgs.srv import GetModelState
from gazebo_msgs.srv import GetWorldProperties
WriteFlag = 0
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
logtime = str(current_time) + "_bot_listener_log.txt"
f = open(logtime, "w+")
def callback(data):
rospy.loginfo(data.data)
get_world_properties = rospy.ServiceProxy('/gazebo/get_world_properties', GetWorldProperties)
resp1 = get_world_properties()
f.write("[T:" + str(resp1.sim_time) + "] " + data.data + "\n")
def listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber('chatter', String, callback)
rospy.spin()
if __name__ == '__main__':
listener()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment