5.7 KiB
5.7 KiB
“集群智能”开放挑战赛答选手提问-第一期
问题1 地图对应问题
问题2 关于SwarmAEClinet register_node传参问题
问:
node_type 到底需要传什么?
答:
node_type传参:
- 无人车:
四轮车
- 无人机:
四旋翼
完整代码(无人车):
#!/usr/bin/env python
import argparse
import time
def main():
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'-i', '--address',
default='127.0.0.1')
argparser.add_argument(
'-p', '--port',
type=int,
default=2000)
argparser.add_argument(
'-n', '--number',
type=int,
default=5)
argparser.add_argument(
'-s', '--subject',
type=int,
default=1
)
args = argparser.parse_args()
ue_ip = args.address.strip()
ue_port = args.port
num = args.number
try:
# 车列表,用于后续控制
nodes = []
# 1. 首先引入sdk
from swarmae.SwarmAEClient import SwarmAEClient
# 2. 连接UE
client = SwarmAEClient(ue_ip=ue_ip, ue_port=ue_port)
# 注册车辆
for id in range(num):
# node_no 从1开始编号
timestamp, node, code = client.register_node(
node_type="四轮车", node_name="节点" + str(id+1), node_no=id+1, frame_timestamp=int(round(time.time() * 1000))
)
if code == 200:
# 获取信息
node_name, node_no, _, node_type, node_model, color = node.get_node_info()
nodes.append(node)
finally:
print('main() end')
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
finally:
print('__main__ end')
问题3 报错 Python.ArgumentError:Python argument types inClient.init(client, NoneType, NoneType) did not match C++ signature
答:可能是sdk不匹配导致,尝试使用更新sdk依赖:
# windows
pip install https://jqtj.obs.cn-north-4.myhuaweicloud.com/sdk/windows/swarmae-1.0-py3-none-any.whl
# linux
pip install https://jqtj.obs.cn-north-4.myhuaweicloud.com/sdk/linux/swarmae-1.0-py3-none-any.whl
或使用新的示例(参考问题2的回答)。
问题4 关于FBX的读取方式
-
读取FBX文件的包使用哪个 AutoDesk最新版fbx python sdk可以吗?
请选择支持Python3.6的FBX Python SDK,这里提供一版此前编译好的FBX SDK
fbx 读取示例
import pdb
import fbx
from FbxCommon import *
def ProcessNode(pNode, prefix):
#获取结点的属性,也就是标签,标签是mesh就代表这个是mesh结点
NodeAttribute = pNode.GetNodeAttribute()
print(prefix + pNode.GetName(), NodeAttribute.GetAttributeType() if NodeAttribute is not None else "")
#if NodeAttribute is not None:
# NodeAttributeType = NodeAttribute.GetAttributeType()
# if NodeAttributeType == fbx.FbxNodeAttribute.eMesh:
# print('mesh')
# # return pNode
# else:
# print("Node Type is: ", NodeAttributeType)
#利用递归来获得节点,一旦遇到mesh结点就可以返回
if NodeAttribute is not None and NodeAttribute.GetAttributeType() == fbx.FbxNodeAttribute.eMesh:
ProcessMesh(pNode.GetMesh())
# pass
else:
cnt = pNode.GetChildCount()
prefix = prefix.replace('├', '│').replace('└', ' ')
for each in range(cnt):
if each < cnt - 1:
ProcessNode(pNode.GetChild(each), prefix + '├ ')
else:
ProcessNode(pNode.GetChild(each), prefix + '└ ')
return None
def ProcessMesh(pMesh):
if (pMesh == None):
print(1)
return
#获得mesh的构成顶点 = polygonVertices
#获得三角面的数量 = triangleCount
lNormals = pMesh.GetElementNormal()
triangleCount = pMesh.GetPolygonCount()
polygonVertices = pMesh.GetPolygonVertices()
vertexCounter = 0
#逐顶点去遍历
for i in range(triangleCount):
for j in range(3):
ctrlPointIndex = polygonVertices[i * 3 + j]
vertex = pMesh.GetControlPointAt(ctrlPointIndex)
vertexCounter = vertexCounter + 1
def main():
manager, scene = InitializeSdkObjects()
res = LoadScene(manager, scene, "CE_L1.fbx")
if res is not True:
pdb.set_trace()
print(res)
print("\n\nAn error occured while loading the scene...")
exit(0)
root = scene.GetRootNode()
meshNode = None
if root is not None:
meshNode = ProcessNode(root, '')
#根据mesh结点获得mesh
if meshNode is not None:
ProcessMesh(meshNode.GetMesh())
main()
问题5 无人车转角有上限吗,允许倒车吗
相关接口描述如下,即不允许倒车,具体范围如下
问题6 SDK文档有些传参回参描述不清晰
组委会正在全力梳理SDK文档,并对其进行细化,将在近期发布新版SDK接口说明文档,请各位选手留意大赛官网、答疑仓库及微信群等相关渠道