WPILib 2012
WPILibRoboticsLibraryforFRC
Kinect.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2011. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef __KINECT_H__
00008 #define __KINECT_H__
00009 
00010 #include "SensorBase.h"
00011 #include "Skeleton.h"
00012 
00013 #include <semLib.h>
00014 
00015 #define kNumSkeletons 1
00016 
00017 class Kinect : public SensorBase
00018 {
00019 public:
00020         typedef enum {kNotTracked, kPositionOnly, kTracked} SkeletonTrackingState;
00021         typedef enum {kClippedRight = 1, kClippedLeft = 2, kClippedTop = 4, kClippedBottom = 8} SkeletonQuality;
00022         typedef struct
00023         {
00024                 float x;
00025                 float y;
00026                 float z;
00027                 float w;
00028         } Point4;
00029 
00030         int GetNumberOfPlayers();
00031         Point4 GetFloorClipPlane();
00032         Point4 GetGravityNormal();
00033         Skeleton GetSkeleton(int skeletonIndex = 1);
00034         Point4 GetPosition(int skeletonIndex = 1);
00035         UINT32 GetQuality(int skeletonIndex = 1);
00036         SkeletonTrackingState GetTrackingState(int skeletonIndex = 1);
00037 
00038         static Kinect *GetInstance();
00039 
00040 private:
00041         Kinect();
00042         ~Kinect();
00043         void UpdateData();
00044 
00045         DISALLOW_COPY_AND_ASSIGN(Kinect);
00046 
00047         UINT32 m_recentPacketNumber;
00048         SEM_ID m_dataLock;
00049         int m_numberOfPlayers;
00050         Point4 m_floorClipPlane;
00051         Point4 m_gravityNormal;
00052         Point4 m_position[kNumSkeletons];
00053         UINT32 m_quality[kNumSkeletons];
00054         SkeletonTrackingState m_trackingState[kNumSkeletons];
00055         Skeleton m_skeletons[kNumSkeletons];
00056 
00057         // TODO: Include structs for this data format (would be clearer than 100 magic numbers)
00058         char m_rawHeader[46];
00059         char m_rawSkeletonExtra[42];
00060         char m_rawSkeleton[242];
00061 
00062         static Kinect *_instance;
00063 };
00064 
00065 #endif
00066 
 All Classes Functions Variables