Project: engagement_recognition License: BSD Dependencies:
Used by:
None |
engagement_recognition/src/recognition/states/state_factory.cppGo to the documentation of this file.00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Worcester Polytechnic Institute 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Worcester Polytechnic Institute. nor the names 00018 * of its contributors may be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 // @author Brett Ponsler (bponsler (at) wpi (dot) edu) 00035 #include "state_factory.h" 00036 00037 #include "../recognizers/recognizer_factory.h" 00038 #include "../lib/engagement_params.h" 00039 00040 // Include all the Directed Gaze states 00041 #include "../recognizers/directed_gaze/dg_start_state.h" 00042 #include "../recognizers/directed_gaze/dg_robot_directing_state.h" 00043 #include "../recognizers/directed_gaze/dg_human_directing_state.h" 00044 #include "../recognizers/directed_gaze/dg_shared_gaze_state.h" 00045 00046 // Include all the Mutual Facial Gaze States 00047 #include "../recognizers/mutual_facial_gaze/mfg_start_state.h" 00048 #include "../recognizers/mutual_facial_gaze/mfg_robot_waiting_state.h" 00049 #include "../recognizers/mutual_facial_gaze/mfg_human_waiting_state.h" 00050 #include "../recognizers/mutual_facial_gaze/mfg_mutual_facial_gaze_state.h" 00051 00052 // Include all the Adjacency Pair states 00053 #include "../recognizers/adjacency_pair/ap_start_state.h" 00054 #include "../recognizers/adjacency_pair/ap_robot_response_state.h" 00055 #include "../recognizers/adjacency_pair/ap_robot_waiting_state.h" 00056 #include "../recognizers/adjacency_pair/ap_human_response_state.h" 00057 #include "../recognizers/adjacency_pair/ap_human_waiting_state.h" 00058 00059 // Include all the Backchannel states 00060 #include "../recognizers/backchannel/bc_start_state.h" 00061 #include "../recognizers/backchannel/bc_robot_floor_state.h" 00062 #include "../recognizers/backchannel/bc_human_floor_state.h" 00063 00064 State *StateFactory::createState(factory::StateType type, std::string actor, 00065 EventSink *parent) 00066 { 00067 // Check the cases for the enumeration type 00068 switch (type) 00069 { 00070 case factory::DG_START: 00071 return new DGStartState(actor, parent); 00072 break; 00073 case factory::DG_ROBOT_DIRECTING: 00074 return new DGRobotDirectingState(actor, parent); 00075 break; 00076 case factory::DG_HUMAN_DIRECTING: 00077 return new DGHumanDirectingState(actor, parent); 00078 break; 00079 case factory::DG_SHARED_GAZE: 00080 return new DGSharedGazeState(actor, parent); 00081 break; 00082 case factory::MFG_START: 00083 return new MFGStartState(actor, parent); 00084 break; 00085 case factory::MFG_ROBOT_WAITING: 00086 return new MFGRobotWaitingState(actor, parent); 00087 break; 00088 case factory::MFG_HUMAN_WAITING: 00089 return new MFGHumanWaitingState(actor, parent); 00090 break; 00091 case factory::MFG_MUTUAL_FACIAL_GAZE: 00092 return new MFGMutualFacialGazeState(actor, parent); 00093 break; 00094 case factory::AP_START: 00095 return new APStartState(actor, parent); 00096 break; 00097 case factory::AP_ROBOT_RESPONSE: 00098 return new APRobotResponseState(actor, parent); 00099 break; 00100 case factory::AP_ROBOT_WAITING: 00101 return new APRobotWaitingState(actor, parent); 00102 break; 00103 case factory::AP_HUMAN_RESPONSE: 00104 return new APHumanResponseState(actor, parent); 00105 break; 00106 case factory::AP_HUMAN_WAITING: 00107 return new APHumanWaitingState(actor, parent); 00108 break; 00109 case factory::BC_START: 00110 return new BCStartState(actor, parent); 00111 break; 00112 case factory::BC_ROBOT_FLOOR: 00113 return new BCRobotFloorState(actor, parent); 00114 break; 00115 case factory::BC_HUMAN_FLOOR: 00116 return new BCHumanFloorState(actor, parent); 00117 break; 00118 default: 00119 return NULL; 00120 } 00121 } 00122 00123 std::string StateFactory::getType(factory::StateType type) 00124 { 00125 // Check the cases for the enumeration type 00126 switch (type) 00127 { 00128 case factory::DG_START: 00129 return DGStartState::type(); 00130 break; 00131 case factory::DG_ROBOT_DIRECTING: 00132 return DGRobotDirectingState::type(); 00133 break; 00134 case factory::DG_HUMAN_DIRECTING: 00135 return DGHumanDirectingState::type(); 00136 break; 00137 case factory::DG_SHARED_GAZE: 00138 return DGSharedGazeState::type(); 00139 break; 00140 case factory::MFG_START: 00141 return MFGStartState::type(); 00142 break; 00143 case factory::MFG_ROBOT_WAITING: 00144 return MFGRobotWaitingState::type(); 00145 break; 00146 case factory::MFG_HUMAN_WAITING: 00147 return MFGHumanWaitingState::type(); 00148 break; 00149 case factory::MFG_MUTUAL_FACIAL_GAZE: 00150 return MFGMutualFacialGazeState::type(); 00151 break; 00152 case factory::AP_START: 00153 return APStartState::type(); 00154 break; 00155 case factory::AP_ROBOT_RESPONSE: 00156 return APRobotResponseState::type(); 00157 break; 00158 case factory::AP_ROBOT_WAITING: 00159 return APRobotWaitingState::type(); 00160 break; 00161 case factory::AP_HUMAN_RESPONSE: 00162 return APHumanResponseState::type(); 00163 break; 00164 case factory::AP_HUMAN_WAITING: 00165 return APHumanWaitingState::type(); 00166 break; 00167 case factory::BC_START: 00168 return BCStartState::type(); 00169 break; 00170 case factory::BC_ROBOT_FLOOR: 00171 return BCRobotFloorState::type(); 00172 break; 00173 case factory::BC_HUMAN_FLOOR: 00174 return BCHumanFloorState::type(); 00175 break; 00176 default: 00177 return std::string(""); 00178 } 00179 } 00180 00181 factory::StateType StateFactory::getStartState(std::string type) 00182 { 00183 // Determine which type of state to create based on what 00184 // type of recognizer this is 00185 if (type == RecognizerFactory::getDirectedGazeType()) 00186 return factory::DG_START; 00187 else if (type == RecognizerFactory::getMutualFacialGazeType()) 00188 return factory::MFG_START; 00189 else if (type == RecognizerFactory::getAdjacencyPairType()) 00190 return factory::AP_START; 00191 else if (type == RecognizerFactory::getBackchannelType()) 00192 return factory::BC_START; 00193 00194 return factory::INVALID_STATE; 00195 } |