mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
rtps: fix and minor cleanup of scripts and templates
This commit is contained in:
@@ -17,7 +17,6 @@ import gencpp
|
|||||||
from px_generate_uorb_topic_helper import * # this is in Tools/
|
from px_generate_uorb_topic_helper import * # this is in Tools/
|
||||||
from px_generate_uorb_topic_files import MsgScope # this is in Tools/
|
from px_generate_uorb_topic_files import MsgScope # this is in Tools/
|
||||||
|
|
||||||
topic_names = [single_spec.short_name for single_spec in spec]
|
|
||||||
send_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
|
send_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
|
||||||
recv_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
|
recv_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
|
||||||
}@
|
}@
|
||||||
|
|||||||
@@ -81,18 +81,30 @@ def check_rtps_id_uniqueness(classifier):
|
|||||||
|
|
||||||
# check if there are repeated ID's on the messages to send
|
# check if there are repeated ID's on the messages to send
|
||||||
for key, value in classifier.msgs_to_send.items():
|
for key, value in classifier.msgs_to_send.items():
|
||||||
if classifier.msgs_to_send.values().count(value) > 1:
|
if sys.version_info[0] < 3:
|
||||||
repeated_ids.update({key: value})
|
if classifier.msgs_to_send.values().count(value) > 1:
|
||||||
|
repeated_ids.update({key: value})
|
||||||
|
else:
|
||||||
|
if list(classifier.msgs_to_send.values()).count(value) > 1:
|
||||||
|
repeated_ids.update({key: value})
|
||||||
|
|
||||||
# check if there are repeated ID's on the messages to receive
|
# check if there are repeated ID's on the messages to receive
|
||||||
for key, value in classifier.msgs_to_receive.items():
|
for key, value in classifier.msgs_to_receive.items():
|
||||||
if classifier.msgs_to_receive.values().count(value) > 1:
|
if sys.version_info[0] < 3:
|
||||||
repeated_ids.update({key: value})
|
if classifier.msgs_to_receive.values().count(value) > 1:
|
||||||
|
repeated_ids.update({key: value})
|
||||||
|
else:
|
||||||
|
if list(classifier.msgs_to_receive.values()).count(value) > 1:
|
||||||
|
repeated_ids.update({key: value})
|
||||||
|
|
||||||
# check if there are repeated ID's on the messages to ignore
|
# check if there are repeated ID's on the messages to ignore
|
||||||
for key, value in classifier.msgs_to_ignore.items():
|
for key, value in classifier.msgs_to_ignore.items():
|
||||||
if classifier.msgs_to_ignore.values().count(value) > 1:
|
if sys.version_info[0] < 3:
|
||||||
repeated_ids.update({key: value})
|
if classifier.msgs_to_ignore.values().count(value) > 1:
|
||||||
|
repeated_ids.update({key: value})
|
||||||
|
else:
|
||||||
|
if list(classifier.msgs_to_ignore.values()).count(value) > 1:
|
||||||
|
repeated_ids.update({key: value})
|
||||||
|
|
||||||
# check if there are repeated IDs between classfied and unclassified msgs
|
# check if there are repeated IDs between classfied and unclassified msgs
|
||||||
# check send and ignore lists
|
# check send and ignore lists
|
||||||
@@ -122,7 +134,11 @@ def check_rtps_id_uniqueness(classifier):
|
|||||||
all_msgs = classifier.msgs_to_send
|
all_msgs = classifier.msgs_to_send
|
||||||
all_msgs.update(classifier.msgs_to_receive)
|
all_msgs.update(classifier.msgs_to_receive)
|
||||||
all_msgs.update(classifier.msgs_to_ignore)
|
all_msgs.update(classifier.msgs_to_ignore)
|
||||||
all_ids = all_msgs.values()
|
all_ids = list()
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
all_ids = all_msgs.values()
|
||||||
|
else:
|
||||||
|
all_ids = list(all_msgs.values())
|
||||||
all_ids.sort()
|
all_ids.sort()
|
||||||
|
|
||||||
if not repeated_ids:
|
if not repeated_ids:
|
||||||
|
|||||||
@@ -53,39 +53,6 @@ class Classifier():
|
|||||||
self.msg_files_receive = self.set_msg_files_receive()
|
self.msg_files_receive = self.set_msg_files_receive()
|
||||||
self.msg_files_ignore = self.set_msg_files_ignore()
|
self.msg_files_ignore = self.set_msg_files_ignore()
|
||||||
|
|
||||||
# getters
|
|
||||||
@property
|
|
||||||
def msg_id_map(self):
|
|
||||||
return self.__msg_id_map
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msg_folder(self):
|
|
||||||
return self.__msg_folder
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msgs_to_send(self):
|
|
||||||
return self.__msgs_to_send
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msgs_to_receive(self):
|
|
||||||
return self.__msgs_to_receive
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msgs_to_ignore(self):
|
|
||||||
return self.__msgs_to_ignore
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msg_files_send(self):
|
|
||||||
return self.__msg_files_send
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msg_files_receive(self):
|
|
||||||
return self.__msg_files_receive
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msg_files_ignore(self):
|
|
||||||
return self.__msg_files_ignore
|
|
||||||
|
|
||||||
# setters (for class init)
|
# setters (for class init)
|
||||||
def set_msgs_to_send(self):
|
def set_msgs_to_send(self):
|
||||||
send = {}
|
send = {}
|
||||||
@@ -156,7 +123,9 @@ if __name__ == "__main__":
|
|||||||
# Parse arguments
|
# Parse arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
msg_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
msg_folder = args.msgdir
|
||||||
|
if args.msgdir == 'msg':
|
||||||
|
msg_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
classifier = Classifier(os.path.join(
|
classifier = Classifier(os.path.join(
|
||||||
msg_folder, args.yaml_file), msg_folder)
|
msg_folder, args.yaml_file), msg_folder)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user