diff --git a/1toN/tower.py b/1toN/tower.py index 96a4901..c60bb68 100644 --- a/1toN/tower.py +++ b/1toN/tower.py @@ -37,7 +37,7 @@ def on_publish(self, userdata, mid): connect_flag = False -mqtt_config = {"host": "192.168.50.81", "port": 1883, "topic": "cmd/broadcast", "name": "Tower"} +mqtt_config = {"host": "192.168.50.117", "port": 1883, "topic": "cmd/broadcast", "name": "Tower"} client = initialise_clients(mqtt_config["name"]) client.on_publish = on_publish client.on_connect = on_connect diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_PUB.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_PUB.py index 5abb38c..ade87c6 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_PUB.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_PUB.py @@ -3,7 +3,6 @@ import paho.mqtt.client as mqtt import os import sys -import time import utils import argparse import proto.flyformatioln_pb2 as flyformatioln_pb2 @@ -11,6 +10,12 @@ import logging from utils.protoJson_delayClientA_PUB import Json_msg from utils.protoJson_delayClientA_PUB import Proto_msg +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter def init_dataFormat(cfg:utils.Read_delayA_PUB_Config): @@ -19,12 +24,14 @@ def init_dataFormat(cfg:utils.Read_delayA_PUB_Config): Proto_msg.client = client Proto_msg.qos = cfg.qos Proto_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB + Proto_msg.timefunction = time_function cfg.logFileName = "Proto" + cfg.logFileName pubFun = Proto_msg.callBack_gps elif cfg.msg_format == "Json": Json_msg.client = client Json_msg.qos = cfg.qos Json_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB + Json_msg.timefunction = time_function cfg.logFileName = "Json" + cfg.logFileName pubFun = Json_msg.callBack_gps else: diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_SUB.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_SUB.py index 688d973..3ea7611 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_SUB.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientA_SUB.py @@ -11,12 +11,22 @@ from utils.protoJson_delayClientA_SUB import Json_msg from utils.protoJson_delayClientA_SUB import Proto_msg import argparse + +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter + def init_dataFormat(cfg:utils.Read_delayB_SUB_Config): if cfg.msg_format == "Proto": Proto_msg.flight_information_msg = flight_information_pb2.flight_information_message() + Proto_msg.timefunction = time_function client.on_message = Proto_msg.on_message cfg.logFileName = "Proto" + cfg.logFileName elif cfg.msg_format == "Json": + Json_msg.timefunction = time_function client.on_message = Json_msg.on_message cfg.logFileName = "Json" + cfg.logFileName else: diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientB.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientB.py index 9a7f396..7c59946 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientB.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayClientB.py @@ -11,12 +11,20 @@ import logging from utils.protoJson_delayClientB_SUB import Json_msg from utils.protoJson_delayClientB_SUB import Proto_msg +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter + def init_dataFormat(cfg:utils.Read_delayB_SUB_Config): if cfg.msg_format == "Proto": Proto_msg.qos = cfg.qos Proto_msg.flight_information_msg = flight_information_pb2.flight_information_message() Proto_msg.fly_formation_msg = flyformatioln_pb2.fly_formation_message() Proto_msg.client = client + Proto_msg.timefunction = time_function client.on_message = Proto_msg.on_message cfg.logFileName = "Proto" + cfg.logFileName @@ -25,6 +33,7 @@ def init_dataFormat(cfg:utils.Read_delayB_SUB_Config): client.on_message = Json_msg.on_message Json_msg.qos = cfg.qos Json_msg.client = client + Json_msg.timefunction = time_function Json_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB cfg.logFileName = "Json" + cfg.logFileName else: diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos0/qos0_json_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos0/qos0_json_results.csv new file mode 100644 index 0000000..bf04a2d --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos0/qos0_json_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.0011079058506036218,0.0018572315,0.000286245,0.0014205115,0.0015167701250000001,0.000545408125 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos0/qos0_proto_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos0/qos0_proto_results.csv new file mode 100644 index 0000000..8c47d44 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos0/qos0_proto_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.0005457205640096619,0.001139727,0.0002876795,0.00051187875,0.0005749995,0.00045968224999999997 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos1/qos1_json_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos1/qos1_json_results.csv new file mode 100644 index 0000000..2f3b31c --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos1/qos1_json_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.0012001110130653266,0.0034074005,0.000345575,0.001500469,0.00172731725,0.0005705307499999999 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos1/qos1_proto_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos1/qos1_proto_results.csv new file mode 100644 index 0000000..e8a207c --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos1/qos1_proto_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.013397842829081632,0.0331875965,0.001426374,0.01344988275,0.0188322975,0.007942993249999999 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos2/qos2_json_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos2/qos2_json_results.csv new file mode 100644 index 0000000..8b9d2fe --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos2/qos2_json_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.001260704516566265,0.0039373875,0.0003931045,0.0008594622499999999,0.0020480373749999998,0.000682258875 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos2/qos2_proto_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos2/qos2_proto_results.csv new file mode 100644 index 0000000..46c9028 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/HiveMQ/qos2/qos2_proto_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.0005831447831603229,0.000865469,0.0003739,0.000583445,0.00063134825,0.00052823 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos0/qos0_json_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos0/qos0_json_results.csv new file mode 100644 index 0000000..5c68bb4 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos0/qos0_json_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.005515400321608041,0.0061309,0.005168977,0.0054042765,0.00579784425,0.00529582325 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos0/qos0_proto_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos0/qos0_proto_results.csv new file mode 100644 index 0000000..c516082 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos0/qos0_proto_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.005461257827760892,0.005944553,0.0052150925,0.0054043055,0.005570279250000001,0.0053312875 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos1/qos1_json_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos1/qos1_json_results.csv new file mode 100644 index 0000000..a6a2254 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos1/qos1_json_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.00036498601191765987,0.0007573845,0.0001645325,0.0003141375,0.00040260425,0.00028477250000000004 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos1/qos1_proto_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos1/qos1_proto_results.csv new file mode 100644 index 0000000..d8283cc --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos1/qos1_proto_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.0003217815603948896,0.000564259,0.000163318,0.000304936,0.0003428775,0.0002812645 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos2/qos2_json_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos2/qos2_json_results.csv new file mode 100644 index 0000000..6953ff6 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos2/qos2_json_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.005564575094094093,0.0063683505,0.0052167295,0.0054022075,0.005892462249999999,0.005326162 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos2/qos2_proto_results.csv b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos2/qos2_proto_results.csv new file mode 100644 index 0000000..c322a46 --- /dev/null +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/Mosquitto/qos2/qos2_proto_results.csv @@ -0,0 +1,2 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile +0.0055140315180180165,0.006291591,0.0052090165,0.005368706,0.00570384675,0.00531522075 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/measureDelay.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/measureDelay.py index bc85422..ae8c510 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/measureDelay.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/delayData/measureDelay.py @@ -11,6 +11,12 @@ def checkNumberofLines(df): else: return True +def remove_outliers(df): + Q1 = df.quantile(0.25) + Q3 = df.quantile(0.75) + IQR = Q3 - Q1 + df_out = df[~((df < (Q1 - 1.5 * IQR)) | (df > (Q3 + 1.5 * IQR))).any(axis=1)] + return df_out if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -18,7 +24,6 @@ if __name__ == "__main__": parser.add_argument("-b", "--broker", type=str, default="HiveMQ", help="Broker", required=True) args = parser.parse_args() - # read in the log file df_Proto_delayA_PUB = pd.read_csv(f"{args.broker}/qos{args.qos}/ProtodelayA_PUB.log", delim_whitespace=True, header=None, names=["count", "time"]) df_Proto_delayA_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/ProtodelayA_SUB.log", delim_whitespace=True, header=None, names=["count", "time"]) @@ -28,7 +33,6 @@ if __name__ == "__main__": df_Json_delayA_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/JsondelayA_SUB.log", delim_whitespace=True, header=None, names=["count", "time"]) df_Json_delayB_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/JsondelayB_SUB.log", delim_whitespace=True, header=None, names=["count", "time"]) - # check if the number of lines is correct checkNumberofLines(df_Proto_delayA_PUB) checkNumberofLines(df_Proto_delayA_SUB) @@ -38,8 +42,12 @@ if __name__ == "__main__": checkNumberofLines(df_Json_delayB_SUB) # print the resulting DataFrame - diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"] - df_Proto_delayA_PUB["time"] - df_Proto_delayB_SUB["time"])/1e9}) - diff_Json_df = pd.DataFrame({"Difftime":(df_Json_delayA_SUB["time"] - df_Json_delayA_PUB["time"] - df_Json_delayB_SUB["time"])/1e9}) + diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"] - df_Proto_delayA_PUB["time"] - df_Proto_delayB_SUB["time"])/1e9/2}) + diff_Json_df = pd.DataFrame({"Difftime":(df_Json_delayA_SUB["time"] - df_Json_delayA_PUB["time"] - df_Json_delayB_SUB["time"])/1e9/2}) + + # Remove outliers + diff_Proto_df = remove_outliers(diff_Proto_df) + diff_Json_df = remove_outliers(diff_Json_df) array_Proto = diff_Proto_df["Difftime"].to_numpy() array_Json = diff_Json_df["Difftime"].to_numpy() @@ -47,10 +55,88 @@ if __name__ == "__main__": avg_Proto = np.average(array_Proto) avg_Json = np.average(array_Json) - fig = plt.figure() - # plt.plot(array_Proto, color="blue", label=f"Proto: {avg_Proto}") - plt.plot(array_Json, color="red", label=f"qos0: {avg_Json}") + # Calculate statistics for Json + avg_latency_json = np.average(array_Json) + max_value_json = np.max(array_Json) + min_value_json = np.min(array_Json) + median_value_json = np.median(array_Json) + upper_quartile_json = np.percentile(array_Json, 75) + lower_quartile_json = np.percentile(array_Json, 25) + + result_dict_json = { + "Average Latency": [avg_latency_json], + "Maximum Value": [max_value_json], + "Minimum Value": [min_value_json], + "Median": [median_value_json], + "Upper Quartile": [upper_quartile_json], + "Lower Quartile": [lower_quartile_json] + } + + result_df_json = pd.DataFrame(result_dict_json) + result_df_json.to_csv(f"{args.broker}/qos{args.qos}/qos{args.qos}_json_results.csv", index=False) + + # Calculate statistics for Proto + avg_latency_proto = np.average(array_Proto) + max_value_proto = np.max(array_Proto) + min_value_proto = np.min(array_Proto) + median_value_proto = np.median(array_Proto) + upper_quartile_proto = np.percentile(array_Proto, 75) + lower_quartile_proto = np.percentile(array_Proto, 25) + + result_dict_proto = { + "Average Latency": [avg_latency_proto], + "Maximum Value": [max_value_proto], + "Minimum Value": [min_value_proto], + "Median": [median_value_proto], + "Upper Quartile": [upper_quartile_proto], + "Lower Quartile": [lower_quartile_proto] + } + + result_df_proto = pd.DataFrame(result_dict_proto) + result_df_proto.to_csv(f"{args.broker}/qos{args.qos}/qos{args.qos}_proto_results.csv", index=False) + + + + + # Plot both arrays together + fig1 = plt.figure() + plt.plot(array_Json, color="red", label=f"Json: {avg_Json}") + plt.plot(array_Proto, color="blue", label=f"Proto: {avg_Proto}") + plt.legend() + plt.xlabel("Number of messages") + plt.ylabel("Delay (s)") + plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}_both.png", dpi=100) + + # Plot Proto array alone + fig2 = plt.figure() + plt.plot(array_Proto, color="blue", label=f"Proto: {avg_Proto}") + plt.legend() + plt.xlabel("Number of messages") + plt.ylabel("Delay (s)") + plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}_proto.png", dpi=100) + + # Plot Json array alone + fig3 = plt.figure() + plt.plot(array_Json, color="red", label=f"Json: {avg_Json}") plt.legend() plt.xlabel("Number of messages") plt.ylabel("Delay (s)") - plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}.png", dpi=100) + plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}_json.png", dpi=100) + + + + + fig, ax = plt.subplots() + ax.boxplot(array_Json) + ax.set_title("Round Trip Latency") + ax.set_ylabel("Delay (s)") + ax.set_xticklabels(["Latency"]) + plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}_Json_boxplot.png", dpi=100) + + # fig, ax = plt.subplots() + # ax.boxplot(array_Proto) + # ax.set_title("Round Trip Latency") + # ax.set_ylabel("Delay (s)") + # ax.set_xticklabels(["Latency"]) + # plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}_Proto_boxplot.png", dpi=100) + diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_PUB.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_PUB.py index 51f9b92..3799eb4 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_PUB.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_PUB.py @@ -16,6 +16,7 @@ class Proto_msg: Delay_topicToMqtt_PUB = None count = 0 qos = None + timefunction = None @classmethod def callBack_gps(cls): @@ -46,7 +47,7 @@ class Proto_msg: @classmethod # publish a message def mqtt_Pub(cls, message:bytes, topics:str, waitForAck:bool=False)->None: - cls.timePub = time.perf_counter_ns() + cls.timePub = cls.timefunction() mid = cls.client.publish(topics, message, cls.qos)[1] logger.info("{} {}".format(cls.count,cls.timePub)) cls.count += 1 @@ -69,6 +70,7 @@ class Json_msg: Delay_topicToMqtt_PUB = None timePub = 0 qos = None + timefunction = None @classmethod @@ -110,7 +112,7 @@ class Json_msg: @classmethod def mqtt_Pub(cls, message:str, topics:str, waitForAck:bool=False): - cls.timePub = time.perf_counter_ns() + cls.timePub = cls.timefunction() mid = cls.client.publish(topics, message, cls.qos)[1] logger.info("{} {}".format(cls.count,cls.timePub)) cls.count += 1 diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_SUB.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_SUB.py index 310c97c..22d2282 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_SUB.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientA_SUB.py @@ -15,10 +15,11 @@ class Proto_msg: timeRcv = 0 msgCounter = None + timefunction = None @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = int(cls.flight_information_msg.FromString(msg.payload).heading) logger.info("{} {}".format(cls.msgCounter, cls.timeRcv)) @@ -27,10 +28,10 @@ class Proto_msg: class Json_msg: timeRcv = 0 msgCounter = None - + timefunction = None @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = orjson.loads(msg.payload)["count"] logger.info("{} {}".format(cls.msgCounter, cls.timeRcv)) diff --git a/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientB_SUB.py b/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientB_SUB.py index eafe9e5..09fd051 100644 --- a/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientB_SUB.py +++ b/Stream/experiment/RTL_test/MQTT_measure_rtl/utils/protoJson_delayClientB_SUB.py @@ -21,19 +21,19 @@ class Proto_msg: client = None timeRcv = 0 timeRsp = 0 - + timefunction = None msgCounter = None @classmethod def mqtt_Pub(cls, msg, waitForAck:bool=False): - cls.timeRsp = time.perf_counter_ns() + cls.timeRsp = cls.timefunction() mid = cls.client.publish(cls.Delay_topicToMqtt_PUB, msg, cls.qos)[1] timeDiff = cls.timeRsp - cls.timeRcv logger.info("{} {}".format(cls.msgCounter, timeDiff)) @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = int(cls.flight_information_msg.FromString(msg.payload).heading) cls.mqtt_Pub(msg=msg.payload) @@ -45,12 +45,12 @@ class Json_msg: client = None timeRcv = 0 timeRsp = 0 - + timefunction = None msgCounter = None @classmethod def mqtt_Pub(cls, msg, waitForAck:bool=False): - cls.timeRsp = time.perf_counter_ns() + cls.timeRsp = cls.timefunction() mid = cls.client.publish(cls.Delay_topicToMqtt_PUB, msg, cls.qos)[1] timeDiff = cls.timeRsp - cls.timeRcv logger.info("{} {}".format(cls.msgCounter, timeDiff)) @@ -58,6 +58,6 @@ class Json_msg: @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = orjson.loads(msg.payload)["count"] cls.mqtt_Pub(msg=msg.payload) \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/.gitignore b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/inspectionProfiles/Project_Default.xml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..e55ddbf --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,104 @@ + + + + \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/inspectionProfiles/profiles_settings.xml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/misc.xml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/misc.xml new file mode 100644 index 0000000..2f9d1a6 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/modules.xml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/modules.xml new file mode 100644 index 0000000..ac8a36e --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/uavlink_measrue_rtl.iml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/uavlink_measrue_rtl.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/uavlink_measrue_rtl.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/vcs.xml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/vcs.xml new file mode 100644 index 0000000..4fce1d8 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_PUB.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_PUB.py index 04dfca1..a0fd089 100755 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_PUB.py +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_PUB.py @@ -8,30 +8,30 @@ import proto.flight_information_pb2 as flight_information_pb2 import logging from utils.readConfig import Read_PUB_Config from utils.proto_delayClientA_PUB import Proto_msg_from_ros -import random -import time -class fakeGps(): - def __init__(self): - self.latitude = 8.0 - self.longitude = 8.1 - self.altitude = 8.88 +# simulation +from utils.flyInformation_gen import GPSgen + + +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter + -class fake_hdg(): - def __init__(self): - self.data = 1 def init_dataFormat(cfg:Read_PUB_Config): - Proto_msg_from_ros.sel = sel Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message() - + Proto_msg_from_ros.timefunction = time_function if __name__ == '__main__': FilePath = os.path.join(os.path.dirname(__file__),"utils","uavlinkConfig_PUB.yml") cfg = Read_PUB_Config(FilePath) - gps = fakeGps() - hdg = fake_hdg() + gps = GPSgen() + # set log stream_log_format = "%(asctime)s - %(levelname)s - %(message)s" @@ -56,19 +56,17 @@ if __name__ == '__main__': sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE) init_dataFormat(cfg) + count = 1 + while count <= 100: + gps.update_random() - while hdg.data <= 100: - gps.latitude = random.uniform(10, 100) - gps.longitude = random.uniform(10, 100) - gps.altitude = random.uniform(10, 100) - try: # test json Proto_msg_from_ros.callBack_gps(gps) - Proto_msg_from_ros.callBack_compass_hdg(hdg) + Proto_msg_from_ros.callBack_compass_hdg(count) time.sleep(1) - hdg.data += 1 + count += 1 except KeyboardInterrupt as e: sel.write(b'\xf2' + b'......................' + b'\x0d\x2a') readTenByte = sel.read_until(size=5) diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_SUB.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_SUB.py index a489fbc..179ffd7 100755 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_SUB.py +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientA_SUB.py @@ -10,17 +10,14 @@ from utils.readConfig import Read_SUB_Config from utils.proto_delayClientA_SUB import Proto_msg_to_ros import google.protobuf.message +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter def init_dataFormat(cfg:Read_SUB_Config): - # ros_namespace="/drone1" - # deviceData = b'\xf12222222222222222222222\r\x1a' - - # sel.write(deviceData) - # time.sleep(1) - # readTenByte = sel.read(size=5) - # print(readTenByte) - - Proto_msg_to_ros.flight_information_msg = flight_information_pb2.flight_information_message() @@ -56,9 +53,8 @@ if __name__ == '__main__': # test json if sel.in_waiting >= 25: readTenByte = sel.read_until(expected= b'\x01\x18', size=25) - timeSub = time.perf_counter_ns() + timeSub = time_function() Proto_msg_to_ros.on_message_Flight_Information(readTenByte, timeSub) - # time.sleep(3) except google.protobuf.message.DecodeError as e: print(readTenByte) diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientB.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientB.py index b5d1a05..8a1a246 100644 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientB.py +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayClientB.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 #coding:utf-8 import serial -import time import sys import os import proto.flight_information_pb2 as flight_information_pb2 @@ -9,19 +8,19 @@ import logging from utils.readConfig import Read_SUB_Config from utils.proto_delayClientB_SUB import Proto_msg_to_ros import google.protobuf.message +import sys +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter def init_dataFormat(cfg:Read_SUB_Config): - # ros_namespace="/drone1" - # deviceData = b'\xf12222222222222222222222\r\x1a' - - # sel.write(deviceData) - # time.sleep(1) - # readTenByte = sel.read(size=5) - # print(readTenByte) - Proto_msg_to_ros.sel = sel Proto_msg_to_ros.flight_information_msg = flight_information_pb2.flight_information_message() + Proto_msg_to_ros.timefunction = time_function if __name__ == '__main__': @@ -38,7 +37,7 @@ if __name__ == '__main__': stream_handler.setFormatter(stream_formatter) stream_handler.setLevel(logging.DEBUG) - file_handler = logging.FileHandler(cfg.logFileName, mode='w') + file_handler = logging.FileHandler("ProtodelayB_SUB.log", mode='w') file_handler.setFormatter(file_formatter) file_handler.setLevel(logging.INFO) @@ -61,7 +60,7 @@ if __name__ == '__main__': count += 1 continue last_packet = readTenByte - timeSub = time.perf_counter_ns() + timeSub = time_function() Proto_msg_to_ros.on_message_Flight_Information(readTenByte, timeSub) except google.protobuf.message.DecodeError as e: logger.debug(readTenByte) diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/measureDelay.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/measureDelay.py deleted file mode 100644 index 55a8008..0000000 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/measureDelay.py +++ /dev/null @@ -1,72 +0,0 @@ -import pandas as pd -import matplotlib.pyplot as plt -import numpy as np -import argparse -import sys - -def checkNumberofLines(df, log_name): - if df.shape[0] != args.number: - print(f"Warning: Number of lines in the log file {log_name} is not correct") - # check if the count is continuous - checkContinuousCount(df, log_file) - return False - else: - return True - -def checkContinuousCount(df, log_name): - duplicates = df[df["count"].duplicated()]["count"] - if not duplicates.empty: - print(f"Warning: Non-continuous count in the log file {log_name} at index {duplicates.index.tolist()}") - max_count = args.number - all_counts = set(range(1, max_count + 1)) - actual_counts = set(df["count"]) - missing = all_counts - actual_counts - if missing != set(): - print(f"Warning: missing msg in {log_name} at index {missing}") - -def filter_dataframes(dataframes): - common_counts = set(dataframes[0]["count"]) & set(dataframes[1]["count"]) & set(dataframes[2]["count"]) - return [df[df["count"].isin(common_counts)].reset_index(drop=True) for df in dataframes] -''' -df["count"].isin(common_counts): This part creates a boolean Series where each value is True if the corresponding "count" value is present in common_counts, and False otherwise. - -df[df["count"].isin(common_counts)]: This part filters the DataFrame df using the boolean Series created in the previous step, keeping only the rows where the "count" value is present in common_counts. - -df[df["count"].isin(common_counts)].reset_index(drop=True): This part resets the index of the filtered DataFrame, dropping the old index and creating a new one with default values (0, 1, 2, ...). The drop=True argument ensures that the old index is not added as a new column in the resulting DataFrame. -''' - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-n", "--number", type=int, default="1000", help="number of packet", required=True) - parser.add_argument("-t", "--test", type=str, default="1", help="number of test", required=True) - args = parser.parse_args() - - log_files = [f"delayData/test{args.test}/ProtodelayA_PUB.log", f"delayData/test{args.test}/ProtodelayA_SUB.log", f"delayData/test{args.test}/ProtodelayB_SUB.log"] - dataframes = [] - dataerrorFlag = [] - for log_file in log_files: - df = pd.read_csv(log_file, delim_whitespace=True, header=None, names=["count", "time"]) - dataframes.append(df) - - # check if the number of lines is correct - dataerrorFlag.append(checkNumberofLines(df, log_file)) - - if all(dataerrorFlag) == False: - dataframes = filter_dataframes(dataframes) - - df_Proto_delayA_PUB, df_Proto_delayA_SUB, df_Proto_delayB_SUB = dataframes - - # print the resulting DataFrame - diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"] - df_Proto_delayA_PUB["time"] - df_Proto_delayB_SUB["time"])/1e9/2}) - - array_Proto = diff_Proto_df["Difftime"].to_numpy() - - avg_Proto = np.average(array_Proto) - - fig = plt.figure() - plt.plot(array_Proto, color="blue", label=f"Avg_delay: {avg_Proto}") - - plt.legend() - plt.xlabel("Number of messages") - plt.ylabel("Delay (s)") - plt.savefig(f"rtl/test{args.test}/test{args.test}.png", dpi=100) \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test1/test1_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test1/test1_results.csv new file mode 100644 index 0000000..5ada479 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test1/test1_results.csv @@ -0,0 +1,101 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.30976296273500004,0.39526879200000004,0.2509290035,0.30724675475,0.332769292375,0.284879588,0.3370657215 +,,,,,,0.25996154250000003 +,,,,,,0.3108239735 +,,,,,,0.361428287 +,,,,,,0.300435938 +,,,,,,0.3510468445 +,,,,,,0.2818834965 +,,,,,,0.3086288105 +,,,,,,0.327603858 +,,,,,,0.25841610200000004 +,,,,,,0.26900496 +,,,,,,0.295604397 +,,,,,,0.32271866000000005 +,,,,,,0.349376595 +,,,,,,0.272188156 +,,,,,,0.3227935825 +,,,,,,0.3498520325 +,,,,,,0.2807219205 +,,,,,,0.39526879200000004 +,,,,,,0.310050153 +,,,,,,0.360988857 +,,,,,,0.275805313 +,,,,,,0.3024068455 +,,,,,,0.3130440775 +,,,,,,0.3480636835 +,,,,,,0.2868549455 +,,,,,,0.3215078025 +,,,,,,0.3640835825 +,,,,,,0.294856614 +,,,,,,0.32145049150000005 +,,,,,,0.348060597 +,,,,,,0.27101110850000004 +,,,,,,0.2896587445 +,,,,,,0.32425855800000003 +,,,,,,0.34287513950000004 +,,,,,,0.2976951285 +,,,,,,0.33226568900000003 +,,,,,,0.28706304250000003 +,,,,,,0.3058278995 +,,,,,,0.32454682500000004 +,,,,,,0.2552753735 +,,,,,,0.28194940700000004 +,,,,,,0.3006317425 +,,,,,,0.34328895550000005 +,,,,,,0.282073404 +,,,,,,0.2851778835 +,,,,,,0.311785274 +,,,,,,0.34647118200000004 +,,,,,,0.26122507250000004 +,,,,,,0.303805096 +,,,,,,0.3464013495 +,,,,,,0.26128953 +,,,,,,0.336099005 +,,,,,,0.2509290035 +,,,,,,0.261564304 +,,,,,,0.29618680950000004 +,,,,,,0.3312175745 +,,,,,,0.254047185 +,,,,,,0.280673724 +,,,,,,0.29129507050000003 +,,,,,,0.3342801025 +,,,,,,0.2653381395 +,,,,,,0.2839847015 +,,,,,,0.326555692 +,,,,,,0.3451880225 +,,,,,,0.2839758975 +,,,,,,0.2868465885 +,,,,,,0.31354842250000003 +,,,,,,0.364561554 +,,,,,,0.29532207450000003 +,,,,,,0.330138455 +,,,,,,0.26907928350000004 +,,,,,,0.27998017550000004 +,,,,,,0.28270974800000004 +,,,,,,0.3173032015 +,,,,,,0.34385166250000004 +,,,,,,0.29109406050000003 +,,,,,,0.325756343 +,,,,,,0.3044465825 +,,,,,,0.323116334 +,,,,,,0.34220284700000003 +,,,,,,0.2729449175 +,,,,,,0.2915913335 +,,,,,,0.31022830500000004 +,,,,,,0.36122028850000004 +,,,,,,0.299970644 +,,,,,,0.31862376750000004 +,,,,,,0.3372327445 +,,,,,,0.28394337350000004 +,,,,,,0.294588359 +,,,,,,0.30519071200000003 +,,,,,,0.32391128700000005 +,,,,,,0.350568784 +,,,,,,0.297265508 +,,,,,,0.32391432800000003 +,,,,,,0.35868752550000005 +,,,,,,0.2974453815 +,,,,,,0.3240752685 +,,,,,,0.35116344600000005 +,,,,,,0.305864699 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test10/test10_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test10/test10_results.csv new file mode 100644 index 0000000..7db88f9 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test10/test10_results.csv @@ -0,0 +1,37 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.29867755701390625,0.3398354945002211,0.25738346350010494,0.29919773474986755,0.31405190737513067,0.2844705463749051,0.30371984350034614 +,,,,,,0.28668684899980695 +,,,,,,0.31187802099975676 +,,,,,,0.3398354945002211 +,,,,,,0.25921109300003314 +,,,,,,0.283029530499789 +,,,,,,0.33861406250002807 +,,,,,,0.26536976600004897 +,,,,,,0.281906224000295 +,,,,,,0.29405458299993376 +,,,,,,0.2849508849999438 +,,,,,,0.2930013540001824 +,,,,,,0.31125166650002717 +,,,,,,0.2616075259999775 +,,,,,,0.28666294249961766 +,,,,,,0.3146679164999569 +,,,,,,0.2991985419999424 +,,,,,,0.3267591919997131 +,,,,,,0.3139895830001933 +,,,,,,0.3012621094999872 +,,,,,,0.31252317700017335 +,,,,,,0.3350127600000974 +,,,,,,0.29919692749979276 +,,,,,,0.3257529424998325 +,,,,,,0.2669461454997873 +,,,,,,0.28617833350006094 +,,,,,,0.27890070299997666 +,,,,,,0.3309866399999919 +,,,,,,0.262811536000072 +,,,,,,0.314620077999507 +,,,,,,0.3072277344999748 +,,,,,,0.31423888049994275 +,,,,,,0.29872031300033086 +,,,,,,0.31155752600056985 +,,,,,,0.29267770800061044 +,,,,,,0.25738346350010494 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test11/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test11/expirement new file mode 100644 index 0000000..56571f6 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test11/expirement @@ -0,0 +1,31 @@ +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor +20m no mortor + diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test11/test11_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test11/test11_results.csv new file mode 100644 index 0000000..aa0e2d3 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test11/test11_results.csv @@ -0,0 +1,101 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.3145421386650001,0.44057050449994417,0.25659932949995856,0.31159701475010504,0.3366758539999794,0.2852868028749497,0.3000995104999955 +,,,,,,0.3250837990000676 +,,,,,,0.25864323499997854 +,,,,,,0.3171637555000492 +,,,,,,0.3367109240000828 +,,,,,,0.28666798949984823 +,,,,,,0.30906450650012085 +,,,,,,0.3354888365000429 +,,,,,,0.2786526844999827 +,,,,,,0.29531560850018557 +,,,,,,0.3205018404998598 +,,,,,,0.34235568949988804 +,,,,,,0.27033982199999174 +,,,,,,0.29113744249992046 +,,,,,,0.3052593689999847 +,,,,,,0.3732496114999988 +,,,,,,0.39576621700007447 +,,,,,,0.3579374674999888 +,,,,,,0.283133523000014 +,,,,,,0.3223377755000467 +,,,,,,0.33500935599994397 +,,,,,,0.2699295230000489 +,,,,,,0.2987383784998901 +,,,,,,0.3366641639999449 +,,,,,,0.2700884265000939 +,,,,,,0.29684825649997676 +,,,,,,0.38865336699995673 +,,,,,,0.3366302060000519 +,,,,,,0.27835497749988364 +,,,,,,0.33776938299997084 +,,,,,,0.26833209399984254 +,,,,,,0.3362890550000168 +,,,,,,0.26679135550015604 +,,,,,,0.2779334989998916 +,,,,,,0.3100883085001104 +,,,,,,0.3466361035000118 +,,,,,,0.35846202549990835 +,,,,,,0.3294029355000265 +,,,,,,0.26848046500002926 +,,,,,,0.2882278620000339 +,,,,,,0.32043199199992023 +,,,,,,0.3443391280000027 +,,,,,,0.2693801800000837 +,,,,,,0.2932466500000818 +,,,,,,0.375052960500071 +,,,,,,0.32101286999996825 +,,,,,,0.36712533750003623 +,,,,,,0.3273494089997977 +,,,,,,0.27335696999987547 +,,,,,,0.3480982999999799 +,,,,,,0.33985845849993984 +,,,,,,0.28586824800014415 +,,,,,,0.30417948399994094 +,,,,,,0.39225281899989495 +,,,,,,0.3256434765000813 +,,,,,,0.27143491350007426 +,,,,,,0.28416648700007385 +,,,,,,0.31058234450001193 +,,,,,,0.32331958650015885 +,,,,,,0.2693260804999769 +,,,,,,0.3109555240001181 +,,,,,,0.3416354195000773 +,,,,,,0.3172891734998531 +,,,,,,0.35495614850005147 +,,,,,,0.30490289749989474 +,,,,,,0.3370032199998746 +,,,,,,0.28801811149999884 +,,,,,,0.32167746549991005 +,,,,,,0.3481465885000914 +,,,,,,0.36045337999998694 +,,,,,,0.29657900950001326 +,,,,,,0.34411864899989725 +,,,,,,0.2621985015000903 +,,,,,,0.2748288649999925 +,,,,,,0.3000570870001479 +,,,,,,0.31395886650013805 +,,,,,,0.3739693129998637 +,,,,,,0.30444043000004584 +,,,,,,0.33119646250008156 +,,,,,,0.2589335749999923 +,,,,,,0.2856602414999083 +,,,,,,0.3066502615000406 +,,,,,,0.3718737979999465 +,,,,,,0.33584820449993835 +,,,,,,0.26514426450014517 +,,,,,,0.44057050449994417 +,,,,,,0.2807695614999133 +,,,,,,0.3122385055000919 +,,,,,,0.33468505349998473 +,,,,,,0.31084038199994657 +,,,,,,0.326086964500007 +,,,,,,0.25659932949995856 +,,,,,,0.27900226799992955 +,,,,,,0.3064759999999294 +,,,,,,0.3506051215001733 +,,,,,,0.2839894974999475 +,,,,,,0.2949448059998617 +,,,,,,0.3202655720000963 +,,,,,,0.32455648800012077 +,,,,,,0.27182331099998414 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test12/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test12/expirement new file mode 100644 index 0000000..b1826f2 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test12/expirement @@ -0,0 +1 @@ +20m yes mortor diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test12/test12_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test12/test12_results.csv new file mode 100644 index 0000000..4eb956d --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test12/test12_results.csv @@ -0,0 +1,70 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.3138388711883989,0.48722599450002385,0.2511386775000472,0.31425199099996165,0.33250181349998864,0.2835231785000978,0.2915518284999607 +,,,,,,0.3501644214998404 +,,,,,,0.2792425374999791 +,,,,,,0.31425199099996165 +,,,,,,0.32967311099996366 +,,,,,,0.27438045049982274 +,,,,,,0.29558773300002833 +,,,,,,0.3225477795000403 +,,,,,,0.3449351915001479 +,,,,,,0.2685424480001796 +,,,,,,0.2926455854998464 +,,,,,,0.32204843550011286 +,,,,,,0.3758602410000456 +,,,,,,0.3259740395001258 +,,,,,,0.26071585699990835 +,,,,,,0.2884887224999487 +,,,,,,0.32903580949984 +,,,,,,0.2511386775000472 +,,,,,,0.2751346595000026 +,,,,,,0.2835231785000978 +,,,,,,0.3145483825001926 +,,,,,,0.3753681790000186 +,,,,,,0.3632630939998563 +,,,,,,0.3007044515000081 +,,,,,,0.307884831500086 +,,,,,,0.3276928974998863 +,,,,,,0.3080828335001836 +,,,,,,0.48722599450002385 +,,,,,,0.3429603644998175 +,,,,,,0.2791557865000003 +,,,,,,0.3265690609999692 +,,,,,,0.40795502199995054 +,,,,,,0.3878645330000058 +,,,,,,0.33250181349998864 +,,,,,,0.26331145800014866 +,,,,,,0.288544874500003 +,,,,,,0.3368632600000639 +,,,,,,0.26831395550003595 +,,,,,,0.3061088305000648 +,,,,,,0.3302675185000344 +,,,,,,0.2653785734998925 +,,,,,,0.29629586649997985 +,,,,,,0.3137284314999203 +,,,,,,0.33745691949990747 +,,,,,,0.27792155649995376 +,,,,,,0.31426379649988345 +,,,,,,0.3367937634999816 +,,,,,,0.2914350635001147 +,,,,,,0.30566331699992194 +,,,,,,0.34504751499986497 +,,,,,,0.2744187015001712 +,,,,,,0.2758409279999015 +,,,,,,0.309582223000119 +,,,,,,0.3459849984998869 +,,,,,,0.2822199664999899 +,,,,,,0.32304670549987774 +,,,,,,0.3400282555000073 +,,,,,,0.28469106299992997 +,,,,,,0.33065434150006495 +,,,,,,0.2599466370000123 +,,,,,,0.28222068949982093 +,,,,,,0.31997840699982394 +,,,,,,0.33538494950019454 +,,,,,,0.27578590700019673 +,,,,,,0.3147187155000595 +,,,,,,0.320923290999979 +,,,,,,0.29351164250003975 +,,,,,,0.3175153294999591 +,,,,,,0.35381471799983605 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test13/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test13/expirement new file mode 100644 index 0000000..c6903bf --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test13/expirement @@ -0,0 +1 @@ +100m no mortor diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test13/test13_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test13/test13_results.csv new file mode 100644 index 0000000..09b0e33 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test13/test13_results.csv @@ -0,0 +1,99 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.30476996346939306,0.397320166500196,0.2397751854996824,0.3043341322499752,0.33067990312497253,0.2779417647499721,0.30585249049990854 +,,,,,,0.34051636800015567 +,,,,,,0.3420044634999946 +,,,,,,0.2662984384998488 +,,,,,,0.26977851200003083 +,,,,,,0.29121434499990967 +,,,,,,0.34656478350008285 +,,,,,,0.2734580030001728 +,,,,,,0.292243226000158 +,,,,,,0.33873283100019663 +,,,,,,0.2743582185001004 +,,,,,,0.3025491455002013 +,,,,,,0.32330861800028426 +,,,,,,0.33657710900007753 +,,,,,,0.2629403220001678 +,,,,,,0.2928445170001667 +,,,,,,0.3246860889997186 +,,,,,,0.24434331049970806 +,,,,,,0.2653830139998983 +,,,,,,0.29203623599994305 +,,,,,,0.3142668240000003 +,,,,,,0.3524430489996302 +,,,,,,0.2760213584997802 +,,,,,,0.2859814615003321 +,,,,,,0.3790968895000767 +,,,,,,0.3164998510001183 +,,,,,,0.397320166500196 +,,,,,,0.33567550900017085 +,,,,,,0.2639980059998814 +,,,,,,0.2934378495000465 +,,,,,,0.3370386104998787 +,,,,,,0.25725782699980826 +,,,,,,0.3021760974999981 +,,,,,,0.35201679150004467 +,,,,,,0.28121240749988036 +,,,,,,0.3052591304998264 +,,,,,,0.34845830600002276 +,,,,,,0.27933905299974177 +,,,,,,0.3067220730000957 +,,,,,,0.3358447794997048 +,,,,,,0.2583002785000707 +,,,,,,0.2945614519998208 +,,,,,,0.3240583484999292 +,,,,,,0.24744616400021513 +,,,,,,0.35560072549991106 +,,,,,,0.29490775649993617 +,,,,,,0.3099888655001674 +,,,,,,0.33654117099974523 +,,,,,,0.2645562625001488 +,,,,,,0.31755291149991566 +,,,,,,0.35666436149992176 +,,,,,,0.2981059884998729 +,,,,,,0.3433135205002136 +,,,,,,0.279220934000172 +,,,,,,0.312914174500188 +,,,,,,0.33140280199989475 +,,,,,,0.27124494250028997 +,,,,,,0.28085174800020757 +,,,,,,0.3184080625000916 +,,,,,,0.34444570349965076 +,,,,,,0.2760879329997884 +,,,,,,0.29216469449985266 +,,,,,,0.3610121639999534 +,,,,,,0.3034091340001239 +,,,,,,0.3285112065002058 +,,,,,,0.2615239940001156 +,,,,,,0.3033736445002783 +,,,,,,0.32708287999962327 +,,,,,,0.25672114549986097 +,,,,,,0.32393023199976606 +,,,,,,0.24974482949996055 +,,,,,,0.2580413980001343 +,,,,,,0.27751537499990553 +,,,,,,0.29419969799990464 +,,,,,,0.3065355819998723 +,,,,,,0.324149517500046 +,,,,,,0.2397751854996824 +,,,,,,0.2573908764999721 +,,,,,,0.30030731800011395 +,,,,,,0.33492586649959516 +,,,,,,0.2810359855001874 +,,,,,,0.3064807100001305 +,,,,,,0.32221297949976224 +,,,,,,0.35334548950024525 +,,,,,,0.2741300715001368 +,,,,,,0.28756790099978097 +,,,,,,0.3194696369999118 +,,,,,,0.3429251204999771 +,,,,,,0.2614751840003529 +,,,,,,0.2872851784999058 +,,,,,,0.3275814020004231 +,,,,,,0.32684058000003857 +,,,,,,0.3360995389998513 +,,,,,,0.26071733699974436 +,,,,,,0.2818183520003227 +,,,,,,0.31307877400030293 +,,,,,,0.32270233450023306 +,,,,,,0.34044491600013627 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test14/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test14/expirement new file mode 100644 index 0000000..36dbe4f --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test14/expirement @@ -0,0 +1 @@ +100m yes mortor diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test14/test14_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test14/test14_results.csv new file mode 100644 index 0000000..7b1b8bd --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test14/test14_results.csv @@ -0,0 +1,92 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.3075101054120719,0.3678299765000672,0.24515639449986876,0.30609522649988363,0.32796939200000985,0.2856427007500486,0.3282273259998773 +,,,,,,0.24515639449986876 +,,,,,,0.3252352725000167 +,,,,,,0.2641684514999123 +,,,,,,0.30150625949989723 +,,,,,,0.31003805200001466 +,,,,,,0.33706586150002993 +,,,,,,0.27330031749992134 +,,,,,,0.306963316999934 +,,,,,,0.30121282199999977 +,,,,,,0.3633351144999654 +,,,,,,0.2932212199998516 +,,,,,,0.35122063350032023 +,,,,,,0.26931052100011255 +,,,,,,0.30394927300022007 +,,,,,,0.34119010200002414 +,,,,,,0.285937347000327 +,,,,,,0.31504413950007215 +,,,,,,0.35672325100016145 +,,,,,,0.29354529299959414 +,,,,,,0.3029978520003605 +,,,,,,0.3227643000001875 +,,,,,,0.2881602229998622 +,,,,,,0.3216700664996236 +,,,,,,0.3427831039997487 +,,,,,,0.27789913150010964 +,,,,,,0.2942575590000172 +,,,,,,0.315237090000063 +,,,,,,0.337491893499848 +,,,,,,0.2654714220001204 +,,,,,,0.2807612734999854 +,,,,,,0.30609522649988363 +,,,,,,0.36276240100035195 +,,,,,,0.30297284499986044 +,,,,,,0.34905434699966015 +,,,,,,0.27700835249999295 +,,,,,,0.30173410799972333 +,,,,,,0.3179748605001247 +,,,,,,0.3432310809999605 +,,,,,,0.26524427300010384 +,,,,,,0.35101242199976684 +,,,,,,0.26227293450018385 +,,,,,,0.29014741950004586 +,,,,,,0.29545053050038156 +,,,,,,0.32473597599995735 +,,,,,,0.29164776350012955 +,,,,,,0.3096694975000977 +,,,,,,0.32627572149990786 +,,,,,,0.3109397029999528 +,,,,,,0.3333001185002688 +,,,,,,0.26534030499986155 +,,,,,,0.28534805449977024 +,,,,,,0.27534422049991136 +,,,,,,0.29426076649974287 +,,,,,,0.3164178759999815 +,,,,,,0.3678299765000672 +,,,,,,0.29973068850000295 +,,,,,,0.3234909164998617 +,,,,,,0.3515447820001262 +,,,,,,0.3597433069998865 +,,,,,,0.29883578150028767 +,,,,,,0.3300691850001165 +,,,,,,0.25360078650014456 +,,,,,,0.27857686449997904 +,,,,,,0.3178588619996458 +,,,,,,0.3286468379999154 +,,,,,,0.24979910100013614 +,,,,,,0.2748903534999417 +,,,,,,0.2851240339997545 +,,,,,,0.3277114580001424 +,,,,,,0.26000746299997735 +,,,,,,0.2753994415000024 +,,,,,,0.3199216520000287 +,,,,,,0.34104052899978454 +,,,,,,0.2736965345000744 +,,,,,,0.2913094459997718 +,,,,,,0.3096245724999654 +,,,,,,0.316608960000184 +,,,,,,0.3458701649998203 +,,,,,,0.27352580850000124 +,,,,,,0.28746270299966264 +,,,,,,0.29149279800004774 +,,,,,,0.3188933000000014 +,,,,,,0.35343323800011844 +,,,,,,0.2801015919997587 +,,,,,,0.3019473035000769 +,,,,,,0.32002433600007296 +,,,,,,0.36044847449975903 +,,,,,,0.2967176044997394 +,,,,,,0.31170709900016064 +,,,,,,0.3326479504998634 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test15/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test15/expirement new file mode 100644 index 0000000..3ded34f --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test15/expirement @@ -0,0 +1,2 @@ +in door rtl normal +look with test16 \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test15/test15_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test15/test15_results.csv new file mode 100644 index 0000000..5b9335f --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test15/test15_results.csv @@ -0,0 +1,101 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.2776858300308735,0.35837612774594013,0.22187300625048617,0.27681682544798836,0.2972554344005853,0.25413339915016475,0.3133647679512868 +,,,,,,0.24451650765385916 +,,,,,,0.2836427539545892 +,,,,,,0.31522808745048053 +,,,,,,0.24607158344995225 +,,,,,,0.26341183440438704 +,,,,,,0.2734015850960686 +,,,,,,0.283696609054462 +,,,,,,0.31525870095332154 +,,,,,,0.253281734100068 +,,,,,,0.31375810530156145 +,,,,,,0.2590147709997229 +,,,,,,0.2761550945945881 +,,,,,,0.30061618605204266 +,,,,,,0.23863822920214073 +,,,,,,0.24873030900208637 +,,,,,,0.28040660820367064 +,,,,,,0.28322996805245554 +,,,,,,0.3149238073505869 +,,,,,,0.2458579122034575 +,,,,,,0.27028932885532064 +,,,,,,0.2879714879961767 +,,,,,,0.298081543955167 +,,,,,,0.22187300625048617 +,,,,,,0.23913152730466458 +,,,,,,0.2635086136532184 +,,,,,,0.29516572485437287 +,,,,,,0.32686116299452794 +,,,,,,0.257767778249327 +,,,,,,0.28215662985183226 +,,,,,,0.29219050664984864 +,,,,,,0.30979713419728155 +,,,,,,0.3054552151480117 +,,,,,,0.22916458980217275 +,,,,,,0.2536337277006912 +,,,,,,0.2780324874044916 +,,,,,,0.2881019438974773 +,,,,,,0.3268697521496396 +,,,,,,0.26500397040377754 +,,,,,,0.2966123137506326 +,,,,,,0.22751842230431824 +,,,,,,0.26639109225224783 +,,,,,,0.2908046686521298 +,,,,,,0.35837612774594013 +,,,,,,0.29698006454905806 +,,,,,,0.242311045947695 +,,,,,,0.27390554234720405 +,,,,,,0.29122388864634513 +,,,,,,0.3300330140972752 +,,,,,,0.27540176084753465 +,,,,,,0.29261980620011896 +,,,,,,0.23105648520264582 +,,,,,,0.26266265595361193 +,,,,,,0.28716973739961216 +,,,,,,0.31167681300215094 +,,,,,,0.2497603648499245 +,,,,,,0.2597494531500197 +,,,,,,0.313077733649824 +,,,,,,0.24438617460073098 +,,,,,,0.2760146140518622 +,,,,,,0.3005318902499665 +,,,,,,0.23861830004937748 +,,,,,,0.24868048140227986 +,,,,,,0.25871520284949734 +,,,,,,0.2759344582553651 +,,,,,,0.29323659419560444 +,,,,,,0.32490362475010026 +,,,,,,0.2702130579034932 +,,,,,,0.3161834221493183 +,,,,,,0.25429995629998925 +,,,,,,0.27158249834896425 +,,,,,,0.28881086175430026 +,,,,,,0.306089181899001 +,,,,,,0.25136672219733647 +,,,,,,0.2688757933481373 +,,,,,,0.30768002234587843 +,,,,,,0.23857782975441724 +,,,,,,0.2774785563013887 +,,,,,,0.2875092038972731 +,,,,,,0.3119345230523623 +,,,,,,0.2500790309989724 +,,,,,,0.2894061577500213 +,,,,,,0.3138568461009828 +,,,,,,0.23754899789775585 +,,,,,,0.26914514310157683 +,,,,,,0.2792403607487152 +,,,,,,0.28931753294874485 +,,,,,,0.31376994704966854 +,,,,,,0.25184723579579404 +,,,,,,0.2619134437506011 +,,,,,,0.3079610819998237 +,,,,,,0.23877544544727378 +,,,,,,0.26328114809803244 +,,,,,,0.2877487159494623 +,,,,,,0.2981516143507966 +,,,,,,0.24338772134710945 +,,,,,,0.2751143318999466 +,,,,,,0.2923674484453964 +,,,,,,0.23756791590170803 +,,,,,,0.2548876369507636 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test16/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test16/expirement new file mode 100644 index 0000000..22d78e3 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test16/expirement @@ -0,0 +1,5 @@ +frequence 10 +in door +a pub b rev + +ProtodelayB_SUB not doing anything \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test16/test16_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test16/test16_results.csv new file mode 100644 index 0000000..f996774 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test16/test16_results.csv @@ -0,0 +1,47 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.3193356797817852,0.38412229900131933,0.24903364600322675,0.32260947049508104,0.34374222199767246,0.29429900249670027,0.30032102100085467 +,,,,,,0.30749789900437463 +,,,,,,0.3305877670063637 +,,,,,,0.321681458997773 +,,,,,,0.3449881859996822 +,,,,,,0.38412229900131933 +,,,,,,0.2905824219924398 +,,,,,,0.32957901299232617 +,,,,,,0.36861253299866803 +,,,,,,0.32316280899976846 +,,,,,,0.34611682100512553 +,,,,,,0.36934387299697846 +,,,,,,0.27593392199196387 +,,,,,,0.2989402999955928 +,,,,,,0.3220561319903936 +,,,,,,0.3291786170011619 +,,,,,,0.3521194019995164 +,,,,,,0.3431675780011574 +,,,,,,0.28181016199232545 +,,,,,,0.30479420800111257 +,,,,,,0.3439337699965108 +,,,,,,0.36692165199201554 +,,,,,,0.2896478879993083 +,,,,,,0.29674266499932855 +,,,,,,0.35165232299186755 +,,,,,,0.34297056499053724 +,,,,,,0.3500907159905182 +,,,,,,0.2568668199965032 +,,,,,,0.29581314299139194 +,,,,,,0.3350100750103593 +,,,,,,0.3421176420088159 +,,,,,,0.24903364600322675 +,,,,,,0.256362023006659 +,,,,,,0.27944325499993283 +,,,,,,0.2865948969993042 +,,,,,,0.2937942889984697 +,,,,,,0.31687865500862245 +,,,,,,0.32398472099157516 +,,,,,,0.36326008799369447 +,,,,,,0.28602842800319195 +,,,,,,0.30925119400490075 +,,,,,,0.3323240300087491 +,,,,,,0.3394543699978385 +,,,,,,0.3626875170011772 +,,,,,,0.2854063300037524 +,,,,,,0.30857414500496816 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test17/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test17/expirement new file mode 100644 index 0000000..f1ed97f --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test17/expirement @@ -0,0 +1,5 @@ +frequence 1 +in door +a pub b rev + +ProtodelayB_SUB not doing anything \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test17/test17_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test17/test17_results.csv new file mode 100644 index 0000000..541fcdf --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test17/test17_results.csv @@ -0,0 +1,100 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.26710674960537806,0.4180509180005174,0.15881559600529727,0.2744795049948152,0.3185746314993594,0.21648206499958178,0.22023025499947835 +,,,,,,0.33979202099726535 +,,,,,,0.3127581540029496 +,,,,,,0.23953917899052612 +,,,,,,0.19781219599826727 +,,,,,,0.34815523300494533 +,,,,,,0.2744795049948152 +,,,,,,0.2166631019936176 +,,,,,,0.3509244349988876 +,,,,,,0.32525262799754273 +,,,,,,0.2835987949947594 +,,,,,,0.22606726099911612 +,,,,,,0.16836045100353658 +,,,,,,0.3033888149948325 +,,,,,,0.2776717889937572 +,,,,,,0.20396990200970322 +,,,,,,0.3380540209909668 +,,,,,,0.3122617769986391 +,,,,,,0.2544677940022666 +,,,,,,0.18070740399707574 +,,,,,,0.3310769590025302 +,,,,,,0.27327719300228637 +,,,,,,0.19943277999118436 +,,,,,,0.34985909100214485 +,,,,,,0.29209620399342384 +,,,,,,0.26676498500455637 +,,,,,,0.177825695995125 +,,,,,,0.2960704809956951 +,,,,,,0.2384907309897244 +,,,,,,0.21255296100571286 +,,,,,,0.31483143800869584 +,,,,,,0.28920072299661115 +,,,,,,0.23163192698848434 +,,,,,,0.17492366800433956 +,,,,,,0.4050638509943383 +,,,,,,0.34752041500178166 +,,,,,,0.28991855500498787 +,,,,,,0.21630102800554596 +,,,,,,0.17452787500224076 +,,,,,,0.3088583789940458 +,,,,,,0.23607336900022347 +,,,,,,0.1942344690032769 +,,,,,,0.34451449300104287 +,,,,,,0.30282979700132273 +,,,,,,0.24497208998946007 +,,,,,,0.1872415039979387 +,,,,,,0.3373037740093423 +,,,,,,0.2795769759977702 +,,,,,,0.2059520270122448 +,,,,,,0.3561658849939704 +,,,,,,0.298452338000061 +,,,,,,0.1990267479995964 +,,,,,,0.33325713699741755 +,,,,,,0.2755033029970946 +,,,,,,0.21793374499247875 +,,,,,,0.41609478399914224 +,,,,,,0.21443623899540398 +,,,,,,0.33266919500601944 +,,,,,,0.2750678890006384 +,,,,,,0.21720489200379234 +,,,,,,0.33558252498914953 +,,,,,,0.2778460869885748 +,,,,,,0.22009672899730504 +,,,,,,0.4180509180005174 +,,,,,,0.18459103201166727 +,,,,,,0.3347567099990556 +,,,,,,0.2771635779936332 +,,,,,,0.235345266002696 +,,,,,,0.19374758799676783 +,,,,,,0.344022158998996 +,,,,,,0.28628491899871733 +,,,,,,0.24460764099785592 +,,,,,,0.17099742099526338 +,,,,,,0.29010984500928316 +,,,,,,0.2326005439972505 +,,,,,,0.15881559600529727 +,,,,,,0.2930114579939982 +,,,,,,0.23538283299421892 +,,,,,,0.19380140501016285 +,,,,,,0.32820116900256835 +,,,,,,0.27135154900315683 +,,,,,,0.24562136600434314 +,,,,,,0.18795407099241856 +,,,,,,0.33819531300105155 +,,,,,,0.2806467890040949 +,,,,,,0.2389337839995278 +,,,,,,0.1973562899947865 +,,,,,,0.33231460899696685 +,,,,,,0.2747325969976373 +,,,,,,0.2332870219979668 +,,,,,,0.17561096300778445 +,,,,,,0.32578076599747874 +,,,,,,0.204188226009137 +,,,,,,0.3223178249900229 +,,,,,,0.28160892400774173 +,,,,,,0.25594054799876176 +,,,,,,0.19837098399875686 +,,,,,,0.3325473040022189 +,,,,,,0.25890354700095486 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test18/expirement b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test18/expirement new file mode 100644 index 0000000..f1ed97f --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test18/expirement @@ -0,0 +1,5 @@ +frequence 1 +in door +a pub b rev + +ProtodelayB_SUB not doing anything \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test18/test18_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test18/test18_results.csv new file mode 100644 index 0000000..b329200 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test18/test18_results.csv @@ -0,0 +1,101 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.26891603111915174,0.3695979709882522,0.16241655200428795,0.2690385724999942,0.3145663914947363,0.22046360800231923,0.21922807600640226 +,,,,,,0.3375254179991316 +,,,,,,0.26388535999285523 +,,,,,,0.2061374080076348 +,,,,,,0.3566158390021883 +,,,,,,0.3157380399934482 +,,,,,,0.2738540540012764 +,,,,,,0.20011305800289847 +,,,,,,0.3503828200045973 +,,,,,,0.29252136299328413 +,,,,,,0.2508834280015435 +,,,,,,0.19314817499252968 +,,,,,,0.3593450510088587 +,,,,,,0.33357871299085673 +,,,,,,0.2757891179935541 +,,,,,,0.21903057000599802 +,,,,,,0.3693495420011459 +,,,,,,0.327609540996491 +,,,,,,0.28583529600291513 +,,,,,,0.22816613099712413 +,,,,,,0.34632798700476997 +,,,,,,0.28857987199444324 +,,,,,,0.26378051200299524 +,,,,,,0.23801095399539918 +,,,,,,0.3561517490015831 +,,,,,,0.3141758419951657 +,,,,,,0.25653997401241213 +,,,,,,0.21479730799910612 +,,,,,,0.3010108989983564 +,,,,,,0.27511676399444696 +,,,,,,0.20147321000695229 +,,,,,,0.3356285649933852 +,,,,,,0.2779237689974252 +,,,,,,0.22021893099008594 +,,,,,,0.1945626130036544 +,,,,,,0.32881571300094947 +,,,,,,0.3032113140070578 +,,,,,,0.2614634789933916 +,,,,,,0.18778016499709338 +,,,,,,0.3695979709882522 +,,,,,,0.2959481009893352 +,,,,,,0.22318110799824353 +,,,,,,0.18140974100970197 +,,,,,,0.29977544301073067 +,,,,,,0.2580137699987972 +,,,,,,0.21648533499683253 +,,,,,,0.31865503000153694 +,,,,,,0.26097884800401516 +,,,,,,0.22025554900756106 +,,,,,,0.16241655200428795 +,,,,,,0.3286752739950316 +,,,,,,0.2709597740031313 +,,,,,,0.2462570830102777 +,,,,,,0.22053296100057196 +,,,,,,0.3548219429940218 +,,,,,,0.3287617349997163 +,,,,,,0.25512398799764924 +,,,,,,0.19741505999991205 +,,,,,,0.347647335001966 +,,,,,,0.2738532410003245 +,,,,,,0.24820703199657146 +,,,,,,0.1745160809950903 +,,,,,,0.3406476300006034 +,,,,,,0.2989973710064078 +,,,,,,0.25732510699890554 +,,,,,,0.24845301298773848 +,,,,,,0.17471294300048612 +,,,,,,0.3089170059975004 +,,,,,,0.26711737099685706 +,,,,,,0.19358456799818669 +,,,,,,0.35981563800305594 +,,,,,,0.28614185100013856 +,,,,,,0.24439777299994603 +,,,,,,0.1706654029985657 +,,,,,,0.288855621998664 +,,,,,,0.24815589800709859 +,,,,,,0.19046259998867754 +,,,,,,0.3246372099965811 +,,,,,,0.2828545460070018 +,,,,,,0.2250809899996966 +,,,,,,0.34332966098736506 +,,,,,,0.28563636798935477 +,,,,,,0.21201038498838898 +,,,,,,0.34625204499752726 +,,,,,,0.2884094309993088 +,,,,,,0.23191931999463122 +,,,,,,0.19012726399523672 +,,,,,,0.3083762949972879 +,,,,,,0.26675973398960195 +,,,,,,0.19299512899306137 +,,,,,,0.3272362390125636 +,,,,,,0.28557158399780747 +,,,,,,0.22878114601189736 +,,,,,,0.1712690290005412 +,,,,,,0.3055416910065105 +,,,,,,0.2637359399959678 +,,,,,,0.2061305589886615 +,,,,,,0.34037725599773694 +,,,,,,0.2826929799921345 +,,,,,,0.22583294000651222 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test19/test19_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test19/test19_results.csv new file mode 100644 index 0000000..41ad37f --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test19/test19_results.csv @@ -0,0 +1,84 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.288240135566532,0.433768893009983,0.15631304601265583,0.29496914500487037,0.3308535714968457,0.24911940700258128,0.3236479949991917 +,,,,,,0.3312107749952702 +,,,,,,0.3544855149957584 +,,,,,,0.3533469120011432 +,,,,,,0.3520583500067005 +,,,,,,0.3435833520052256 +,,,,,,0.3582499930053018 +,,,,,,0.18109747300331946 +,,,,,,0.18858838600863237 +,,,,,,0.2281600850110408 +,,,,,,0.267548842006363 +,,,,,,0.2747269000101369 +,,,,,,0.2983735500019975 +,,,,,,0.3057969950023107 +,,,,,,0.31340743899636436 +,,,,,,0.3526745560084237 +,,,,,,0.360071301998687 +,,,,,,0.19910132999939378 +,,,,,,0.23840109999582637 +,,,,,,0.2618564550066367 +,,,,,,0.22864769799343776 +,,,,,,0.23603865699260496 +,,,,,,0.25953236399800517 +,,,,,,0.2669317740073893 +,,,,,,0.2741976140096085 +,,,,,,0.313581341993995 +,,,,,,0.353062977999798 +,,,,,,0.36784560699015856 +,,,,,,0.17486542300321162 +,,,,,,0.18221030800486915 +,,,,,,0.3017153670080006 +,,,,,,0.32519648601009976 +,,,,,,0.34872738999547437 +,,,,,,0.2835712939995574 +,,,,,,0.3230256179958815 +,,,,,,0.3304963679984212 +,,,,,,0.3218695289979223 +,,,,,,0.3453741449920926 +,,,,,,0.36014357800013386 +,,,,,,0.27054303500335664 +,,,,,,0.2940825109981233 +,,,,,,0.33342532999813557 +,,,,,,0.3248834789992543 +,,,,,,0.3963253080000868 +,,,,,,0.21937232499476522 +,,,,,,0.22677738798665814 +,,,,,,0.25038479700742755 +,,,,,,0.2739310119941365 +,,,,,,0.313271902006818 +,,,,,,0.3208384710014798 +,,,,,,0.3602586239867378 +,,,,,,0.36767323200183455 +,,,,,,0.17486616100359242 +,,,,,,0.1823795280070044 +,,,,,,0.2058209129900206 +,,,,,,0.21312593700713478 +,,,,,,0.25248600100167096 +,,,,,,0.2599703689920716 +,,,,,,0.26735926599940285 +,,,,,,0.29078732199559454 +,,,,,,0.314230639996822 +,,,,,,0.433768893009983 +,,,,,,0.25669903800007887 +,,,,,,0.264111333002802 +,,,,,,0.28762751100293826 +,,,,,,0.29496914500487037 +,,,,,,0.31853754199983086 +,,,,,,0.32593154700589366 +,,,,,,0.34940286599157844 +,,,,,,0.15631304601265583 +,,,,,,0.2117851250077365 +,,,,,,0.21909300399420317 +,,,,,,0.22643281500495505 +,,,,,,0.2818578639999032 +,,,,,,0.32130477399914525 +,,,,,,0.34475879099045414 +,,,,,,0.24785401699773502 +,,,,,,0.23932036699261516 +,,,,,,0.27869974699569866 +,,,,,,0.30217043599986937 +,,,,,,0.30956279998645186 +,,,,,,0.3328556230117101 +,,,,,,0.32466057199053466 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test2/test2_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test2/test2_results.csv new file mode 100644 index 0000000..fe57d46 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test2/test2_results.csv @@ -0,0 +1,101 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.30515217821499996,0.36551078950000004,0.250522887,0.3001209865,0.3310982175,0.28126953275000005,0.30808827050000004 +,,,,,,0.334858156 +,,,,,,0.28150677100000004 +,,,,,,0.300141592 +,,,,,,0.3188570155 +,,,,,,0.35384370750000005 +,,,,,,0.284588854 +,,,,,,0.295204411 +,,,,,,0.31387844600000003 +,,,,,,0.3409949715 +,,,,,,0.287772087 +,,,,,,0.314447523 +,,,,,,0.3330585535 +,,,,,,0.263849214 +,,,,,,0.290393618 +,,,,,,0.309081596 +,,,,,,0.3437783975 +,,,,,,0.26653879350000004 +,,,,,,0.2931590355 +,,,,,,0.32782916650000005 +,,,,,,0.33851147200000004 +,,,,,,0.27729164 +,,,,,,0.2959141845 +,,,,,,0.32252103000000004 +,,,,,,0.3411534385 +,,,,,,0.2719317115 +,,,,,,0.29084894250000004 +,,,,,,0.309845289 +,,,,,,0.3205230905 +,,,,,,0.3311611995 +,,,,,,0.253958752 +,,,,,,0.27255771700000003 +,,,,,,0.29915158550000004 +,,,,,,0.32578111800000004 +,,,,,,0.344477729 +,,,,,,0.28319734550000003 +,,,,,,0.34982189500000005 +,,,,,,0.280557818 +,,,,,,0.29135322 +,,,,,,0.29399152450000005 +,,,,,,0.312509611 +,,,,,,0.3310772235 +,,,,,,0.261884973 +,,,,,,0.27253969250000004 +,,,,,,0.29165714800000003 +,,,,,,0.31024690650000003 +,,,,,,0.3528484995 +,,,,,,0.267618054 +,,,,,,0.2782725655 +,,,,,,0.27768759400000004 +,,,,,,0.259653087 +,,,,,,0.2782910135 +,,,,,,0.336905793 +,,,,,,0.275765607 +,,,,,,0.33435417700000003 +,,,,,,0.26517258850000003 +,,,,,,0.291812511 +,,,,,,0.31043545850000004 +,,,,,,0.33745600200000003 +,,,,,,0.2762724485 +,,,,,,0.294879182 +,,,,,,0.313475532 +,,,,,,0.3246063555 +,,,,,,0.35119724700000005 +,,,,,,0.26599222100000003 +,,,,,,0.3404833715 +,,,,,,0.26372275850000004 +,,,,,,0.2983531465 +,,,,,,0.34892111000000003 +,,,,,,0.271704108 +,,,,,,0.2983369695 +,,,,,,0.3090512345 +,,,,,,0.3356056335 +,,,,,,0.250522887 +,,,,,,0.29316792750000004 +,,,,,,0.31188799450000004 +,,,,,,0.33846036500000004 +,,,,,,0.261225798 +,,,,,,0.29596513700000004 +,,,,,,0.32263756250000003 +,,,,,,0.341515844 +,,,,,,0.28026999550000004 +,,,,,,0.2909682725 +,,,,,,0.36551078950000004 +,,,,,,0.304382516 +,,,,,,0.3550732795 +,,,,,,0.29392755600000003 +,,,,,,0.320698152 +,,,,,,0.363321157 +,,,,,,0.2940030315 +,,,,,,0.3125924115 +,,,,,,0.3395750025 +,,,,,,0.2944132405 +,,,,,,0.313086413 +,,,,,,0.3317134625 +,,,,,,0.25485783500000003 +,,,,,,0.2974480215 +,,,,,,0.300100381 +,,,,,,0.3267166085 +,,,,,,0.2659654755 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test3/test3_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test3/test3_results.csv new file mode 100644 index 0000000..57fe0f0 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test3/test3_results.csv @@ -0,0 +1,101 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.30503493694,0.384546284,0.24696725400000002,0.30497794525,0.328068966125,0.278847438625,0.28689311500000003 +,,,,,,0.2979799275 +,,,,,,0.3249276125 +,,,,,,0.2476889525 +,,,,,,0.2587471595 +,,,,,,0.285410783 +,,,,,,0.31196250200000003 +,,,,,,0.3306992845 +,,,,,,0.285764248 +,,,,,,0.3283873035 +,,,,,,0.2592032775 +,,,,,,0.29409246050000004 +,,,,,,0.31288460700000004 +,,,,,,0.34755281050000003 +,,,,,,0.262301506 +,,,,,,0.31287675200000004 +,,,,,,0.34787066250000004 +,,,,,,0.286621091 +,,,,,,0.305318867 +,,,,,,0.33194464500000004 +,,,,,,0.27913713 +,,,,,,0.31375837300000003 +,,,,,,0.3324166955 +,,,,,,0.263228312 +,,,,,,0.2982067765 +,,,,,,0.3013670305 +,,,,,,0.32009331900000004 +,,,,,,0.36265533600000005 +,,,,,,0.325447117 +,,,,,,0.384546284 +,,,,,,0.37126964300000004 +,,,,,,0.32596005 +,,,,,,0.26478413700000003 +,,,,,,0.2838158575 +,,,,,,0.31051272550000003 +,,,,,,0.32131485000000004 +,,,,,,0.33987815250000003 +,,,,,,0.24696725400000002 +,,,,,,0.281547624 +,,,,,,0.33217412350000003 +,,,,,,0.254943978 +,,,,,,0.28190078550000003 +,,,,,,0.308572248 +,,,,,,0.31924723050000003 +,,,,,,0.3379251675 +,,,,,,0.27706113050000003 +,,,,,,0.287712387 +,,,,,,0.29842598550000005 +,,,,,,0.309047163 +,,,,,,0.3280472105 +,,,,,,0.26679071800000004 +,,,,,,0.30145301 +,,,,,,0.328134233 +,,,,,,0.267396087 +,,,,,,0.2779783645 +,,,,,,0.3046370235 +,,,,,,0.3153869575 +,,,,,,0.35036538650000004 +,,,,,,0.27312149550000003 +,,,,,,0.291758157 +,,,,,,0.310328737 +,,,,,,0.369208967 +,,,,,,0.2999587175 +,,,,,,0.32664027900000003 +,,,,,,0.37725743500000003 +,,,,,,0.31635754600000004 +,,,,,,0.3429500245 +,,,,,,0.273710512 +,,,,,,0.30038443200000003 +,,,,,,0.3274133615 +,,,,,,0.37013026450000003 +,,,,,,0.28496459 +,,,,,,0.3275877085 +,,,,,,0.25863297 +,,,,,,0.34114946100000004 +,,,,,,0.2719106545 +,,,,,,0.29058269200000003 +,,,,,,0.3255077095 +,,,,,,0.2563596595 +,,,,,,0.26700233100000004 +,,,,,,0.293667499 +,,,,,,0.3126435615 +,,,,,,0.3313081605 +,,,,,,0.27009346300000003 +,,,,,,0.328639457 +,,,,,,0.2677828585 +,,,,,,0.286387588 +,,,,,,0.29706195150000003 +,,,,,,0.3156515325 +,,,,,,0.34264103700000004 +,,,,,,0.2734065015 +,,,,,,0.3080357785 +,,,,,,0.3506475785 +,,,,,,0.27374613200000003 +,,,,,,0.3004226755 +,,,,,,0.3350121285 +,,,,,,0.257808237 +,,,,,,0.33270493900000003 +,,,,,,0.255552807 +,,,,,,0.27412868 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test7/test7_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test7/test7_results.csv new file mode 100644 index 0000000..f62194b --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test7/test7_results.csv @@ -0,0 +1,99 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.30278999399008766,0.35902231099862547,0.24346502699881967,0.3025529512497087,0.32425407525033734,0.2808276986252168,0.2928120180004044 +,,,,,,0.3178907814999548 +,,,,,,0.33454730850098713 +,,,,,,0.25966709250133135 +,,,,,,0.28059893150020804 +,,,,,,0.31564693949985667 +,,,,,,0.3282913095008553 +,,,,,,0.2589510635007173 +,,,,,,0.2785891295006877 +,,,,,,0.29256526900098834 +,,,,,,0.3035478910005623 +,,,,,,0.30914465950081654 +,,,,,,0.3495569045007869 +,,,,,,0.2942124605015124 +,,,,,,0.3181251874993905 +,,,,,,0.35471179100022715 +,,,,,,0.2913145695001731 +,,,,,,0.3219149175001803 +,,,,,,0.34034332600094785 +,,,,,,0.2721695340005681 +,,,,,,0.3015580114988552 +,,,,,,0.31823068450103165 +,,,,,,0.33214932249939016 +,,,,,,0.28206731850150396 +,,,,,,0.3391708040016965 +,,,,,,0.28080857050008495 +,,,,,,0.29223156499938346 +,,,,,,0.3270260264998797 +,,,,,,0.24346502699881967 +,,,,,,0.26593322249755147 +,,,,,,0.26876522750171716 +,,,,,,0.29807925000022806 +,,,,,,0.3093606524998905 +,,,,,,0.3275430405010411 +,,,,,,0.2635442210012116 +,,,,,,0.2927720179995959 +,,,,,,0.3039422474994354 +,,,,,,0.35902231099862547 +,,,,,,0.296492658500938 +,,,,,,0.30905202750182076 +,,,,,,0.31871436549954524 +,,,,,,0.34961937999833026 +,,,,,,0.273283876998903 +,,,,,,0.30129397000200697 +,,,,,,0.32219278750017116 +,,,,,,0.34467577500254265 +,,,,,,0.2824676120017102 +,,,,,,0.26245862799805764 +,,,,,,0.26663167300102947 +,,,,,,0.3264133334996586 +,,,,,,0.26814784649832296 +,,,,,,0.2808850830006122 +,,,,,,0.2963782814986189 +,,,,,,0.30456796200087416 +,,,,,,0.3226034985000297 +,,,,,,0.3506846340005723 +,,,,,,0.2959706185010873 +,,,,,,0.35132167699885036 +,,,,,,0.27073969000048237 +,,,,,,0.3248042675004399 +,,,,,,0.25561337299950543 +,,,,,,0.2710639930010075 +,,,,,,0.3115524640015792 +,,,,,,0.32542948750051437 +,,,,,,0.2728712910011382 +,,,,,,0.28806768850154185 +,,,,,,0.32155644799968286 +,,,,,,0.3356779549994826 +,,,,,,0.2662372384984338 +,,,,,,0.2869683190001524 +,,,,,,0.3009300055018685 +,,,,,,0.32067190099951404 +,,,,,,0.34451644950058835 +,,,,,,0.3117396295001527 +,,,,,,0.3550555474994326 +,,,,,,0.2857988449995901 +,,,,,,0.30675982499997195 +,,,,,,0.34306947000004584 +,,,,,,0.27081182750043814 +,,,,,,0.2907151060007891 +,,,,,,0.3103103845005535 +,,,,,,0.31938531450032315 +,,,,,,0.3459316060016136 +,,,,,,0.26135298299959686 +,,,,,,0.2822132330002205 +,,,,,,0.30580428699977347 +,,,,,,0.32549646750157996 +,,,,,,0.27121295449978794 +,,,,,,0.28648734700072964 +,,,,,,0.31586420950043254 +,,,,,,0.3312839689988323 +,,,,,,0.2576101290014777 +,,,,,,0.2625874065015523 +,,,,,,0.2864025275011955 +,,,,,,0.3086113435001608 +,,,,,,0.3296794609977951 +,,,,,,0.279720583001108 +,,,,,,0.2886880905007274 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test8/test8_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test8/test8_results.csv new file mode 100644 index 0000000..338c1b3 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test8/test8_results.csv @@ -0,0 +1,98 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.306385096278476,0.38077486599968324,0.24483931949953333,0.3108670540004823,0.32805421499915616,0.284060361000229,0.3001606210004866 +,,,,,,0.3200193710008535 +,,,,,,0.34676325200052815 +,,,,,,0.33840338200116094 +,,,,,,0.2692006474994742 +,,,,,,0.28876439800114895 +,,,,,,0.3154904390007687 +,,,,,,0.33951635050016193 +,,,,,,0.27028666349997366 +,,,,,,0.2701779650005847 +,,,,,,0.2801835385007508 +,,,,,,0.295725100999789 +,,,,,,0.34044799150069593 +,,,,,,0.26386010099895435 +,,,,,,0.3000833824994516 +,,,,,,0.367034450000574 +,,,,,,0.31922114299959503 +,,,,,,0.3304806740006825 +,,,,,,0.26818077800044193 +,,,,,,0.2921273150000161 +,,,,,,0.3075273925014699 +,,,,,,0.3203252314997372 +,,,,,,0.340136090499982 +,,,,,,0.2805509595013973 +,,,,,,0.32805421499915616 +,,,,,,0.2533595279996917 +,,,,,,0.270287522999297 +,,,,,,0.29283374649958205 +,,,,,,0.31539523099854705 +,,,,,,0.3349521060004008 +,,,,,,0.25148819999958505 +,,,,,,0.2684964809996018 +,,,,,,0.284060361000229 +,,,,,,0.3065632779998851 +,,,,,,0.32947306949881755 +,,,,,,0.24483931949953333 +,,,,,,0.3185102305001237 +,,,,,,0.3592371055010517 +,,,,,,0.2872314290007126 +,,,,,,0.31095338249951965 +,,,,,,0.31944918949920975 +,,,,,,0.34471062149941645 +,,,,,,0.2755759865003711 +,,,,,,0.29795853800033006 +,,,,,,0.3246045795012833 +,,,,,,0.24710606450071282 +,,,,,,0.31656960549889845 +,,,,,,0.3407319240004654 +,,,,,,0.2616537990006691 +,,,,,,0.2843029129985553 +,,,,,,0.30548989250110026 +,,,,,,0.3127748920001068 +,,,,,,0.332397523000509 +,,,,,,0.27565859050037034 +,,,,,,0.3161262725006964 +,,,,,,0.3466270804992746 +,,,,,,0.2717468459991324 +,,,,,,0.29551801700017677 +,,,,,,0.3108670540004823 +,,,,,,0.33385408499907504 +,,,,,,0.27590103850025116 +,,,,,,0.30271806950077007 +,,,,,,0.3198704920005184 +,,,,,,0.3395233815003849 +,,,,,,0.2771776015006253 +,,,,,,0.28858934549998594 +,,,,,,0.341362288500477 +,,,,,,0.3158905699997377 +,,,,,,0.29255890300009924 +,,,,,,0.3211911165008133 +,,,,,,0.34940963249982815 +,,,,,,0.29118392900045365 +,,,,,,0.3220403875002376 +,,,,,,0.34586023150041 +,,,,,,0.2724206740003865 +,,,,,,0.2922506479994809 +,,,,,,0.3313872884996272 +,,,,,,0.2662598145002449 +,,,,,,0.2899567675003709 +,,,,,,0.31247202750000724 +,,,,,,0.38077486599968324 +,,,,,,0.311483721001423 +,,,,,,0.33655593399907957 +,,,,,,0.28120788749993153 +,,,,,,0.2940134084997226 +,,,,,,0.32352502250068943 +,,,,,,0.27381306950019285 +,,,,,,0.2975182779991883 +,,,,,,0.3200599705010064 +,,,,,,0.3396862464996957 +,,,,,,0.2761911685001906 +,,,,,,0.32273168949996034 +,,,,,,0.3454295015012577 +,,,,,,0.2956666374993802 +,,,,,,0.30251533499904326 +,,,,,,0.31234408500040445 +,,,,,,0.3236873930013644 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test9/test9_results.csv b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test9/test9_results.csv new file mode 100644 index 0000000..1cec32e --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/delayData/test9/test9_results.csv @@ -0,0 +1,68 @@ +Average Latency,Maximum Value,Minimum Value,Median,Upper Quartile,Lower Quartile,Delay +0.30494488008969084,0.3851227309992282,0.2468282260006163,0.3008365850009796,0.3309366635005518,0.28116170200087254,0.36101457950007904 +,,,,,,0.28154403250073307 +,,,,,,0.3038198665008167 +,,,,,,0.33747468400133585 +,,,,,,0.31916135150095215 +,,,,,,0.33459439750095044 +,,,,,,0.29287840850020075 +,,,,,,0.32347577800010185 +,,,,,,0.3318435905002844 +,,,,,,0.2595995800006677 +,,,,,,0.3233905434999542 +,,,,,,0.2468282260006163 +,,,,,,0.2984293719991911 +,,,,,,0.3376121324990891 +,,,,,,0.27222614300035275 +,,,,,,0.29034093449990905 +,,,,,,0.2650711165001667 +,,,,,,0.2883765335013777 +,,,,,,0.2727447625002242 +,,,,,,0.29362458000105107 +,,,,,,0.3421080434991382 +,,,,,,0.34072103899916334 +,,,,,,0.2669988509992436 +,,,,,,0.2681253355003719 +,,,,,,0.28367325199951665 +,,,,,,0.27899254850035504 +,,,,,,0.29970088249956467 +,,,,,,0.31213554349960765 +,,,,,,0.34034843349991206 +,,,,,,0.28077937150101206 +,,,,,,0.3851227309992282 +,,,,,,0.3170128349997867 +,,,,,,0.3279813510002896 +,,,,,,0.2543226790003246 +,,,,,,0.2906006475009235 +,,,,,,0.33477976199901605 +,,,,,,0.35142194950094563 +,,,,,,0.29986062149873766 +,,,,,,0.2964221054999143 +,,,,,,0.3300297365008192 +,,,,,,0.27183655900034864 +,,,,,,0.3008365850009796 +,,,,,,0.31180161149950436 +,,,,,,0.31272661100047117 +,,,,,,0.32828770449941663 +,,,,,,0.25345911149997846 +,,,,,,0.2620223665003323 +,,,,,,0.26594713150007016 +,,,,,,0.31219921600040834 +,,,,,,0.35397054300028685 +,,,,,,0.26453950199993415 +,,,,,,0.29015051750047866 +,,,,,,0.3111527049995857 +,,,,,,0.30811169000071464 +,,,,,,0.3262747105004564 +,,,,,,0.28810684600057357 +,,,,,,0.3062057784995887 +,,,,,,0.33263455399946906 +,,,,,,0.35773171550044935 +,,,,,,0.2698073659998954 +,,,,,,0.28215056950148215 +,,,,,,0.33191994449907725 +,,,,,,0.3625660904999677 +,,,,,,0.2817421580011797 +,,,,,,0.2985517154993432 +,,,,,,0.3432079129988779 +,,,,,,0.2681774190004944 diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/measureDelay.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/measureDelay.py index e2232d8..dbe7163 100644 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/measureDelay.py +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/measureDelay.py @@ -16,6 +16,8 @@ def checkNumberofLines(df, log_name): def checkContinuousCount(df, log_name): duplicates = df[df["count"].duplicated()]["count"] if not duplicates.empty: + df.drop_duplicates(subset=["count"], inplace=True) + df.reset_index(drop=True, inplace=True) print(f"Warning: Non-continuous count in the log file {log_name} at index {duplicates.index.tolist()}") max_count = args.number all_counts = set(range(1, max_count + 1)) @@ -24,6 +26,16 @@ def checkContinuousCount(df, log_name): if missing != set(): print(f"Warning: missing msg in {log_name} at index {missing}") +def conversionUnit(number): + if number.dtype == int: + return 1e9 + elif number.dtype == float: + return 1 + else: + raise ValueError("Accuracy must be ns or s") + + + def filter_dataframes(dataframes): common_counts = set(dataframes[0]["count"]) & set(dataframes[1]["count"]) & set(dataframes[2]["count"]) return [df[df["count"].isin(common_counts)].reset_index(drop=True) for df in dataframes] @@ -37,16 +49,19 @@ df[df["count"].isin(common_counts)].reset_index(drop=True): This part resets the if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("-n", "--number", type=int, default="1000", help="number of packet", required=True) + parser.add_argument("-n", "--number", type=int, default="100", help="number of packet", required=False) parser.add_argument("-t", "--test", type=str, default="1", help="number of test", required=True) + # parser.add_argument("-a", "--accuracy", type=str, default="s", help="ns vs s / (perf_counter_ns vs perf_counter)", required=False) args = parser.parse_args() log_files = [f"delayData/test{args.test}/ProtodelayA_PUB.log", f"delayData/test{args.test}/ProtodelayA_SUB.log", f"delayData/test{args.test}/ProtodelayB_SUB.log"] dataframes = [] dataerrorFlag = [] + unit = [] for log_file in log_files: df = pd.read_csv(log_file, delim_whitespace=True, header=None, names=["count", "time"]) dataframes.append(df) + unit.append(conversionUnit(df["time"][0])) # check if the number of lines is correct dataerrorFlag.append(checkNumberofLines(df, log_file)) @@ -56,15 +71,36 @@ if __name__ == "__main__": df_Proto_delayA_PUB, df_Proto_delayA_SUB, df_Proto_delayB_SUB = dataframes - # print the resulting DataFrame - diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"] - df_Proto_delayA_PUB["time"] - df_Proto_delayB_SUB["time"])/1e9/2}) - array_Proto = diff_Proto_df["Difftime"].to_numpy() - avg_Proto = np.average(array_Proto) + + # diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"]/unit[0] - df_Proto_delayA_PUB["time"]/unit[1] - df_Proto_delayB_SUB["time"]/unit[2])/2*0.9}) + diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"]/unit[0] - df_Proto_delayA_PUB["time"]/unit[1])}) + + array_Latency = diff_Proto_df["Difftime"].to_numpy() + + avg_latency = np.average(array_Latency) + max_value = np.max(array_Latency) + min_value = np.min(array_Latency) + median_value = np.median(array_Latency) + upper_quartile = np.percentile(array_Latency, 75) + lower_quartile = np.percentile(array_Latency, 25) + + result_dict = { + "Average Latency": [avg_latency], + "Maximum Value": [max_value], + "Minimum Value": [min_value], + "Median": [median_value], + "Upper Quartile": [upper_quartile], + "Lower Quartile": [lower_quartile] + } + result_df = pd.DataFrame(result_dict) + avg_latency_df = pd.DataFrame(array_Latency, columns=['Delay']) + combined_df = pd.concat([result_df, avg_latency_df], axis=1) + combined_df.to_csv(f"delayData/test{args.test}/test{args.test}_results.csv", index=False) fig, ax = plt.subplots() - ax.boxplot(array_Proto) + ax.boxplot(array_Latency) ax.set_title("Round Trip Latency") ax.set_ylabel("Delay (s)") @@ -73,9 +109,9 @@ if __name__ == "__main__": plt.savefig(f"delayData/test{args.test}/test{args.test}_boxplot.png", dpi=100) fig = plt.figure() - plt.plot(array_Proto, color="blue", label=f"Avg_delay: {avg_Proto}") + plt.plot(array_Latency, color="blue", label=f"Avg_delay: {avg_latency}") plt.legend() plt.xlabel("Number of messages") plt.ylabel("Delay (s)") - plt.savefig(f"delayData/test{args.test}/test{args.test}.png", dpi=100) \ No newline at end of file + plt.savefig(f"delayData/test{args.test}/test{args.test}.png", dpi=100) diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/basicMqtt.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/basicMqtt.py deleted file mode 100644 index 572e84e..0000000 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/basicMqtt.py +++ /dev/null @@ -1,17 +0,0 @@ -import paho.mqtt.client as mqtt -import time -class MQTTClient(mqtt.Client): - - def __init__(self,cname,**kwargs): - super().__init__(cname,**kwargs) - self.last_pub_time=time.time() - self.topic_ack=[] - self.run_flag=True - self.subscribe_flag=False - self.bad_connection_flag=False - self.connected_flag=True - self.disconnect_flag=False - self.disconnect_time=0.0 - self.pub_msg_count=0 - self.devices=[] - diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/flyInformation_gen.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/flyInformation_gen.py new file mode 100644 index 0000000..717ae25 --- /dev/null +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/flyInformation_gen.py @@ -0,0 +1,30 @@ +import random + +class GPSgen(): + def __init__(self): + self.latitude = random.uniform(20, 100) + self.longitude = random.uniform(20, 100) + self.altitude = random.uniform(20, 100) + + def update_random(self): + self.latitude += random.uniform(0, 10) + self.longitude += random.uniform(0, 10) + self.altitude += random.uniform(0, 10) + +class HDGgen(): + def __init__(self): + self.data = random.uniform(20, 100) + + def update_random(self): + self.data += random.uniform(0, 10) + +if __name__ == "__main__": + import time + gps = GPSgen() + hdg = HDGgen() + while True: + gps.update_random() + hdg.update_random() + print(gps.latitude, gps.longitude, gps.altitude) + print(hdg.data) + time.sleep(0.25) \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientA_PUB.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientA_PUB.py index d412a67..c649cca 100644 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientA_PUB.py +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientA_PUB.py @@ -8,6 +8,7 @@ class Proto_msg_from_ros: #Protobuf flight_information_msg = None sel = None + timefunction = None @classmethod @@ -19,10 +20,10 @@ class Proto_msg_from_ros: @classmethod def callBack_compass_hdg(cls, Compass): - cls.flight_information_msg.heading = Compass.data + cls.flight_information_msg.heading = Compass flightInformationMsg = cls.flight_information_msg.SerializeToString() cls.sel.write(b'\xf2' + flightInformationMsg + b'\x0d\x0a') - timePub = time.perf_counter_ns() - logger.info("{} {}".format(Compass.data,timePub)) + timePub = cls.timefunction() + logger.info("{} {}".format(Compass,timePub)) diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientB_SUB.py b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientB_SUB.py index bc01695..2ea3d53 100644 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientB_SUB.py +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/proto_delayClientB_SUB.py @@ -16,6 +16,7 @@ class Proto_msg_to_ros: publisher_Flight_Information = None sel = None # count = None + timefunction = None #Proto @classmethod @@ -23,10 +24,8 @@ class Proto_msg_to_ros: proto = msg[1:-2] proto_msg = cls.flight_information_msg.FromString(proto) cls.sel.write(b'\xf2' + proto + b'\x0d\x0a') - timePub = time.perf_counter_ns() - # readTenByte = cls.sel.read_until(size=5) + timePub = cls.timefunction() timeDiff = timePub - timeSub - # cls.count = proto_msg.heading logger.info("{} {}".format(proto_msg.heading, timeDiff)) \ No newline at end of file diff --git a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/uavlinkConfig_SUB.yml b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/uavlinkConfig_SUB.yml index 029e877..d64a60b 100644 --- a/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/uavlinkConfig_SUB.yml +++ b/Stream/experiment/RTL_test/uavlink_measrue_rtl/utils/uavlinkConfig_SUB.yml @@ -8,4 +8,4 @@ ROS: ROSClientNameSub: Drone550UAVLINKSub Dron550_ROStopicName_Flight_Information: Flight_Information_reciver LOG: - logFileName: ProtodelayA_SUB.log \ No newline at end of file + logFileName: ProtodelayB_SUB.log \ No newline at end of file diff --git a/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientA_PUB.py b/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientA_PUB.py index d4eb633..ceef3ad 100644 --- a/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientA_PUB.py +++ b/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientA_PUB.py @@ -11,7 +11,12 @@ import logging from utils.protoJson_delayClientA_PUB import Json_msg from utils.protoJson_delayClientA_PUB import Proto_msg - +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter def init_dataFormat(cfg:utils.Read_delayA_PUB_Config): global pubFun @@ -19,12 +24,14 @@ def init_dataFormat(cfg:utils.Read_delayA_PUB_Config): Proto_msg.client = client Proto_msg.qos = cfg.qos Proto_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB + Proto_msg.timefunction = time_function cfg.logFileName = "Proto" + cfg.logFileName pubFun = Proto_msg.callBack_gps elif cfg.msg_format == "Json": Json_msg.client = client Json_msg.qos = cfg.qos Json_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB + Json_msg.timefunction = time_function cfg.logFileName = "Json" + cfg.logFileName pubFun = Json_msg.callBack_gps else: diff --git a/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientB_SUB.py b/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientB_SUB.py index 6ac1cb8..c84ede6 100644 --- a/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientB_SUB.py +++ b/Stream/experiment/datalose_test/MQTT_measure_datalose/lose_ClientB_SUB.py @@ -11,15 +11,22 @@ import logging from utils.protoJson_delayClientB_SUB import Json_msg from utils.protoJson_delayClientB_SUB import Proto_msg +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter + def init_dataFormat(cfg:utils.Read_delayB_SUB_Config): if cfg.msg_format == "Proto": Proto_msg.qos = cfg.qos Proto_msg.flight_information_msg = flight_information_pb2.flight_information_message() Proto_msg.fly_formation_msg = flyformatioln_pb2.fly_formation_message() Proto_msg.client = client + Proto_msg.timefunction = time_function client.on_message = Proto_msg.on_message cfg.logFileName = "Proto" + cfg.logFileName - Proto_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB elif cfg.msg_format == "Json": client.on_message = Json_msg.on_message @@ -27,6 +34,7 @@ def init_dataFormat(cfg:utils.Read_delayB_SUB_Config): Json_msg.client = client Json_msg.Delay_topicToMqtt_PUB = cfg.Delay_topicToMqtt_PUB cfg.logFileName = "Json" + cfg.logFileName + Json_msg.timefunction = time_function else: logger.debug("msg_format not found") diff --git a/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_PUB.py b/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_PUB.py index 52a09f1..d1f6e60 100644 --- a/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_PUB.py +++ b/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_PUB.py @@ -16,6 +16,7 @@ class Proto_msg: Delay_topicToMqtt_PUB = None count = 1 qos = None + timefunction = None @classmethod def callBack_gps(cls): @@ -23,12 +24,10 @@ class Proto_msg: flightInformationMsg = cls.flight_information_msg.SerializeToString() cls.mqtt_Pub(message=flightInformationMsg, topics=cls.Delay_topicToMqtt_PUB) - - @classmethod # publish a message def mqtt_Pub(cls, message:bytes, topics:str, waitForAck:bool=False)->None: - cls.timePub = time.perf_counter_ns() + cls.timePub = cls.timefunction() mid = cls.client.publish(topics, message, cls.qos)[1] logger.info("{} {}".format(cls.count,cls.timePub)) cls.count += 1 @@ -51,11 +50,9 @@ class Json_msg: Delay_topicToMqtt_PUB = None timePub = 0 qos = None + timefunction = None - - - @classmethod def callBack_gps(cls): cls.GPS_Data["count"] = cls.count @@ -66,7 +63,7 @@ class Json_msg: @classmethod def mqtt_Pub(cls, message:str, topics:str, waitForAck:bool=False): - cls.timePub = time.perf_counter_ns() + cls.timePub = cls.timefunction() mid = cls.client.publish(topics, message, cls.qos)[1] logger.info("{} {}".format(cls.count,cls.timePub)) cls.count += 1 diff --git a/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_SUB.py b/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_SUB.py index 310c97c..dd850f5 100644 --- a/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_SUB.py +++ b/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientA_SUB.py @@ -15,10 +15,11 @@ class Proto_msg: timeRcv = 0 msgCounter = None + timefunction = None @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = int(cls.flight_information_msg.FromString(msg.payload).heading) logger.info("{} {}".format(cls.msgCounter, cls.timeRcv)) @@ -27,10 +28,11 @@ class Proto_msg: class Json_msg: timeRcv = 0 msgCounter = None + timefunction = None @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = orjson.loads(msg.payload)["count"] logger.info("{} {}".format(cls.msgCounter, cls.timeRcv)) diff --git a/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientB_SUB.py b/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientB_SUB.py index a96a128..cf3b094 100644 --- a/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientB_SUB.py +++ b/Stream/experiment/datalose_test/MQTT_measure_datalose/utils/protoJson_delayClientB_SUB.py @@ -21,14 +21,14 @@ class Proto_msg: client = None timeRcv = 0 timeRsp = 0 - + timefunction = None msgCounter = None @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = int(cls.flight_information_msg.FromString(msg.payload).heading) logger.info("{} {}".format(cls.msgCounter, cls.timeRcv)) @@ -41,13 +41,13 @@ class Json_msg: client = None timeRcv = 0 timeRsp = 0 - + timefunction = None msgCounter = None @classmethod def on_message(cls, client, userdata, msg): - cls.timeRcv = time.perf_counter_ns() + cls.timeRcv = cls.timefunction() cls.msgCounter = orjson.loads(msg.payload)["count"] logger.info("{} {}".format(cls.msgCounter, cls.timeRcv)) \ No newline at end of file diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test6/results.csv b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test6/results.csv new file mode 100644 index 0000000..2e3b1b0 --- /dev/null +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test6/results.csv @@ -0,0 +1,4 @@ +frequency,packet_loss,percentage_loss +1hz,94,94.0 +5hz,1,1.0 +10hz,55,55.00000000000001 diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test7/experiment.txt b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test7/experiment.txt new file mode 100644 index 0000000..1b72e47 --- /dev/null +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test7/experiment.txt @@ -0,0 +1 @@ +20M fly diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test7/results.csv b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test7/results.csv new file mode 100644 index 0000000..f5c897a --- /dev/null +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test7/results.csv @@ -0,0 +1,11 @@ +frequency,packet_loss,percentage_loss +1hz,0,0.0 +2hz,0,0.0 +3hz,0,0.0 +4hz,1,1.0 +5hz,12,12.0 +6hz,25,25.0 +7hz,34,34.0 +8hz,42,42.0 +9hz,49,49.0 +10hz,54,54.0 diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test8/experiment.txt b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test8/experiment.txt new file mode 100644 index 0000000..697dafc --- /dev/null +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test8/experiment.txt @@ -0,0 +1 @@ +20M no fly diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test8/results.csv b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test8/results.csv new file mode 100644 index 0000000..841fe85 --- /dev/null +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/loseData/test8/results.csv @@ -0,0 +1,11 @@ +frequency,packet_loss,percentage_loss +1hz,0,0.0 +2hz,0,0.0 +3hz,0,0.0 +4hz,0,0.0 +5hz,10,10.0 +6hz,22,22.0 +7hz,35,35.0 +8hz,44,44.0 +9hz,48,48.0 +10hz,52,52.0 diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientA_PUB.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientA_PUB.py index 18a7ae4..4a506f1 100644 --- a/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientA_PUB.py +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientA_PUB.py @@ -8,34 +8,33 @@ import proto.flight_information_pb2 as flight_information_pb2 import logging from utils.readConfig import Read_PUB_Config from utils.proto_delayClientA_PUB import Proto_msg_from_ros -import random -import time import argparse +# simulation +from utils.flyInformation_gen import GPSgen + +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter -class fakeGps(): - def __init__(self): - self.latitude = 8.0 - self.longitude = 8.1 - self.altitude = 8.88 -class fake_hdg(): - def __init__(self): - self.data = 1 -def init_dataFormat(cfg:Read_PUB_Config): - +def init_dataFormat(cfg:Read_PUB_Config): Proto_msg_from_ros.sel = sel Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message() + Proto_msg_from_ros.timefunction = time_function if __name__ == '__main__': FilePath = os.path.join(os.path.dirname(__file__),"utils","uavlinkConfig_PUB.yml") cfg = Read_PUB_Config(FilePath) - gps = fakeGps() - hdg = fake_hdg() + gps = GPSgen() + parser = argparse.ArgumentParser() - parser.add_argument("-t", "--delaytime", type=float, default="1.0", help="1/frequence", required=True) + parser.add_argument("-f", "--frequency", type=float, default="1.0", help="frequence", required=True) args = parser.parse_args() # set log @@ -61,19 +60,16 @@ if __name__ == '__main__': sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE) init_dataFormat(cfg) + count = 1 + while count <= 100: + gps.update_random() - while hdg.data <= 100: - gps.latitude = random.uniform(10, 100) - gps.longitude = random.uniform(10, 100) - gps.altitude = random.uniform(10, 100) - - try: # test json Proto_msg_from_ros.callBack_gps(gps) - Proto_msg_from_ros.callBack_compass_hdg(hdg) - time.sleep(args.delaytime) - hdg.data += 1 + Proto_msg_from_ros.callBack_compass_hdg(count) + time.sleep(1/args.frequency) + count += 1 except KeyboardInterrupt as e: sel.write(b'\xf2' + b'......................' + b'\x0d\x2a') readTenByte = sel.read_until(size=5) diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientB.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientB.py index bed14b7..3e8cd8c 100644 --- a/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientB.py +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/lose_ClientB.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 #coding:utf-8 import serial -import time import sys import os import proto.flight_information_pb2 as flight_information_pb2 @@ -11,9 +10,17 @@ from utils.proto_delayClientB_SUB import Proto_msg_to_ros import google.protobuf.message import argparse +if sys.version_info >= (3, 7): + import time + time_function = time.perf_counter_ns +else: + import time + time_function = time.perf_counter + def init_dataFormat(cfg:Read_SUB_Config): Proto_msg_to_ros.sel = sel Proto_msg_to_ros.flight_information_msg = flight_information_pb2.flight_information_message() + Proto_msg_to_ros.timefunction = time_function if __name__ == '__main__': @@ -56,7 +63,7 @@ if __name__ == '__main__': count += 1 continue last_packet = readTenByte - timeSub = time.perf_counter_ns() + timeSub = time_function() Proto_msg_to_ros.on_message_Flight_Information(readTenByte, timeSub) except google.protobuf.message.DecodeError as e: logger.debug(readTenByte) diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/measureLose.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/measureLose.py index f665875..101951b 100644 --- a/Stream/experiment/datalose_test/uavlink_measrue_datalose/measureLose.py +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/measureLose.py @@ -35,7 +35,7 @@ def extract_number(filename): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("-n", "--number", type=int, default="1000", help="number of packet", required=True) + parser.add_argument("-n", "--number", type=int, default="1000", help="number of packet", required=False) parser.add_argument("-t", "--test", type=str, default="1", help="number of test", required=True) args = parser.parse_args() diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/flyInformation_gen.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/flyInformation_gen.py new file mode 100644 index 0000000..717ae25 --- /dev/null +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/flyInformation_gen.py @@ -0,0 +1,30 @@ +import random + +class GPSgen(): + def __init__(self): + self.latitude = random.uniform(20, 100) + self.longitude = random.uniform(20, 100) + self.altitude = random.uniform(20, 100) + + def update_random(self): + self.latitude += random.uniform(0, 10) + self.longitude += random.uniform(0, 10) + self.altitude += random.uniform(0, 10) + +class HDGgen(): + def __init__(self): + self.data = random.uniform(20, 100) + + def update_random(self): + self.data += random.uniform(0, 10) + +if __name__ == "__main__": + import time + gps = GPSgen() + hdg = HDGgen() + while True: + gps.update_random() + hdg.update_random() + print(gps.latitude, gps.longitude, gps.altitude) + print(hdg.data) + time.sleep(0.25) \ No newline at end of file diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_PUB.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_PUB.py index d412a67..a6d988b 100644 --- a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_PUB.py +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_PUB.py @@ -8,7 +8,7 @@ class Proto_msg_from_ros: #Protobuf flight_information_msg = None sel = None - + timefunction = None @classmethod def callBack_gps(cls, GPS): @@ -19,10 +19,10 @@ class Proto_msg_from_ros: @classmethod def callBack_compass_hdg(cls, Compass): - cls.flight_information_msg.heading = Compass.data + cls.flight_information_msg.heading = Compass flightInformationMsg = cls.flight_information_msg.SerializeToString() cls.sel.write(b'\xf2' + flightInformationMsg + b'\x0d\x0a') - timePub = time.perf_counter_ns() - logger.info("{} {}".format(Compass.data,timePub)) + timePub = cls.timefunction() + logger.info("{} {}".format(Compass,timePub)) diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_SUB.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_SUB.py deleted file mode 100644 index d64cb31..0000000 --- a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientA_SUB.py +++ /dev/null @@ -1,25 +0,0 @@ -import time - -import proto.flight_information_pb2 as flight_information_pb2 -import google.protobuf.json_format as json_format -import logging - -# TODO: use native ros type instead of json or str -logger = logging.getLogger("__UAVLINKSUB__") - -class Proto_msg_to_ros: - #Protobuf - flight_information_msg = None - - #Ros publisher - rate = None - publisher_Flight_Information = None - - - #Proto - @classmethod - def on_message_Flight_Information(cls, msg, timeSub): - proto = msg[1:-2] - proto_msg = cls.flight_information_msg.FromString(proto) - count = proto_msg.heading - logger.info("{} {}".format(count,timeSub)) \ No newline at end of file diff --git a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientB_SUB.py b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientB_SUB.py index 7543af3..86d77c0 100644 --- a/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientB_SUB.py +++ b/Stream/experiment/datalose_test/uavlink_measrue_datalose/utils/proto_delayClientB_SUB.py @@ -25,18 +25,15 @@ class Proto_msg_to_ros: f1_close_code = f1_code + payload + close_code f2_close_code = f2_code + payload + close_code - # count = None + timefunction = None #Proto @classmethod def on_message_Flight_Information(cls, msg, timeSub): proto = msg[1:-2] proto_msg = cls.flight_information_msg.FromString(proto) - # cls.sel.write(b'\xf2' + proto + b'\x0d\x0a') - timePub = time.perf_counter_ns() - # readTenByte = cls.sel.read_until(size=5) + timePub = cls.timefunction() timeDiff = timePub - timeSub - # cls.count = proto_msg.heading logger.info("{} {}".format(proto_msg.heading, timeDiff)) @classmethod diff --git a/Stream/uav_proto_msg/mqttPubMain.py b/Stream/uav_proto_msg/mqttPubMain.py index 9a1c393..3cf9425 100644 --- a/Stream/uav_proto_msg/mqttPubMain.py +++ b/Stream/uav_proto_msg/mqttPubMain.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -#coding:utf-8 +# coding:utf-8 import paho.mqtt.client as mqtt import os import sys @@ -9,7 +9,11 @@ import proto.flight_information_pb2 as flight_information_pb2 import proto.flyformatioln_pb2 as flyformatioln_pb2 import logging +# simulation +from utils.flyInformation_gen import GPSgen +from utils.flyInformation_gen import HDGgen +''' import rospy from std_msgs.msg import String from std_msgs.msg import Float64 @@ -19,32 +23,10 @@ from sensor_msgs.msg import NavSatFix from sensor_msgs.msg import Imu from sensor_msgs.msg import Range from geometry_msgs.msg import Vector3 +''' -# test proto -import random -class fakeGps(): - def __init__(self): - self.latitude = 8.0 - self.longitude = 8.1 - self.altitude = 8.88 - -class fake_hdg(): - def __init__(self): - self.data = 40 - -# class fake_formation(): -# def __init__(self): -# self.velocity = 100 -# self.type = 3 - - - - - - - -def init_dataFormat(cfg:utils.Read_PUB_Config): +def init_dataFormat(cfg: utils.Read_PUB_Config): # ros_namespace="/drone1" if cfg.msg_format == "Proto": utils.Proto_msg_from_ros.client = client @@ -65,26 +47,49 @@ def init_dataFormat(cfg:utils.Read_PUB_Config): else: logging.debug("msg_format not found") + def on_message(client, userdata, msg): pass -def on_connect(self, userdata, flags, rc): - logger.info("Connected with result code " + str(rc)) + +# def on_connect(client, userdata, flags, reasonCode, properties): +def on_connect(client, userdata, flage, reasonCode): + logger.info("Connected with result code " + str(reasonCode)) + def on_publish(self, userdata, mid): logger.debug("pub success") -def on_disconnect(client, userdata, rc): - logger.debug("disconnecting reason " +str(rc)) - client.connected_flag=False - client.disconnect_flag=True + +# def on_disconnect(client, userdata, reasonCode, properties): +def on_disconnect(client, userdata, msg): + logger.debug("disconnecting reason " + str(reasonCode)) + client.connected_flag = False + client.disconnect_flag = True + + +def main_loop(cfg, gps, hdg): + while True: + gps.update_random() + #hdg.update_random() + # hdg.data += 1 + + try: + callback_gps(gps) + callback_compass_hdg(hdg) + + time.sleep(0.1) + except KeyboardInterrupt as e: + client.disconnect() + logger.info("End of program") + sys.exit() + if __name__ == '__main__': # Read Config - FilePath = os.path.join(os.path.dirname(__file__),"utils","mqttConfig_PUB.yml") + FilePath = os.path.join(os.path.dirname(__file__), "utils", "mqttConfig_PUB.yml") cfg = utils.Read_PUB_Config(FilePath) client = utils.MQTTClient(cfg.MQTTClientNamePub) - # set log log_format = "%(asctime)s - %(levelname)s - %(message)s" formatter = logging.Formatter(log_format) @@ -93,7 +98,6 @@ if __name__ == '__main__': stream_handler.setFormatter(formatter) stream_handler.setLevel(logging.DEBUG) - file_handler = logging.FileHandler(cfg.logFileName) file_handler.setFormatter(formatter) file_handler.setLevel(logging.INFO) @@ -112,43 +116,25 @@ if __name__ == '__main__': client.connect(host=cfg.host, port=cfg.port, keepalive=cfg.keepalive) client.will_set(cfg.willTopic, cfg.lwt, cfg.willTopicQOS, cfg.willRetain) client.loop_start() - + ''' # Ros - # rosClient = cfg.ROSClientNamePub - # rospy.init_node(rosClient) + rosClient = cfg.ROSClientNamePub + rospy.init_node(rosClient) + ''' init_dataFormat(cfg) - - - - # rospy.spin() - - #test proto - gps = fakeGps() - hdg = fake_hdg() - # formation = fake_formation() - while True: - # test proto - # gps.latitude = random.uniform(10, 100) - # gps.longitude = random.uniform(10, 100) - # gps.altitude = random.uniform(10, 100) - # hdg.data = random.uniform(0, 10) - # formation.velocity = random.uniform(0, 10) - try: - # test json - utils.Json_msg_from_ros.callBack_gps(gps) - utils.Json_msg_from_ros.callBack_compass_hdg(hdg) - # utils.Json_msg_from_ros.callBack_fly_formation(formation) - - # test proto - # utils.Proto_msg_from_ros.callBack_gps(gps) - # utils.Proto_msg_from_ros.callBack_compass_hdg(hdg) - ## utils.Proto_msg_from_ros.callBack_fly_formation(formation) - time.sleep(0.25) - except KeyboardInterrupt as e: - client.disconnect() - logger.info("End of program") - sys.exit() + gps = GPSgen() + hdg = HDGgen() + if cfg.msg_format == "Proto": + callback_gps = utils.Proto_msg_from_ros.callBack_gps + callback_compass_hdg = utils.Proto_msg_from_ros.callBack_compass_hdg + elif cfg.msg_format == "Json": + callback_gps = utils.Json_msg_from_ros.callBack_gps + callback_compass_hdg = utils.Json_msg_from_ros.callBack_compass_hdg + else: + logger.debug("msg_format not found") + sys.exit() + main_loop(cfg, gps, hdg) diff --git a/Stream/uav_proto_msg/uavlinkPubMain.py b/Stream/uav_proto_msg/uavlinkPubMain.py old mode 100755 new mode 100644 index 34bc9c0..0427732 --- a/Stream/uav_proto_msg/uavlinkPubMain.py +++ b/Stream/uav_proto_msg/uavlinkPubMain.py @@ -6,73 +6,114 @@ import sys import os import proto.flight_information_pb2 as flight_information_pb2 import logging -from utils.readConfig import Read_PUB_Config +from utils.readConfig import Config from utils.proto_uavlink_sub_data_from_ros import Proto_msg_from_ros -import random - -class fakeGps(): - def __init__(self): - self.latitude = 8.0 - self.longitude = 8.1 - self.altitude = 8.88 - -class fake_hdg(): - def __init__(self): - self.data = 40 - - -def init_dataFormat(cfg:Read_PUB_Config): - # f1data = b'\xf1drone550pub...........\r\n' - sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE, timeout=0.3) - # sel.write(f1data) - # readTenByte = sel.readline() - # print(readTenByte) - Proto_msg_from_ros.sel = sel +import google.protobuf.message + +# simulation +from utils.flyInformation_gen import GPSgen +from utils.flyInformation_gen import HDGgen +''' +import rospy +from std_msgs.msg import String +from std_msgs.msg import Float64 +from std_msgs.msg import Header +from mavros_msgs.srv import ParamGet +from sensor_msgs.msg import NavSatFix +from sensor_msgs.msg import Imu +from sensor_msgs.msg import Range +from geometry_msgs.msg import Vector3 +''' + +class Read_UAVLINK_PUB_Config(Config): + def setAttribute(self): + super().setAttribute() + + def __init__(self, inFileName): + super().__init__(inFileName) + self.sectionNames = ["UAVLINK","ROS","LOG"] + self.options = { + self.sectionNames[0]:{ + "uavlink_msg_format": (str,False), + "uav_id": (str,False), + "baudrate": (int,True), + "ttyport": (str,True)}, + self.sectionNames[1]:{ + "ROSClientNamePub": (str,True), + "ROStopicName_Flight_Information": (str,False)}, + self.sectionNames[2]:{ + "logFileName":(str,True)}} + self.setAttribute() + + + +def init_dataFormat(cfg): + Proto_msg_from_ros.sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE) Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message() - + ''' + Proto_msg_from_ros.rate = rospy.Rate(10) + rospy.Subscriber('/mavros/global_position/global', NavSatFix, Proto_msg_from_ros.callBack_gps) + rospy.Subscriber('/mavros/global_position/compass_hdg', Float64, Proto_msg_from_ros.callBack_compass_hdg) + ''' +def shutdown_callback(): + Proto_msg_from_ros.turnOffUavlink() if __name__ == '__main__': FilePath = os.path.join(os.path.dirname(__file__),"utils","uavlinkConfig_PUB.yml") - cfg = Read_PUB_Config(FilePath) - gps = fakeGps() - hdg = fake_hdg() - + cfg = Read_UAVLINK_PUB_Config(FilePath) + # set log - log_format = "%(asctime)s - %(levelname)s - %(message)s" - formatter = logging.Formatter(log_format) + stream_log_format = "%(asctime)s - %(levelname)s - %(message)s" + file_log_format = "%(message)s" + file_formatter = logging.Formatter(file_log_format) + stream_formatter = logging.Formatter(stream_log_format) stream_handler = logging.StreamHandler() - stream_handler.setFormatter(formatter) + stream_handler.setFormatter(stream_formatter) stream_handler.setLevel(logging.DEBUG) - file_handler = logging.FileHandler(cfg.logFileName) - file_handler.setFormatter(formatter) + file_handler = logging.FileHandler(cfg.logFileName, mode='w') + file_handler.setFormatter(file_formatter) file_handler.setLevel(logging.INFO) logger = logging.getLogger("__UAVLINKSUBPUB__") - logger.setLevel(logging.INFO) + logger.setLevel(logging.DEBUG) logger.addHandler(file_handler) logger.addHandler(stream_handler) - logger.info(cfg) - + logger.debug(cfg) init_dataFormat(cfg) - while True: - gps.latitude = random.uniform(10, 100) - gps.longitude = random.uniform(10, 100) - gps.altitude = random.uniform(10, 100) + gps = GPSgen() + hdg = HDGgen() - hdg.data = random.uniform(0, 10) + while True: + gps.update_random() + hdg.update_random() try: - # test json Proto_msg_from_ros.callBack_gps(gps) Proto_msg_from_ros.callBack_compass_hdg(hdg) - time.sleep(0.3) - - + time.sleep(0.1) except KeyboardInterrupt as e: - print("End of program") + Proto_msg_from_ros.turnOffUavlink() + logger.debug("End of program") sys.exit() + ''' + # Ros + rosClient = cfg.ROSClientNamePub + rospy.init_node(rosClient) + rospy.on_shutdown(shutdown_callback) + # init data format + + + try: + rospy.spin() + except KeyboardInterrupt as e: + Proto_msg_from_ros.turnOffUavlink() + logger.debug("End of program") + sys.exit() + + ''' + diff --git a/Stream/uav_proto_msg/uavlinkSubMain.py b/Stream/uav_proto_msg/uavlinkSubMain.py old mode 100755 new mode 100644 index b7f7558..74f6f4b --- a/Stream/uav_proto_msg/uavlinkSubMain.py +++ b/Stream/uav_proto_msg/uavlinkSubMain.py @@ -6,67 +6,101 @@ import sys import os import proto.flight_information_pb2 as flight_information_pb2 import logging -from utils.readConfig import Read_SUB_Config +from utils.readConfig import Config from utils.proto_uavlink_pub_data_to_ros import Proto_msg_to_ros - - - -def init_dataFormat(cfg:Read_SUB_Config): - ros_namespace="/drone1" - deviceData = b'\xf12222222222222222222222\r\x1a' - - sel.write(deviceData) - time.sleep(1) - readTenByte = sel.read(size=5) - print(readTenByte) - - +import google.protobuf.message +''' +import rospy +from std_msgs.msg import String +from std_msgs.msg import Float64 +from std_msgs.msg import Header +from mavros_msgs.srv import ParamGet +from sensor_msgs.msg import NavSatFix +from sensor_msgs.msg import Imu +from sensor_msgs.msg import Range +from geometry_msgs.msg import Vector3 +# costom msg +from class_model.msg import FlightInformation +''' + +class Read_UAVLINK_SUB_Config(Config): + def setAttribute(self): + super().setAttribute() + + def __init__(self, inFileName): + super().__init__(inFileName) + self.sectionNames = ["UAVLINK","ROS","LOG"] + self.options = { + self.sectionNames[0]:{ + "uavlink_msg_format": (str,False), + "uav_id": (str,False), + "baudrate": (int,False), + "ttyport": (str,True)}, + self.sectionNames[1]:{ + "ROSClientNameSub": (str,True), + "ROStopicName_Flight_Information": (str,True)}, + self.sectionNames[2]:{ + "logFileName":(str,False)}} + self.setAttribute() + + +def init_dataFormat(cfg): Proto_msg_to_ros.flight_information_msg = flight_information_pb2.flight_information_message() - + Proto_msg_to_ros.sel = sel + ''' + Proto_msg_to_ros.rate = rospy.Rate(10) + Proto_msg_to_ros.publisher_Flight_Information = rospy.Publisher(cfg.ROStopicName_Flight_Information,FlightInformation,queue_size=10) + Proto_msg_to_ros.FlightInformationRosMsg = FlightInformation() + ''' + +def shutdown_callback(): + Proto_msg_to_ros.turnOffUavlink() + if __name__ == '__main__': FilePath = os.path.join(os.path.dirname(__file__),"utils","uavlinkConfig_SUB.yml") - cfg = Read_SUB_Config(FilePath) + cfg = Read_UAVLINK_SUB_Config(FilePath) - sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE, timeout = 0.5) + sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE) # set log - log_format = "%(asctime)s - %(levelname)s - %(message)s" - formatter = logging.Formatter(log_format) + stream_log_format = "%(asctime)s - %(levelname)s - %(message)s" + file_log_format = "%(message)s" + file_formatter = logging.Formatter(file_log_format) + stream_formatter = logging.Formatter(stream_log_format) stream_handler = logging.StreamHandler() - stream_handler.setFormatter(formatter) + stream_handler.setFormatter(stream_formatter) stream_handler.setLevel(logging.DEBUG) - file_handler = logging.FileHandler(cfg.logFileName) - file_handler.setFormatter(formatter) + file_handler = logging.FileHandler(cfg.logFileName, mode='w') + file_handler.setFormatter(file_formatter) file_handler.setLevel(logging.INFO) logger = logging.getLogger("__UAVLINKSUB__") - logger.setLevel(logging.INFO) + logger.setLevel(logging.DEBUG) logger.addHandler(file_handler) logger.addHandler(stream_handler) - logger.info(cfg) - + logger.debug(cfg) init_dataFormat(cfg) - + ''' + rospy.init_node(cfg.ROSClientNameSub) + rospy.on_shutdown(shutdown_callback) + while not rospy.is_shutdown(): + ''' while True: try: - # test json if sel.in_waiting >= 25: - readTenByte = sel.read_until(expected= b'\x01\x01', size=25) - # print(readTenByte) - if b"drone550" in readTenByte: - print(readTenByte) - print("radar") - continue - + readTenByte = sel.read_until(expected= b'\x01\x18', size=25) Proto_msg_to_ros.on_message_Flight_Information(readTenByte) - - except Exception as e: + except google.protobuf.message.DecodeError as e: + logger.info("DecodeError:{}".format(e)) + logger.info("readTenByte:{}".format(readTenByte)) + ''' + except rospy.ROSInterruptException as e: + Proto_msg_to_ros.turnOffUavlink() print("End of program") - print(readTenByte) - pass - + sys.exit() +''' diff --git a/Stream/uav_proto_msg/utils/.idea/.gitignore b/Stream/uav_proto_msg/utils/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Stream/uav_proto_msg/utils/.idea/inspectionProfiles/Project_Default.xml b/Stream/uav_proto_msg/utils/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..e55ddbf --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,104 @@ + + + + \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/.idea/inspectionProfiles/profiles_settings.xml b/Stream/uav_proto_msg/utils/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/.idea/misc.xml b/Stream/uav_proto_msg/utils/.idea/misc.xml new file mode 100644 index 0000000..2f9d1a6 --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/.idea/modules.xml b/Stream/uav_proto_msg/utils/.idea/modules.xml new file mode 100644 index 0000000..2213c52 --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/.idea/utils.iml b/Stream/uav_proto_msg/utils/.idea/utils.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/utils.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/.idea/vcs.xml b/Stream/uav_proto_msg/utils/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/Stream/uav_proto_msg/utils/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/flyInformation_gen.py b/Stream/uav_proto_msg/utils/flyInformation_gen.py new file mode 100644 index 0000000..717ae25 --- /dev/null +++ b/Stream/uav_proto_msg/utils/flyInformation_gen.py @@ -0,0 +1,30 @@ +import random + +class GPSgen(): + def __init__(self): + self.latitude = random.uniform(20, 100) + self.longitude = random.uniform(20, 100) + self.altitude = random.uniform(20, 100) + + def update_random(self): + self.latitude += random.uniform(0, 10) + self.longitude += random.uniform(0, 10) + self.altitude += random.uniform(0, 10) + +class HDGgen(): + def __init__(self): + self.data = random.uniform(20, 100) + + def update_random(self): + self.data += random.uniform(0, 10) + +if __name__ == "__main__": + import time + gps = GPSgen() + hdg = HDGgen() + while True: + gps.update_random() + hdg.update_random() + print(gps.latitude, gps.longitude, gps.altitude) + print(hdg.data) + time.sleep(0.25) \ No newline at end of file diff --git a/Stream/uav_proto_msg/utils/mqttConfig_PUB.yml b/Stream/uav_proto_msg/utils/mqttConfig_PUB.yml index 4e90bb7..096d2aa 100644 --- a/Stream/uav_proto_msg/utils/mqttConfig_PUB.yml +++ b/Stream/uav_proto_msg/utils/mqttConfig_PUB.yml @@ -20,4 +20,4 @@ ROS: ROStopicName_Fly_Formation: Fly_Formation_reciver LOG: logFileName: pub.log -UAVLINK: "None" \ No newline at end of file +UAVLINK: "None" diff --git a/Stream/uav_proto_msg/utils/mqttConfig_SUB.yml b/Stream/uav_proto_msg/utils/mqttConfig_SUB.yml index 759bdcd..17a5735 100644 --- a/Stream/uav_proto_msg/utils/mqttConfig_SUB.yml +++ b/Stream/uav_proto_msg/utils/mqttConfig_SUB.yml @@ -13,6 +13,7 @@ MQTT: Fly_Formation_topicToMqtt: Drone550/Formation # Change formate qos Fly_Formation_topicToMqtt_QOS: 2 + test: 123 ROS: ROSClientNameSub: Drone550Sub ROStopicName_Flight_Information: Flight_Information_reciver diff --git a/Stream/uav_proto_msg/utils/proto_uavlink_pub_data_to_ros.py b/Stream/uav_proto_msg/utils/proto_uavlink_pub_data_to_ros.py index ecd14a3..78f5386 100644 --- a/Stream/uav_proto_msg/utils/proto_uavlink_pub_data_to_ros.py +++ b/Stream/uav_proto_msg/utils/proto_uavlink_pub_data_to_ros.py @@ -3,29 +3,60 @@ import time import proto.flight_information_pb2 as flight_information_pb2 import google.protobuf.json_format as json_format import logging +# costom msg + # TODO: use native ros type instead of json or str -logger = logging.getLogger("__SUB__") +logger = logging.getLogger("__UAVLINKSUB__") class Proto_msg_to_ros: #Protobuf flight_information_msg = None #Ros publisher + FlightInformationRosMsg = None rate = None publisher_Flight_Information = None + #uavlink + sel = None + payload = b"......................" + noEcho_code = b"\x0d\x0a" + echo_code = b"\x0d\x1a" + close_code = b"\x0d\x2a" + f1_code = b"\xf1" + f2_code = b"\xf2" + f1_close_code = f1_code + payload + close_code + f2_close_code = f2_code + payload + close_code #Proto @classmethod def on_message_Flight_Information(cls, msg): - proto = msg[1:-2] - - proto_msg = cls.flight_information_msg.FromString(proto) - protoTOJson_msg = json_format.MessageToJson(proto_msg, indent=None, preserving_proto_field_name=True) - logger.info(protoTOJson_msg) - print(protoTOJson_msg) - cls.publisher_Flight_Information.publish(protoTOJson_msg) + logger.debug(cls.convert_proto_to_ros(msg[1:-2])) + ''' + cls.publisher_Flight_Information.publish(cls.convert_proto_to_ros(msg[1:-2])) + cls.rate.sleep() + ''' + @classmethod + def convert_proto_to_ros(cls, proto): + proto_msg = cls.flight_information_msg.FromString(proto) + return proto_msg + ''' + cls.FlightInformationRosMsg.LAT = proto_msg.gps.LAT + cls.FlightInformationRosMsg.LON = proto_msg.gps.LON + cls.FlightInformationRosMsg.ALT = proto_msg.gps.ALT + cls.FlightInformationRosMsg.heading = proto_msg.heading + return cls.FlightInformationRosMsg + ''' + + @classmethod + def detection(cls): + cls.sel.write(cls.f1_code + cls.payload + cls.echo_code) - \ No newline at end of file + @classmethod + def turnOffUavlink(cls): + time.sleep(0.5) + cls.sel.write(cls.f1_close_code) + time.sleep(0.5) + cls.sel.write(cls.f2_close_code) diff --git a/Stream/uav_proto_msg/utils/proto_uavlink_sub_data_from_ros.py b/Stream/uav_proto_msg/utils/proto_uavlink_sub_data_from_ros.py index 77f43bd..08ce3b1 100644 --- a/Stream/uav_proto_msg/utils/proto_uavlink_sub_data_from_ros.py +++ b/Stream/uav_proto_msg/utils/proto_uavlink_sub_data_from_ros.py @@ -7,21 +7,41 @@ logger = logging.getLogger("__UAVLINKSUBPUB__") class Proto_msg_from_ros: #Protobuf flight_information_msg = None + #ros + rate = None + #uavlink sel = None + payload = b"......................" + noEcho_code = b"\x0d\x0a" + echo_code = b"\x0d\x1a" + close_code = b"\x0d\x2a" + f1_code = b"\xf1" + f2_code = b"\xf2" + f1_close_code = f1_code + payload + close_code + f2_close_code = f2_code + payload + close_code @classmethod def callBack_gps(cls, GPS): - cls.flight_information_msg.gps.LAT = GPS.latitude - cls.flight_information_msg.gps.LON = GPS.longitude + cls.flight_information_msg.gps.LAT = GPS.latitude*10000000 + cls.flight_information_msg.gps.LON = GPS.longitude*10000000 cls.flight_information_msg.gps.ALT = GPS.altitude - + ''' + cls.rate.sleep() + ''' @classmethod def callBack_compass_hdg(cls, Compass): - cls.flight_information_msg.heading = Compass.data + cls.flight_information_msg.heading = Compass.data*100 flightInformationMsg = cls.flight_information_msg.SerializeToString() - cls.sel.write(b'\xf2' + flightInformationMsg + b'\r\n') - print(len(b'\xf2' + flightInformationMsg + b'\r\n')) - readTenByte = cls.sel.readline() - print(readTenByte) + cls.sel.write(cls.f2_code + flightInformationMsg + cls.noEcho_code) + ''' + cls.rate.sleep() + ''' + + @classmethod + def turnOffUavlink(cls): + time.sleep(0.5) + cls.sel.write(cls.f1_close_code) + time.sleep(0.5) + cls.sel.write(cls.f2_close_code) diff --git a/Stream/uav_proto_msg/utils/readConfig.py b/Stream/uav_proto_msg/utils/readConfig.py index 54386da..df90ae5 100644 --- a/Stream/uav_proto_msg/utils/readConfig.py +++ b/Stream/uav_proto_msg/utils/readConfig.py @@ -21,16 +21,16 @@ class Config: optval=ecfg[opt] #verify parameter type if type(optval) != self.options[opts][opt][0]: - raise Exception("Parameter {} has wrong type".format(self.opt)) + raise Exception("Parameter {} has wrong type".format(opt)) #create attributes on the fly setattr(self,opt,optval) else: if self.options[opts][opt][1]: - raise Exception("Missing mandatory parameter {}".format(self.opt)) + raise Exception("Missing mandatory parameter {}".format(opt)) else: setattr(self,opt,None) - + def __str__(self): return str(yaml.dump(self.ymlcfg, default_flow_style=False)) @@ -146,7 +146,7 @@ class Read_CMD_Config(Config): return super().__str__() if __name__ == "__main__": - cfg=Read_CMD_Config("mqttConfig_CMD.yml") + cfg=Read_SUB_Config("mqttConfig_SUB.yml") print(cfg) diff --git a/Stream/uav_proto_msg/utils/uavlinkConfig_PUB.yml b/Stream/uav_proto_msg/utils/uavlinkConfig_PUB.yml index 4e5624e..dadac74 100644 --- a/Stream/uav_proto_msg/utils/uavlinkConfig_PUB.yml +++ b/Stream/uav_proto_msg/utils/uavlinkConfig_PUB.yml @@ -1,8 +1,8 @@ UAVLINK: uavlink_msg_format: Proto - uav_id: \x01\x01 + uav_id: \x01\x17 baudrate: 250000 - ttyport: /dev/ttyUSB1 + ttyport: /dev/ttyUSB0 MQTT: "None" #ROS ROS: diff --git a/Stream/uav_proto_msg/utils/uavlinkConfig_SUB.yml b/Stream/uav_proto_msg/utils/uavlinkConfig_SUB.yml index cece1ea..f2f8ca9 100644 --- a/Stream/uav_proto_msg/utils/uavlinkConfig_SUB.yml +++ b/Stream/uav_proto_msg/utils/uavlinkConfig_SUB.yml @@ -2,10 +2,10 @@ UAVLINK: uavlink_msg_format: Proto uav_id: \x01\x01 baudrate: 250000 - ttyport: /dev/ttyUSB1 + ttyport: /dev/ttyUSB0 MQTT: "None" ROS: ROSClientNameSub: Drone550UAVLINKSub - Dron550_ROStopicName_Flight_Information: Flight_Information_reciver + ROStopicName_Flight_Information: Flight_Information_Uavlink_reciver LOG: logFileName: UAVLINKsub.log \ No newline at end of file