Skip to content

Commit

Permalink
Merge pull request #42 from rebfjyjy/comment_fix
Browse files Browse the repository at this point in the history
fix comment
  • Loading branch information
YoruCathy authored Apr 14, 2024
2 parents b41a1c2 + 637a05e commit 2639d18
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
25 changes: 13 additions & 12 deletions pyrcareworld/pyrcareworld/attributes/custom_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyrcareworld/pyrcareworld/attributes/graspsim_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 13 additions & 13 deletions pyrcareworld/pyrcareworld/rfuniverse_channel/asset_channel_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2639d18

Please sign in to comment.