在add_agent() 函数中,默认将添加的个体放在仿真环境的坐标原点。我们可以添加一个 AgentState 类型的参数,在其中指定添加个体的位置、角度等信息,例如:
state = lgsvl.AgentState()
state.transform.position = lgsvl.Vector(210, 10, 200) # 可以将 x,y,z 三个坐标包装成 Vector 类型数据赋值
state.transform.rotation.x = 0
state.transform.rotation.y = 270
state.transform.rotation.z = 0 # 也可以单独设置各个分量
a = sim.add_agent("XE_Rigged-apollo", lgsvl.AgentType.EGO, state)
仿真环境中 x,y,z 三个坐标构成左手坐标系,其中 y 轴始终垂直指向上方,若 x 轴指向车后方,则 z 轴指向车右侧。rotation 中三个角度对应绕 x,y,z 轴顺时针旋转的角度。
References: