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

配置Wsg控制器时已连接状态端口仍触发Multiplexer输入端口未连接错误

问题分析与解决:WSG控制器端口未连接错误

你在修改MakeManipulationStation适配自定义设置时,未改动Iiwa和WSG的添加逻辑,但配置WSG时触发以下错误:

RuntimeError: InputPort::Eval(): required InputPort[0] (u0) of System ::_::wsg1_controller::drake/systems/StateInterpolatorWithDiscreteDerivative@0000562a7a82aa10::drake/systems/Multiplexer@0000562a7aaa90c0 (Multiplexer) is not connected

你的WSG配置函数如下:

def ConfigureWsg(builder, plant, wsg, name='wsg', time_step=0.002):
    # Add wsg controller
    wsg_controller = builder.AddSystem(SchunkWsgPositionController(time_step=time_step))
    wsg_controller.set_name(f"{name}_controller")
    builder.Connect(wsg_controller.get_generalized_force_output_port(),
                    plant.get_actuation_input_port(wsg))
    builder.Connect(plant.get_state_output_port(wsg),
                    wsg_controller.get_state_input_port())
    builder.ExportInput(wsg_controller.get_desired_position_input_port(),
                        f"{name}_position")
    builder.ExportInput(wsg_controller.get_force_limit_input_port(),
                        f"{name}_force_limit")
    wsg_mbp_state_to_wsg_state = builder.AddSystem(
        MakeMultibodyStateToWsgStateSystem())
    builder.Connect(plant.get_state_output_port(wsg),
                    wsg_mbp_state_to_wsg_state.get_input_port())
    builder.ExportOutput(wsg_mbp_state_to_wsg_state.get_output_port(),
                         f"{name}_state_measured")
    builder.ExportOutput(wsg_controller.get_grip_force_output_port(),
                         f"{name}_force_measured")

错误原因

错误指向的Multiplexer是SchunkWsgPositionController内部StateInterpolatorWithDiscreteDerivative的子系统,根源是导出的输入端口未被连接信号源:

  1. 你的配置函数通过ExportInput暴露了{name}_position(期望位置)和{name}_force_limit(力限制)两个输入端口,但这只是对外暴露端口,并没有为它们提供实际的输入信号。
  2. SchunkWsgPositionController内部依赖这两个输入运行:期望位置会被传入内部的插值器做求导处理,而这个插值器的输入端口(对应错误中的Multiplexer输入端口0)因为外部未连接信号,导致系统运行时触发未连接错误。

解决方法

在调用ConfigureWsg之后,必须给这两个导出的输入端口连接具体的信号源(比如常数默认值、轨迹生成器输出等)。示例代码如下:

# 假设调用ConfigureWsg时使用的name是'wsg'
# 1. 给WSG设置默认期望位置(示例:0.08米,对应张开状态)
default_wsg_pos = builder.AddSystem(ConstantVectorSource([0.08]))
builder.Connect(default_wsg_pos.get_output_port(),
                builder.GetInputPort("wsg_position"))

# 2. 设置默认力限制(示例:40N)
default_wsg_force_limit = builder.AddSystem(ConstantVectorSource([40.0]))
builder.Connect(default_wsg_force_limit.get_output_port(),
                builder.GetInputPort("wsg_force_limit"))

额外检查点

  • 确保在调用builder.Build()之前,所有通过ExportInput暴露的必需输入端口都已完成连接;
  • 若从外部系统传递信号,需确认外部输出端口与这些输入端口的维度匹配(WSG期望位置和力限制均为1维向量)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 20:40:25