jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/
|
| 2 | /* Copyright (c) FIRST 2011. All Rights Reserved. */
|
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
|
| 4 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
| 5 | /*----------------------------------------------------------------------------*/
|
| 6 |
|
| 7 | #ifndef __KINECT_H__
|
| 8 | #define __KINECT_H__
|
| 9 |
|
| 10 | #include "SensorBase.h"
|
| 11 | #include "Skeleton.h"
|
| 12 |
|
| 13 | #include <semLib.h>
|
| 14 |
|
| 15 | #define kNumSkeletons 1
|
| 16 |
|
| 17 | /**
|
| 18 | * Handles raw data input from the FRC Kinect Server
|
| 19 | * when used with a Kinect device connected to the Driver Station.
|
| 20 | * Each time a value is requested the most recent value is returned.
|
| 21 | * See Getting Started with Microsoft Kinect for FRC and the Kinect
|
| 22 | * for Windows SDK API reference for more information
|
| 23 | */
|
| 24 | class Kinect : public SensorBase
|
| 25 | {
|
| 26 | public:
|
| 27 | typedef enum {kNotTracked, kPositionOnly, kTracked} SkeletonTrackingState;
|
| 28 | typedef enum {kClippedRight = 1, kClippedLeft = 2, kClippedTop = 4, kClippedBottom = 8} SkeletonQuality;
|
| 29 | typedef struct
|
| 30 | {
|
| 31 | float x;
|
| 32 | float y;
|
| 33 | float z;
|
| 34 | float w;
|
| 35 | } Point4;
|
| 36 |
|
| 37 | int GetNumberOfPlayers();
|
| 38 | Point4 GetFloorClipPlane();
|
| 39 | Point4 GetGravityNormal();
|
| 40 | Skeleton GetSkeleton(int skeletonIndex = 1);
|
| 41 | Point4 GetPosition(int skeletonIndex = 1);
|
| 42 | UINT32 GetQuality(int skeletonIndex = 1);
|
| 43 | SkeletonTrackingState GetTrackingState(int skeletonIndex = 1);
|
| 44 |
|
| 45 | static Kinect *GetInstance();
|
| 46 |
|
| 47 | private:
|
| 48 | Kinect();
|
| 49 | ~Kinect();
|
| 50 | void UpdateData();
|
| 51 |
|
| 52 | DISALLOW_COPY_AND_ASSIGN(Kinect);
|
| 53 |
|
| 54 | UINT32 m_recentPacketNumber;
|
| 55 | SEM_ID m_dataLock;
|
| 56 | int m_numberOfPlayers;
|
| 57 | Point4 m_floorClipPlane;
|
| 58 | Point4 m_gravityNormal;
|
| 59 | Point4 m_position[kNumSkeletons];
|
| 60 | UINT32 m_quality[kNumSkeletons];
|
| 61 | SkeletonTrackingState m_trackingState[kNumSkeletons];
|
| 62 | Skeleton m_skeletons[kNumSkeletons];
|
| 63 |
|
| 64 | // TODO: Include structs for this data format (would be clearer than 100 magic numbers)
|
| 65 | char m_rawHeader[46];
|
| 66 | char m_rawSkeletonExtra[42];
|
| 67 | char m_rawSkeleton[242];
|
| 68 |
|
| 69 | static Kinect *_instance;
|
| 70 | };
|
| 71 |
|
| 72 | #endif
|
| 73 |
|