Skip to content

Commit 57b8d64

Browse files
stevenlovegroveqdot
authored andcommitted
Modified CSharp Tilt sample to demonstrate horizon following
The Kinect tilt control is relative to the horizon. This update modifies the CSharp sample to demonstrate this. Signed-off-by: Steven Lovegrove <[email protected]>
1 parent 626e388 commit 57b8d64

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

csharp/OpenKinectConsole/OpenKinectConsole.cs

+28-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,41 @@ namespace OpenKinectConsole
1111
{
1212
class OpenKinectConsole
1313
{
14+
static void Usage()
15+
{
16+
Console.WriteLine(
17+
"Usage:\n " +
18+
System.IO.Path.GetFileName(Environment.GetCommandLineArgs()[0]) +
19+
" [--horizon | (pos)]"
20+
);
21+
}
22+
1423
static void Main(string[] args)
1524
{
1625
KinectMotor motor = new KinectMotor();
1726

1827
if( args.Length ==1 )
1928
{
20-
sbyte pos = sbyte.Parse(args[0]);
21-
motor.SetTilt(pos);
29+
if( args[0] == "--horizon" )
30+
{
31+
// Demonstrate horizon following
32+
Console.WriteLine("Press any key to exit");
33+
while(Console.KeyAvailable == false)
34+
{
35+
motor.SetTilt(0);
36+
Thread.Sleep(TimeSpan.FromMilliseconds(100));
37+
}
38+
}else{
39+
// User defined value
40+
sbyte pos = sbyte.Parse(args[0]);
41+
motor.SetTilt(pos);
42+
}
2243
}else{
44+
Usage();
45+
46+
Console.WriteLine("Demo sequence started");
47+
48+
// Sample Sequence
2349
ExerciseMotor(motor,+50);
2450
ExerciseMotor(motor,-50);
2551
ExerciseMotor(motor,+60);
@@ -28,7 +54,6 @@ static void Main(string[] args)
2854
}
2955

3056
Console.WriteLine("done");
31-
Console.ReadKey();
3257
}
3358

3459
private static void ExerciseMotor(KinectMotor motor, sbyte pos)

0 commit comments

Comments
 (0)