Example #1
0
    def send_start(self):

        # 初始化节点空闲率列表
        global dimension
        global myLockIdleness
        global lastVisitList
        global instantIdlenessList
        global visitCountList
        global maxIdlenessList
        global meanIdlenessList
        global M2IdlenessList
        global stdDevIdlenessList
        seconds = rospy.get_time()  # Get the current time in float seconds
        myLockIdleness.acquire()
        lastVisitList = [seconds] * dimension
        instantIdlenessList = [0.0] * dimension
        visitCountList = [-1] * dimension  # 前几次的节点访问不记入统计,达到稳定巡逻状态时再开始统计
        maxIdlenessList = [0.0] * dimension
        meanIdlenessList = [0.0] * dimension
        M2IdlenessList = [0.0] * dimension
        stdDevIdlenessList = [0.0] * dimension
        for i in range(0, dimension):
            idlenessRecordDic[i] = []
        myLockIdleness.release()

        # 打开记录图中各节点的瞬时空闲率随时间变化的文件
        global timeidleness_filename
        self.timeidleness_file = open(timeidleness_filename, "w")

        global patrol_is_start
        patrol_is_start = True

        # 向巡逻机器人发布开始命令
        msg = command_t()
        msg.is_start = True
        msg.is_stop = False
        self.lc.publish("ROBOTCOMMAND", msg.encode())

        tkMessageBox.showinfo("Message", "Send Start Command")
Example #2
0
    def send_start(self):

        # 初始化节点空闲率列表
        global dimension
        global myLockIdleness
        global lastVisitList
        global instantIdlenessList
        global visitCountList
        global maxIdlenessList
        global meanIdlenessList
        global M2IdlenessList
        global stdDevIdlenessList
        seconds = rospy.get_time()  # Get the current time in float seconds
        myLockIdleness.acquire()
        lastVisitList = [seconds] * dimension
        instantIdlenessList = [0.0] * dimension
        visitCountList = [-1] * dimension  # 前几次的节点访问不记入统计,达到稳定巡逻状态时再开始统计
        maxIdlenessList = [0.0] * dimension
        meanIdlenessList = [0.0] * dimension
        M2IdlenessList = [0.0] * dimension
        stdDevIdlenessList = [0.0] * dimension
        for i in range(0, dimension):
            idlenessRecordDic[i] = []
        myLockIdleness.release()

        # 打开记录图中各节点的瞬时空闲率随时间变化的文件
        global timeidleness_filename
        self.timeidleness_file = open(timeidleness_filename, 'w')

        global patrol_is_start
        patrol_is_start = True

        # 向巡逻机器人发布开始命令
        msg = command_t()
        msg.is_start = True
        msg.is_stop = False
        self.lc.publish("ROBOTCOMMAND", msg.encode())

        tkMessageBox.showinfo('Message', 'Send Start Command')
