Thread: Kinect Help
View Single Post
  #1   Spotlight this post!  
Unread 13-01-2012, 20:41
ProgrammerMike7 ProgrammerMike7 is offline
Registered User
AKA: Mike
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 13
ProgrammerMike7 will become famous soon enoughProgrammerMike7 will become famous soon enough
Kinect Help

Hello Everyone!

Today we started testing our Kinect with the sample KinectStick code (We program in C++). We setup the kinect and the skeleton displays fine on the dashboard and the Y-axis movement is shown accurately in the readouts beneath the skeletal viewer as we move our arms . However, whenever we try to access the KinectStick via our program, using stick.GetY(), it would only display 0 (we printed the value to the smart dashboard). We got this error whenever the robot was initialized:
Code:
ERROR: Error reading NetworkTables socket: errno=54 ...in Read() in C:/WindRiver/workspace/WPILib/NetworkTables/Reader.cpp at line 70
Here is the code we used (it's the exact same as the KinectStick example except two lines added for the Smart Dashboard):
Code:
#include "WPILib.h"

/**
 * This code demonstrates the use of the KinectStick
 * class to drive your robot during the autonomous mode
 * of the match, making it a hybrid machine. The gestures
 * used to control the KinectStick class are described in the
 * "Getting Started with the Microsoft Kinect for FRC" document
 */ 
class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	KinectStick leftArm;	//The Left arm should be constructed as stick 1
	KinectStick rightArm; 	//The Right arm should be constructed as stick 2
	Joystick stick;			//Joystick for teleop control

public:
	RobotDemo(void):
		myRobot(1, 2),	// these must be initialized in the same order
		leftArm(1),		// as they are declared above.
		rightArm(2),
		stick(1)
	{
		myRobot.SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		bool exampleButton;
	
		/*A loop is necessary to retrieve the latest Kinect data and update the motors */
		while(IsAutonomous()){
            /**
             * KinectStick axis values are accessed identically to those of a joystick
             * In this example the axis values have been scaled by ~1/3 for safer
             * operation when learning to use the Kinect.
             */
            myRobot.TankDrive(leftArm.GetY()*.33, rightArm.GetY()*.33);
            SmartDashboard::GetInstance()->Log(leftArm.GetY(), "LeftArm");
            SmartDashboard::GetInstance()->Log(rightArm.GetY(), "RightArm");
            
            /* An alternative illustrating that the KinectStick can be used just like a Joystick */
            //myRobot.TankDrive(leftArm, rightArm);

            /*Example illustrating that accessing buttons is identical to a Joystick */
            exampleButton = leftArm.GetRawButton(1);

            Wait(.01); /* Delay 10ms to reduce processing load */
		}
	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{
		myRobot.SetSafetyEnabled(true);
		while (IsOperatorControl())
		{
			myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
Has anyone been able to get the Kinect and the KinectStick objects working? Thanks!
__________________
Wait (-1)
Reply With Quote