Go to the documentation of this file.00001
00002 import time
00003 import json
00004 import rospy
00005 import rospkg
00006 import datetime
00007 import requests
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 def main():
00039 rospy.init_node("web_test", anonymous=True)
00040
00041
00042
00043 url_prefix = 'http://52.38.170.95:8080'
00044 loop_rate = rospy.Rate(10)
00045
00046 login_request = json.dumps({
00047 "modelId": "LA120",
00048 "batteryLevel": 100,
00049 "machineStatus": {
00050 "systemStatus": "OK",
00051 "subsystemsStatuses": [
00052 {
00053 "componentId": "string",
00054 "componentStatus": "OK",
00055 "componentDetailedStatus": "OK"
00056 }
00057 ]
00058 },
00059 "mapVersion": 1,
00060 "isMaintenance": True,
00061 "isVirtual": True
00062 })
00063
00064 keep_alive_request = json.dumps({
00065 "batteryLevel": 100,
00066 "floorSticker": "1001",
00067 "missionInfo": {},
00068 "orientation": "90",
00069 "currentX": "2400",
00070 "currentY": "1200",
00071 "mapVersion": 1,
00072 "machineStatus": "READY"
00073 })
00074
00075 requests.post(url_prefix + '/machines/999/login', data=login_request, headers={'Content-type': 'application/json'})
00076
00077 while not rospy.is_shutdown():
00078 request_time = rospy.get_rostime()
00079 requests.post(url_prefix + '/machines/999/keepAlive', data=keep_alive_request, headers={'Content-type': 'application/json'}).json()
00080
00081
00082 dt = (rospy.get_rostime()-request_time).to_sec()
00083
00084 print "delta: " + str(dt)
00085
00086
00087
00088 loop_rate.sleep()
00089
00090
00091 log_file.close()
00092
00093 if __name__ == '__main__':
00094 main()