@@ -28,27 +28,22 @@ void AppManager::setup(){
28
28
timeOfLastUpdate = elapsedTimeInSeconds ();
29
29
30
30
// set up applications
31
- mqttApp = new MqttTransmissionApp ();
32
- mqttApp->setRefForShapeIOManager (m_serialShapeIOManager);
31
+ mqttApp = new MqttTransmissionApp (m_serialShapeIOManager);
33
32
applications[" mqttTransmission" ] = mqttApp;
34
33
35
- videoPlayerApp = new VideoPlayerApp ();
36
- videoPlayerApp->setRefForShapeIOManager (m_serialShapeIOManager);
34
+ videoPlayerApp = new VideoPlayerApp (m_serialShapeIOManager);
37
35
applications[" videoPlayer" ] = videoPlayerApp;
38
36
videoPlayerApp->setup ();
39
37
40
38
// set up debugging application
41
39
// and the debugging apps, too
42
- axisCheckerApp = new AxisCheckerApp ();
43
- axisCheckerApp->setRefForShapeIOManager (m_serialShapeIOManager);
40
+ axisCheckerApp = new AxisCheckerApp (m_serialShapeIOManager);
44
41
applications[" axisChecker" ] = axisCheckerApp;
45
42
46
- kinectDebugApp = new KinectDebugApp (kinectManager);
47
- kinectDebugApp->setRefForShapeIOManager (m_serialShapeIOManager);
43
+ kinectDebugApp = new KinectDebugApp (m_serialShapeIOManager, kinectManager);
48
44
applications[" kinectDebug" ] = kinectDebugApp;
49
45
50
- depthDebugApp = new DepthDebugApp ();
51
- depthDebugApp->setRefForShapeIOManager (m_serialShapeIOManager);
46
+ depthDebugApp = new DepthDebugApp (m_serialShapeIOManager);
52
47
applications[" depthDebug" ] = depthDebugApp;
53
48
54
49
kinectHandWavy = new KinectHandWavy (m_serialShapeIOManager,kinectManager);
@@ -72,35 +67,41 @@ void AppManager::setup(){
72
67
void AppManager::setupShapeDisplayManagement () {
73
68
// initialize communication with the shape display
74
69
// This is where the particulars of the shape display are set (i.e. TRANSFORM, inFORM, or any other physical layout).
75
- m_serialShapeIOManager = new TransformIOManager (kinectManager);
70
+ string shapeDisplayToUse = " inFORM" ;
71
+
72
+ if (shapeDisplayToUse == " TRANSFORM" ) {
73
+ m_serialShapeIOManager = new TransformIOManager (kinectManager);
74
+ } else if (shapeDisplayToUse == " inFORM" ) {
75
+ m_serialShapeIOManager = new InFormIOManager (kinectManager);
76
+ } else {
77
+ throw " unknown shape display type: " + shapeDisplayToUse;
78
+ }
76
79
77
80
printf (" Setting up Shape Display Management\n " );
78
81
82
+ // Size the pin arrays correctly based on the hardware specific dimension, and initialize them with zero values
83
+ heightsForShapeDisplay = std::vector<std::vector<unsigned char >>(m_serialShapeIOManager->shapeDisplaySizeX , std::vector<unsigned char >(m_serialShapeIOManager->shapeDisplaySizeY ));
84
+ heightsFromShapeDisplay = std::vector<std::vector<unsigned char >>(m_serialShapeIOManager->shapeDisplaySizeX , std::vector<unsigned char >(m_serialShapeIOManager->shapeDisplaySizeY ));
79
85
80
86
// initialize shape display pin configs
81
87
PinConfigs pinConfigs;
82
88
pinConfigs.timeOfUpdate = elapsedTimeInSeconds ();
83
- pinConfigs.gainP = DEFAULT_GAIN_P ;
84
- pinConfigs.gainI = DEFAULT_GAIN_I ;
85
- pinConfigs.maxI = DEFAULT_MAX_I ;
86
- pinConfigs.deadZone = DEFAULT_DEAD_ZONE ;
87
- pinConfigs.maxSpeed = DEFAULT_MAX_SPEED ;
89
+ pinConfigs.gainP = m_serialShapeIOManager-> getGainP () ;
90
+ pinConfigs.gainI = m_serialShapeIOManager-> getGainI () ;
91
+ pinConfigs.maxI = m_serialShapeIOManager-> getMaxI () ;
92
+ pinConfigs.deadZone = m_serialShapeIOManager-> getDeadZone () ;
93
+ pinConfigs.maxSpeed = m_serialShapeIOManager-> getMaxSpeed () ;
88
94
m_serialShapeIOManager->setGlobalPinConfigs (pinConfigs);
89
95
timeOfLastPinConfigsUpdate = elapsedTimeInSeconds ();
90
96
91
- // clear height and pin config buffers
92
- for (int x = 0 ; x < SHAPE_DISPLAY_SIZE_X; x++) {
93
- for (int y = 0 ; y < SHAPE_DISPLAY_SIZE_Y; y++) {
94
- heightsForShapeDisplay[x][y] = 0 ;
95
- heightsFromShapeDisplay[x][y] = 0 ;
96
- pinConfigsForShapeDisplay[x][y] = pinConfigs;
97
- }
98
- }
97
+
98
+ // Set the dimensions of the pinConfigs
99
+ pinConfigsForShapeDisplay.resize (m_serialShapeIOManager->shapeDisplaySizeX , std::vector<PinConfigs>(m_serialShapeIOManager->shapeDisplaySizeY , pinConfigs));
99
100
100
101
// allocate height pixels objects and clear contents
101
- heightPixelsForShapeDisplay.allocate (SHAPE_DISPLAY_SIZE_X, SHAPE_DISPLAY_SIZE_Y , 1 );
102
+ heightPixelsForShapeDisplay.allocate (m_serialShapeIOManager-> shapeDisplaySizeX , m_serialShapeIOManager-> shapeDisplaySizeY , 1 );
102
103
heightPixelsForShapeDisplay.set (0 );
103
- heightPixelsFromShapeDisplay.allocate (SHAPE_DISPLAY_SIZE_X, SHAPE_DISPLAY_SIZE_Y , 1 );
104
+ heightPixelsFromShapeDisplay.allocate (m_serialShapeIOManager-> shapeDisplaySizeX , m_serialShapeIOManager-> shapeDisplaySizeY , 1 );
104
105
heightPixelsFromShapeDisplay.set (0 );
105
106
106
107
// allocate shape display graphics container and clear contents
@@ -126,8 +127,8 @@ void AppManager::update(){
126
127
// note: manually looping over all pixels is important! the underlying
127
128
// ofPixels char array is stored as unsigned char[y][x], while the
128
129
// shape display heights are stored as unsigned char[x][y]
129
- for (int x = 0 ; x < SHAPE_DISPLAY_SIZE_X ; x++) {
130
- for (int y = 0 ; y < SHAPE_DISPLAY_SIZE_Y ; y++) {
130
+ for (int x = 0 ; x < m_serialShapeIOManager-> shapeDisplaySizeX ; x++) {
131
+ for (int y = 0 ; y < m_serialShapeIOManager-> shapeDisplaySizeY ; y++) {
131
132
int xy = heightPixelsFromShapeDisplay.getPixelIndex (x, y);
132
133
heightPixelsFromShapeDisplay[xy] = heightsFromShapeDisplay[x][y];
133
134
}
@@ -143,8 +144,8 @@ void AppManager::update(){
143
144
// note: manually looping over all pixels is important! the underlying
144
145
// ofPixels char array is stored as unsigned char[y][x], while the
145
146
// shape display heights are stored as unsigned char[x][y]
146
- for (int x = 0 ; x < SHAPE_DISPLAY_SIZE_X ; x++) {
147
- for (int y = 0 ; y < SHAPE_DISPLAY_SIZE_Y ; y++) {
147
+ for (int x = 0 ; x < m_serialShapeIOManager-> shapeDisplaySizeX ; x++) {
148
+ for (int y = 0 ; y < m_serialShapeIOManager-> shapeDisplaySizeY ; y++) {
148
149
int xy = heightPixelsForShapeDisplay.getPixelIndex (x, y);
149
150
heightsForShapeDisplay[x][y] = heightPixelsForShapeDisplay[xy];
150
151
}
0 commit comments