Project: engagement_generation License: BSD Dependencies:
Used by:
None |
engagement_generation/src/edu/wpi/hri/gen/policy/ref/GestureSpeechPair.javaGo 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 package edu.wpi.hri.gen.policy.ref; 00035 00036 import edu.wpi.hri.gen.comm.SituationKnowledge; 00037 import edu.wpi.hri.gen.ebml.SpeechOption; 00038 import edu.wpi.hri.log.Logger; 00039 import edu.wpi.hri.log.Logger.Colors; 00040 import edu.wpi.hri.log.Logger.LoggerLevel; 00041 00050 class GestureSpeechPair { 00051 00052 private final Logger logger; 00053 private final GestureOption gesture; 00054 private final SpeechOption speech; 00055 private final String object; 00056 private final double reliability; 00057 private final DistractorSet distractors; 00058 private final SituationKnowledge situation; 00059 00074 GestureSpeechPair(Logger logger, GestureOption gesture, 00075 SpeechOption speech, String object, SituationKnowledge situation) { 00076 this.logger = logger.sub(Colors.REFERENCE, "GS-" + gesture + "-" 00077 + speech.getID()); 00078 this.gesture = gesture; 00079 this.speech = speech; 00080 this.object = object; 00081 00082 this.logger.debug(LoggerLevel.MATH, "Finding Reliability ..."); 00083 this.reliability = gesture.getReliability() + speech.getReliability(); 00084 00085 logger.debug(LoggerLevel.MATH, "Finding Distractors ..."); 00086 this.situation = situation; 00087 DistractorSet dg = gesture.getDistractors(object, situation); 00088 DistractorSet ds = speech.getDistractors(); 00089 this.distractors = (dg == null) ? ds : ((ds == null) ? dg : dg 00090 .intersection(ds)); 00091 } 00092 00098 SpeechOption getSpeech() { 00099 return this.speech; 00100 } 00101 00107 GestureOption getGesture() { 00108 return gesture; 00109 } 00110 00122 double getCost(GestureState state, NoPointZone noZone) { 00123 double cost = gesture.getCost(state, object, situation, noZone) 00124 + speech.getCost(); 00125 logger.debug(LoggerLevel.MATH, "Costs " + cost); 00126 return cost; 00127 } 00128 00134 double getInherentReliability() { 00135 return reliability; 00136 } 00137 00146 DistractorSet getDistractors(SituationKnowledge situation) { 00147 return distractors; 00148 } 00149 00160 GestureState getNextState(GestureState state, SituationKnowledge situation) { 00161 return this.gesture.getNextState(state, object, situation); 00162 } 00163 } |