Project: engagement_generation License: BSD Dependencies:
Used by:
None |
engagement_generation/test/edu/wpi/hri/gen/policy/ref/GestureSpeechPairTest.javaGo to the documentation of this file.00001 package edu.wpi.hri.gen.policy.ref; 00002 00003 import java.io.File; 00004 00005 import junit.framework.TestCase; 00006 00007 import org.junit.Test; 00008 00009 import ros.NodeHandle; 00010 import ros.Ros; 00011 import ros.RosException; 00012 import ros.pkg.bml_msgs.msg.Entity; 00013 import ros.pkg.bml_msgs.msg.EntityPosition; 00014 import edu.wpi.hri.bml.XMLInterface; 00015 import edu.wpi.hri.comm.MasterSpinner; 00016 import edu.wpi.hri.gen.comm.BMLRealizer; 00017 import edu.wpi.hri.gen.comm.GazeKnowledge; 00018 import edu.wpi.hri.gen.comm.SituationKnowledge; 00019 import edu.wpi.hri.gen.ebml.EBMLListTest; 00020 import edu.wpi.hri.gen.ebml.ReferenceBehavior; 00021 import edu.wpi.hri.gen.ebml.SpeechOption; 00022 import edu.wpi.hri.log.Logger; 00023 00024 public class GestureSpeechPairTest extends TestCase { 00025 00026 @Test 00027 public void testGestureSpeechPair() throws RosException { 00028 Logger logger = Logger.createDefault(); 00029 GestureOption gesture = GestureOption.LAMBDA; 00030 XMLInterface xml = new XMLInterface(logger, new File("ebml.xsd")); 00031 ReferenceBehavior ref = EBMLListTest.createReference(logger, xml, 00032 "GS-REF", "object", 0.75); 00033 SpeechOption speech = null; 00034 for (SpeechOption so : ref.getSpeechOptions()) 00035 if (so.getText().isEmpty()) 00036 speech = so; 00037 00038 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00039 SituationKnowledge situation = new SituationKnowledge(logger, handle); 00040 GestureState state = new GestureState(new Point(1, 2, 3), new Point(4, 00041 5, 6), new Point(7, 8, 9)); 00042 MasterSpinner spin = new MasterSpinner(logger, false); 00043 BMLRealizer realizer = new BMLRealizer(handle, spin, logger); 00044 GazeKnowledge knowledge = new GazeKnowledge(handle, logger, xml, 00045 realizer); 00046 00047 EntityPosition pos = new EntityPosition(); 00048 pos.entity.id = "object"; 00049 pos.entity.type = Entity.OBJECT; 00050 pos.x = -1; 00051 pos.y = -2; 00052 pos.z = -3; 00053 pos.rotation = 0; 00054 situation.call(pos); 00055 00056 pos = new EntityPosition(); 00057 pos.entity.id = "ROBOT"; 00058 pos.entity.type = Entity.UNKNOWN; 00059 pos.x = -20; 00060 pos.y = -30; 00061 pos.z = 0; 00062 pos.rotation = 0; 00063 situation.call(pos); 00064 00065 // test the lambda first 00066 GestureSpeechPair pair = new GestureSpeechPair(logger, gesture, speech, 00067 "object", situation); 00068 assertEquals(gesture, pair.getGesture()); 00069 assertEquals(speech, pair.getSpeech()); 00070 00071 // then test non-lambda something 00072 for (SpeechOption so : ref.getSpeechOptions()) 00073 if (!so.getText().isEmpty()) 00074 speech = so; 00075 pair = new GestureSpeechPair(logger, GestureOption.GAZE, speech, 00076 "object", situation); 00077 00078 assertNotSame(0, 00079 pair.getCost(state, new NoPointZone(logger, situation, knowledge))); 00080 assertNotSame(0, pair.getInherentReliability()); 00081 assertNotNull(pair.getDistractors(situation)); 00082 assertNotSame(state, pair.getNextState(state, situation)); 00083 00084 situation.shutdown(); 00085 handle.shutdown(); 00086 } 00087 } |