如何用c#和Kinect控制伺服电机? [英] How to control servomotor with c# and Kinect?

查看:611
本文介绍了如何用c#和Kinect控制伺服电机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究一个使用Kinect来检查一个人的手的位置的c#程序.然后,根据人的手(x,y)将显示在画布上的桌子图像移动"到四个位置:上,下,左或右.
我想知道是否可以转移已经使用Visual C#2010和Kinect SDK创建的程序,以直接或通过Microsoft Robotics Studio与NXT进行交互.
我希望我的代码与NXT通信并激活伺服电机,而不要更改NUI上的图像位置.有可能吗?

不一定是Lego NXT,而是任何其他允许我通过程序移动伺服电机的系统.我将不胜感激!

例如:在此代码中,Kinect跟踪我的右手,如果满足条件,它将使图像移位为Y(向上移动).取而代之的是,我想知道是否可以编写代码以不太复杂的方式通过NXT将信号发送到伺服电机.

I''m currently working on a c# program that uses Kinect to check the position of a person''s hand. It then "moves" an image of a table that is displayed on a canvas according to the person''s hand (x,y) to 4 positions: up, down, left or right.
I’d like to know if I can transfer the program I have already created using Visual C# 2010 and Kinect SDK to interact with NXT directly or via Microsoft Robotics Studio.
I want my code to communicate with NXT and activate a servomotor instead of changing the image position on the NUI. Would that be possible?

It doesn''t have to be Lego NXT but any other system that would allow me to move servo motors via my program. I''d appreciate any ideas!

e.g: in this code Kinect tracks my right hand and if the conditions are met it displaces the image in Y (for up movement). Instead of that I''d like to know if I can write a code to send a signal to a servo motor via NXT in a not too complicated way.

if (wristRight.Z > shoulderRight.Z - 0.20 && wristRight.Z < shoulderRight.Z + 0.20)
                {
                    if (sideAngle >= 285 && sideAngle <= 320)
                    {
                        speed = 4;
                        positionY = positionY - speed;
                    }
                 .
                 .
                 .

Canvas.SetLeft(Table, positionX - Table.Width / 2);
Canvas.SetTop(Table, positionY - Table.Height / 2);

推荐答案



是的你可以!我有一篇文章,详细介绍了如何在CodeProject上从C#控制您的机器人.在这里看看:

使用NKH Mindsqualls库的基本机器人控制 [ ^ ]

它使用NKH Mindsqualls库,您可能希望查看是否有新版本.它真的很好用,我的文章展示了如何做基础,包括运行电动机.

希望这会有所帮助,
埃德

查看此页面以获得使用库的快速入门指南,它具有所有要点:
http://www.mindsqualls.net/QuickStart_2_0.aspx [
Hi There,

Yes you can! And I have an article that details how to control your robot from C# here on CodeProject. Have a look here:

Basic Robot Control using NKH Mindsqualls Libraries[^]

It uses the NKH Mindsqualls library, you may wish to see if there is a new version. It works really well and my article shows how to do the basics which includes running motors.

Hope this helps,
Ed

Have a look at this page for a quick start guide to getting working with the library, it has all the essentials:
http://www.mindsqualls.net/QuickStart_2_0.aspx[^]

(There is also v2.2 of the library available that I think you may want to download.)


这篇关于如何用c#和Kinect控制伺服电机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