Example #3
0
    def send_stop(self):

        # 向巡逻机器人发布停止命令
        msg = command_t()
        msg.is_start = False
        msg.is_stop = True
        self.lc.publish("ROBOTCOMMAND", msg.encode())

        global patrol_is_start
        patrol_is_start = False

        tkMessageBox.showinfo("Message", "Send Stop Command")

        # 将巡逻统计结果保存到文件
        if os.path.exists(results_filename):
            outputfile = open(results_filename, "a")
        else:
            outputfile = open(results_filename, "w")
        #        outputfile.write(time.ctime())
        outputfile.write(time.strftime("%Y-%m-%d %X", time.localtime()))
        outputfile.write("\n")
        global dimension
        global myLockIdleness
        global lastVisitList
        global instantIdlenessList
        global visitCountList
        global maxIdlenessList
        global meanIdlenessList
        global M2IdlenessList
        global stdDevIdlenessList
        myLockIdleness.acquire()
        outputfile.write("VertexID ")
        for i in range(0, dimension):
            outputfile.write("%d " % (i))
        outputfile.write("\n")
        outputfile.write("VisitCount ")
        for i in range(0, dimension):
            outputfile.write("%d " % (visitCountList[i]))
        outputfile.write("\n")
        outputfile.write("MaxIdleness ")
        for i in range(0, dimension):
            outputfile.write("%.3f " % (maxIdlenessList[i]))
        outputfile.write("\n")
        outputfile.write("MeanIdleness ")
        for i in range(0, dimension):
            outputfile.write("%.3f " % (meanIdlenessList[i]))
        outputfile.write("\n")
        for i in range(0, dimension):
            if visitCountList[i] > 1:
                stdDevIdlenessList[i] = math.sqrt(M2IdlenessList[i] / visitCountList[i])
        outputfile.write("StdDevIdleness ")
        for i in range(0, dimension):
            outputfile.write("%.3f " % (stdDevIdlenessList[i]))
        outputfile.write("\n")
        outputfile.write("IdlenessRecord\n")
        for i in range(0, dimension):
            outputfile.write("(VertexID%d) " % (i))
            for listelement in idlenessRecordDic[i]:
                outputfile.write("%.3f " % (listelement))
            outputfile.write("\n")
        myLockIdleness.release()
        outputfile.write("\n")
        outputfile.close()

        # 关闭记录图中各节点的瞬时空闲率随时间变化的文件
        self.timeidleness_file.close()

        tkMessageBox.showinfo("Message", "Results File Saved")
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import lcm
from exlcm import command_t

lc = lcm.LCM()

msg = command_t()

msg.is_start = True
msg.is_stop = False

lc.publish("ROBOTCOMMAND", msg.encode())
Example #5
0
    def send_stop(self):

        # 向巡逻机器人发布停止命令
        msg = command_t()
        msg.is_start = False
        msg.is_stop = True
        self.lc.publish("ROBOTCOMMAND", msg.encode())

        global patrol_is_start
        patrol_is_start = False

        tkMessageBox.showinfo('Message', 'Send Stop Command')

        # 将巡逻统计结果保存到文件
        if os.path.exists(results_filename):
            outputfile = open(results_filename, 'a')
        else:
            outputfile = open(results_filename, 'w')
#        outputfile.write(time.ctime())
        outputfile.write(time.strftime("%Y-%m-%d %X", time.localtime()))
        outputfile.write('\n')
        global dimension
        global myLockIdleness
        global lastVisitList
        global instantIdlenessList
        global visitCountList
        global maxIdlenessList
        global meanIdlenessList
        global M2IdlenessList
        global stdDevIdlenessList
        myLockIdleness.acquire()
        outputfile.write('VertexID ')
        for i in range(0, dimension):
            outputfile.write('%d ' % (i))
        outputfile.write('\n')
        outputfile.write('VisitCount ')
        for i in range(0, dimension):
            outputfile.write('%d ' % (visitCountList[i]))
        outputfile.write('\n')
        outputfile.write('MaxIdleness ')
        for i in range(0, dimension):
            outputfile.write('%.3f ' % (maxIdlenessList[i]))
        outputfile.write('\n')
        outputfile.write('MeanIdleness ')
        for i in range(0, dimension):
            outputfile.write('%.3f ' % (meanIdlenessList[i]))
        outputfile.write('\n')
        for i in range(0, dimension):
            if visitCountList[i] > 1:
                stdDevIdlenessList[i] = math.sqrt(M2IdlenessList[i] /
                                                  visitCountList[i])
        outputfile.write('StdDevIdleness ')
        for i in range(0, dimension):
            outputfile.write('%.3f ' % (stdDevIdlenessList[i]))
        outputfile.write('\n')
        outputfile.write('IdlenessRecord\n')
        for i in range(0, dimension):
            outputfile.write('(VertexID%d) ' % (i))
            for listelement in idlenessRecordDic[i]:
                outputfile.write('%.3f ' % (listelement))
            outputfile.write('\n')
        myLockIdleness.release()
        outputfile.write('\n')
        outputfile.close()

        # 关闭记录图中各节点的瞬时空闲率随时间变化的文件
        self.timeidleness_file.close()

        tkMessageBox.showinfo('Message', 'Results File Saved')