You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Drake运行时错误:PyFunctionConstraint无法推断AutoDiffXd标量类型求助

Drake数学规划中PyFunctionConstraint类型推断错误问题

求解数学规划问题时,Drake抛出如下RuntimeError:

PyFunctionConstraint: Output must be of scalar type AutoDiffXd, but unable to infer scalar type.

触发该错误的约束函数代码如下:

def non_penetration_constraint(q):
    plant_ad.SetPositions(context_ad, q)
    Distances = np.zeros(6, dtype=q.dtype)
    i = 0
    for name in Claw_name:
        g_ids = body_geometries[name]
        assert(len(g_ids) == 1)
        Distances[i] = query_object.ComputeSignedDistancePairClosestPoints(
            Worldbody_id, g_ids[0]).distance
        i += 1

    return Distances

调用该约束的代码为:

for n in range(N-1):
    # Non penetration constraint
    prog.AddConstraint(non_penetration_constraint,
                       lb = [0] * nf,
                       ub = [0] * nf,
                       vars = (q[:, n]))

请问有谁遇到过类似问题吗?


内容的提问来源于stack exchange,提问作者Remi Makinwa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 23:40:20