使用PID子系统控制执行器

More advanced subsystems will use sensors for feedback to get guaranteed results for operations like setting elevator heights or wrist angles. 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. Rename the PID Subsystem to a more meaningful name for the subsystem, in this case Elevator

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

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

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

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

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

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

Fill in the PID Parameters

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

The P, I, and D values need to be filled in to get the desired sensitivity and stability of the component. In the case of our elevator we use a proportional constant of 6.0 and 0 for the I and D terms.

Create Setpoint Constants

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

In order to make it easier to manage elevator setpoints, we will create constants to manage the setpoints. Click on the constants box to bring up the constants dialog.

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

Click on the add constant button

../../../../../_images/pidsubsystem-actuators-6.png
  1. Fill in a name for the constant, in this case: Bottom

  2. Select a type for the constant from the drop-down menu, in this case: double

  3. Select a value for the constant, in this case: 4.65

  4. Click add constant to continue adding constants