使用PID子系统控制执行器

More advanced subsystems will use sensors for feedback to get guaranteed results for operations like setting elevator heights or wrist angles. PIDSubsystems use feedback to control the actuator and drive it to a particular position. In this example we use an elevator with a 10-turn potentiometer connected to it to give feedback on the height. The PIDSubsystem has a built-in PIDController to automatically control the mechanism to the correct setpoints.

创建一个PID子系统

../../../../../_images/pidsubsystem-actuators-1.png

创建一个使用反馈来控制机制的位置或速度的子系统非常容易。

  1. 将PID子系统从面板拖到机械手描述中的子系统文件夹中

  2. 将 PID 子系统重命名为对子系统更有意义的名称,在本例中为升降机

请注意,机械手说明的某些部分已变为红色。这表明这些组件(PIDSubsystem)尚未完成,需要填写。缺失或不正确的属性以红色显示。

将传感器和执行器添加到PID子系统

../../../../../_images/pidsubsystem-actuators-2.png

为PID子系统添加缺少的组件

  1. 将执行器(电机控制器)拖到特定的子系统中-在本例中为电梯

  2. 将将用于反馈的传感器拖动到子系统,在这种情况下,该传感器是一个电位计,可提供电梯高度反馈。

填写PID参数

../../../../../_images/pidsubsystem-actuators-3.png

需要填写 P、I 和 D 值以获得所需的组件灵敏度和稳定性。对于我们的升降机,我们使用 6.0 和 0 的比例常数来表示 I 和 D 项。

创建设定点常数

../../../../../_images/pidsubsystem-actuators-4.png

为了更轻松地管理升降机设定值,我们将创建常量来管理设定值。单击常量框以显示常量对话框。

../../../../../_images/pidsubsystem-actuators-5.png

单击:guilabel:添加常量 按钮

../../../../../_images/pidsubsystem-actuators-6.png
  1. 填写常量的名称,在本例中:底部

  2. 从下拉菜单中选择常量的类型,在本例中:双精度小数

  3. 为常量选择一个值,在本例中为:4.65

  4. 点击:guilabel:add constant 继续添加常量

  5. After entering all constants, Click Save and close