Go to Post The world is run by those who show up. - apalrd [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 13-01-2012, 21:54
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 588
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
The network tables are used (among other things) sending data between the robot and laptop for the SmartDashboard. So can you just verify that you also get those errors without logging to the SmartDashboard?

Also, if you are using an incorrect gesture, like arms out of alignment, you'll also get zeroes back. Can you verify that? The driver station and default dashboard will show feedback to tell you if the gestures are being correctly interpreted.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi