From 637a05e3a33c4487027093f611c3e92104364edc Mon Sep 17 00:00:00 2001 From: rebfjyjy Date: Fri, 12 Apr 2024 16:51:38 -0400 Subject: [PATCH] fix comment --- .../pyrcareworld/attributes/custom_attr.py | 25 +++++++++--------- .../pyrcareworld/attributes/graspsim_attr.py | 2 +- .../rfuniverse_channel/asset_channel_ext.py | 26 +++++++++---------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/pyrcareworld/pyrcareworld/attributes/custom_attr.py b/pyrcareworld/pyrcareworld/attributes/custom_attr.py index 13208eb7..df2874d2 100755 --- a/pyrcareworld/pyrcareworld/attributes/custom_attr.py +++ b/pyrcareworld/pyrcareworld/attributes/custom_attr.py @@ -6,31 +6,32 @@ import pyrcareworld.utils.utility as utility -# 消息解析示例 +# Message parsing example def parse_message(msg: IncomingMessage) -> dict: - # 先完成所继承的基类的数据读取 + # First, read the data inherited from the base class this_object_data = attr.base_attr.parse_message(msg) - # 按顺序读取数据 - # 此处读取顺序对应Unity的CustomAttr脚本CollectData函数中的写入顺序 + # Read data in order + # The order of reading here corresponds to the writing order in the CollectData function of Unity's CustomAttr script this_object_data["custom_message"] = msg.read_string() return this_object_data -# 新增接口示例 +# New interface example def CustomMessage(kwargs: dict) -> OutgoingMessage: - # 必要参数 + # Mandatory parameters compulsory_params = ["id", "message"] - # 非必要参数 + # Optional parameters optional_params = [] - # 参数检查 + # Parameter check utility.CheckKwargs(kwargs, compulsory_params) msg = OutgoingMessage() - # 第一个写入的数据必须是ID + # The first data must be ID msg.write_int32(kwargs["id"]) - # 第二个写入的数据必须是消息类型 此处CustomMessage对应Unity新增Attr脚本AnalysisMsg函数switch的一个分支 + # The second data must be message type. + # Here, CustomMessage correspond to one branch of 'switch' in AnalysingMsg function from Unity's new Attr script msg.write_string("CustomMessage") - # 按顺序写入数据 + # Write data in order msg.write_string(kwargs["message"]) - return msg + return msg \ No newline at end of file diff --git a/pyrcareworld/pyrcareworld/attributes/graspsim_attr.py b/pyrcareworld/pyrcareworld/attributes/graspsim_attr.py index 40b253db..f9b4d497 100755 --- a/pyrcareworld/pyrcareworld/attributes/graspsim_attr.py +++ b/pyrcareworld/pyrcareworld/attributes/graspsim_attr.py @@ -21,7 +21,7 @@ def parse_message(msg: IncomingMessage) -> dict: return this_object_data -# 新增接口示例 +# Adding new interface example def StartGraspSim(kwargs: dict) -> OutgoingMessage: compulsory_params = [ "id", diff --git a/pyrcareworld/pyrcareworld/rfuniverse_channel/asset_channel_ext.py b/pyrcareworld/pyrcareworld/rfuniverse_channel/asset_channel_ext.py index 26871ef3..83e1a7f4 100755 --- a/pyrcareworld/pyrcareworld/rfuniverse_channel/asset_channel_ext.py +++ b/pyrcareworld/pyrcareworld/rfuniverse_channel/asset_channel_ext.py @@ -5,33 +5,33 @@ import pyrcareworld.utils.utility as utility -# 消息解析 +# Message parsing def parse_message(msg: IncomingMessage, msg_type: str) -> dict: this_data = {} - # 根据头字符串添加自己的分支 - # 此处CustomMessage对应Unity中AssetManagerExt脚本CustomMessage接口函数中写入的第一个头字符串 + # Add your own branch based on the header string + # CustomMessage corresponds to the first header string in the CustomMessage interface function of Unity's AssetManagerExt script if msg_type == "CustomMessage": - # 按顺序读取数据 - # 此处读取顺序对应Unity中使用SendMetaDataToPython前写入顺序 + # Read data in order + # The reading order corresponds to the writing order before using SendMetaDataToPython in Unity data = msg.read_string() this_data["custom_message"] = data - # 将数据写入到data中返回 + # write data into this_data and return return this_data -# 新增接口示例 +# Adding new interface example def CustomMessage(kwargs: dict) -> OutgoingMessage: - # 必要参数 + # Mandatory parameters compulsory_params = ["message"] - # 非必要参数 + # Optional parameters optional_params = [] - # 参数检查 + # Parameters check utility.CheckKwargs(kwargs, compulsory_params) msg = OutgoingMessage() - # 第一个写入的数据必须是消息类型 - # 此处CustomMessage对应Unity中AssetManagerExt脚本AnalysisMsg函数switch的CustomMessage分支 + # First data to be written must be message type + # CustomMessage corresponds to the CustomMessage branch of the switch in the AnalysisMsg function of the AssetManagerExt script in Unity msg.write_string("CustomMessage") - # 按顺序写入自己想要发送的数据 + # Write the data to be sent in order msg.write_string(kwargs["message"]) return msg