英文:
Adapt port based on state
问题
Suppose I am using the PIDController class and I want to update the "object" being pid controlled based on the state of a DiscreteLeafSystem which is changing periodically over time.
For example, suppose I randomly sample an object index from 1-10 every 1 second, and I want a single PIDController that pulls the sampled object to a setpoint.
How do I do this?
Since the object to be controlled by the PIDController class is passed in via an input port, my question seems to boil down to: how do we adaptively rewire input ports to a LeafSystem (PIDController in this case) based on a discrete-time state?
英文:
Suppose I am using the PIDController class and I want to update the "object" being pid controlled based on the state of a DiscreteLeafSystem which is changing periodically over time.
For example, suppose I randomly sample an object index from 1-10 every 1 second, and I want a single PIDController that pulls the sampled object to a setpoint.
How do I do this?
Since the object to be controlled by the PIDController class is passed in via an input port, my question seems to boil down to: how do we adaptively rewire input ports to a LeafSystem (PIDController in this case) based on a discrete-time state?
答案1
得分: 1
你无法动态重连,但可以使用 PortSwitch
来连接适当的逻辑。
但在这种特殊情况下,我认为编写自己的小型 LeafSystem 会更容易,该系统以整个 MultibodyPlant
状态为输入,并将整个 MultibodyPlant
激励作为输出。该系统应该对未被控制的激励值输出零,并为被控制的激励值实现 PID。
在 Python 中,您现在可以使用,例如:
ActuatorView = namedview("actuators", plant.GetActuatorNames())
view = ActuatorView.Zeros()
view.myinstance_myactuator = value
以帮助分配到状态和激励向量。
英文:
You can't dynamically rewire, but you can use PortSwitch
to wire up the appropriate logic.
But in this particular case, I would think that it would be easier to write your own little LeafSystem which take the entire MultibodyPlant
state as input and outputs the entire MultibodyPlant
actuation as output. This system should put out zero for the actuation values that are not being controller, and implement the PID for the ones that are.
In python, you can now use e.g.
ActuatorView = namedview("actuators", plant.GetActuatorNames())
view = ActuatorView.Zeros()
view.myinstance_myactuator = value
to help with the assignment into the state and actuation vectors.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论