gpt4 book ai didi

c# - 当我尝试移动 Kinect 电机时应用程序卡住

转载 作者:太空宇宙 更新时间:2023-11-03 13:13:39 24 4
gpt4 key购买 nike

我正在尝试移动 Kinect 的电机。它看起来很简单,但它不起作用,我的应用程序被卡住了。我正在使用 Visual Studio 2013 和 WPF,这是我的代码:

代码隐藏:

    private void MotorSliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
Angle.Content = (int)MotorSlider.Value;
}

private void ButtonClick(object sender, RoutedEventArgs e)
{
sensor.ElevationAngle = (int)Angle.Content;
}

XAML:

<Slider x:Name="MotorSlider" HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="262" Maximum="27" SmallChange="1" Minimum="-27" ValueChanged="MotorSliderValueChanged"/>
<Label x:Name="Angle" Content="0" HorizontalAlignment="Left" Height="32" Margin="277,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="43" FontSize="18"/>
<Button Content="Change angle" HorizontalAlignment="Left" Height="32" Margin="336,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="102" Click="ButtonClick"/>

任何线索为什么它会卡住?它会引发 System.InvalidOperationException:此 API 已从 HRESULT 返回异常:0x8007000D

谢谢。

最佳答案

这可能是由于电动倾斜移动得太快(即 ElevationAngle 属性设置得太快)造成的结果。

据官方documentation :

You must allow at least 20 seconds of rest after 15 consecutive changes. If your application exceeds these limits, the tilt motor may experience a lock period during which attempting to set the elevation angle will result in an error code.

同一页面的“社区添加”部分也证实了这一点:

If the tilt motor limits are exceeded and the runtime has locked the tilt motor to allow it to rest, attempts to access this property result in throwing an InvalidOperationException during the tilt motor lock period.

为了解决这个问题,我在 Microsoft 的一个示例(我不记得是哪个示例)中看到,在更改 ElevationAngle 属性后,他们明确避免对该属性进行任何其他更改1.35 秒的时间。

此外,如果您尝试在 Kinect 传感器未运行时更改 ElevationAngle 属性,您会得到一个 InvalidOperationException。来自上述同一页面:

If the ElevationAngle property is accessed while the Kinect sensor is not running (i.e., the Start method has not been called), an InvalidOperationException will be thrown.

关于c# - 当我尝试移动 Kinect 电机时应用程序卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27428226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com