ConditionForceEffect.SetParameters 方法

定义

设置条件力回馈效果的参数。

public:
 virtual void SetParameters(float3 direction, float positiveCoefficient, float negativeCoefficient, float maxPositiveMagnitude, float maxNegativeMagnitude, float deadZone, float bias) = SetParameters;
void SetParameters(float3 const& direction, float const& positiveCoefficient, float const& negativeCoefficient, float const& maxPositiveMagnitude, float const& maxNegativeMagnitude, float const& deadZone, float const& bias);
public void SetParameters(Vector3 direction, float positiveCoefficient, float negativeCoefficient, float maxPositiveMagnitude, float maxNegativeMagnitude, float deadZone, float bias);
function setParameters(direction, positiveCoefficient, negativeCoefficient, maxPositiveMagnitude, maxNegativeMagnitude, deadZone, bias)
Public Sub SetParameters (direction As Vector3, positiveCoefficient As Single, negativeCoefficient As Single, maxPositiveMagnitude As Single, maxNegativeMagnitude As Single, deadZone As Single, bias As Single)

参数

direction
Vector3 Vector3

float3

描述每个轴上效果的方向和数量级的向量。 每个轴的范围为 -1.0 到 1.0,并且独立于其他轴。 为轴指定负值会将输入值从轴反转。

positiveCoefficient
Single

float

线条的斜率,描述当输入沿指定轴沿正方向离开中心点时力增加的速度。 范围从 -infinity 到 +infinity。

negativeCoefficient
Single

float

线条的斜率,描述当输入沿指定轴沿负方向从中心点移开时力增加的速度。 范围从 -infinity 到 +infinity。

maxPositiveMagnitude
Single

float

当输入沿指定轴沿正方向偏离中心点时,力回馈的最大幅度。 范围为 0 到 1.0。

maxNegativeMagnitude
Single

float

当输入沿指定轴沿负方向偏离中心点时,力回馈的最大幅度。 范围为 0 到 1.0。

deadZone
Single

float

指定以下不应用力回馈的值。 范围从 0.0 到 1.0,不对称地围绕中心点应用。

bias
Single

float

在效果计算中与中心点的偏移量。 范围为 -1.0 到 1.0。

示例

// Create a spring effect and load it into the device.  This is an async operation
// since it might take a brief amount of time for the driver to complete this.
ConditionForceEffect ^ springEffect = ref new ConditionForceEffect(ConditionEffectKind::Spring);
if (springEffect)
{
    IAsyncAction ^ action = motor->LoadEffectAsync(springEffect);
    concurrency::create_task(action).then([=]()
    {
        // Make sure the effect was loaded successfully.  There is a finite amount
        // of storage available for effects in the hardware, so this is expected
        // to fail if there is not enough room.  Alternatively, the motor might
        // not support the requested effect (although this is rare).
        if (action->Status == AsyncStatus::Completed)
        {
            // Set the parameters for the spring effect.  Note how the parameters
            // can be modified after the effect has been loaded into the hardware.
            springEffect->SetParameters(
                { 1.0f, 0.0f, 0.0f },   // Unit vector indicating the effect applies to the X axis
                1.0f, -1.0f,            // Full strength when the wheel is turned to its maximum angle
                0.3f, -0.3f,            // Limit the maximum feedback force to 30%
                0.025f,                 // Apply a small dead zone when the wheel is centered
                0.0f);                  // Equal force in both directions

            // Go ahead and start the effect, since we want this running all the time
            springEffect->StartEffect();
        }
    });
}          

注解

下图演示了参数对 SetParameters 的影响:

参数对力的影响。 在图中,所有系数值均为正值。  系数的负值将导致 (绿色线的力) 在橙色轴线下方为负值,从而有效地反转力的方向。  不建议这样做,因为除非仔细操作,否则通常会导致正反馈循环,从而导致电机在该方向上饱和。 数量级和死区值始终是正值,并且各自轴是对称的。  (对于死区演示了这一点,但震级的工作方式相同 - 值 0.5 将反馈力限制为 -0.5 到 +0.5.) 此处显示的偏差为 0.0,但更改值只是以一种或另一种方式滑动中等橙色线。  请注意,这不会影响由系数值定义的绿线的斜率。

适用于