// uncomment next line to "log" the output frames - save them as pnm to the working directory
//#define PPC_DEBUG
+// uncomment next line to print orte state
+#define ORTE_DEBUG
// modes definitions
#define MODE_QUIT 0x01
while(ORTE_CAMERA_CONTROL) {
//if color changed during recognition, restart the mode to load appropriate masks
- if(orte.camera_control.game_color != currentColor) return MODE_RECOGNIZE;
+ if(orte.robot_switches.team_color != currentColor) return MODE_RECOGNIZE;
#ifdef ROZKUK_DEBUG /************ DEBUG SESSION ONLY ************/
/* keyboard events handeling */
cvMoveWindow(WINDOW_PROD, cvQueryFrame(capture)->width, cvQueryFrame(capture)->height+50);
#endif /*----------- DEBUG SESSION ONLY -----------*/
//load masks and run recognition mode, then free masks (they are in memory only while in recognition mode)
- color = orte.camera_control.game_color;
+ color = orte.robot_switches.team_color;
if((ret=loadMasks((color==BLUE ? clBLUE : clYELLOW)))) return ret;
mode = modeRecognize(capture, color);
freeMasks();
case NEW_DATA:
// nothing to do - changes will be processed in the recognition loop
#ifdef ORTE_DEBUG
- printf("orte: New data: ctrl %d, clr %d\n", orte_data->camera_control.on, orte_data->camera_control.game_color);
+ fprintf(stderr, "orte: New camera data: ctrl %d", orte_data->camera_control.on);
#endif /*----------- ORTE_DEBUG -----------*/
break;
case DEADLINE:
- printf("ORTE deadline occurred - CMR_CTRL receive\n");
+ fprintf(stderr, "ORTE deadline occurred - CMR_CTRL receive\n");
+ break;
+ }
+}
+
+/******************************************************************************/
+
+/** Orte switches control callback function. */
+void rcv_robot_switches_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam) {
+#ifdef ORTE_DEBUG
+ struct robot_switches_type *instance = (struct robot_switches_type *)vinstance;
+#endif /*----------- ORTE_DEBUG -----------*/
+
+ switch (info->status) {
+ case NEW_DATA:
+ // nothing to do - changes will be processed in the recognition loop
+#ifdef ORTE_DEBUG
+ fprintf(stderr, "orte: New switches data: clr %d", instance->team_color);
+#endif /*----------- ORTE_DEBUG -----------*/
+ case DEADLINE:
+ fprintf(stderr, "ORTE deadline occurred - CMR_CTRL receive\n");
break;
}
}
}
robottype_publisher_camera_result_create(&orte, NULL, NULL);
robottype_subscriber_camera_control_create(&orte, rcv_cmr_ctrl_cb, &orte);
+ robottype_subscriber_robot_switches_create(&orte, rcv_robot_switches_cb, &orte);
modeManager(START_MODE);