Project: engagement_generation License: BSD Dependencies:
Used by:
None |
engagement_generation/test/edu/wpi/hri/gen/policy/ref/ReferenceOptionsTest.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.log.Logger; 00022 00023 public class ReferenceOptionsTest extends TestCase { 00024 00025 @Test 00026 public void testReferenceOptions() throws RosException { 00027 Logger logger = Logger.createDefault(); 00028 XMLInterface xml = new XMLInterface(logger, new File("ebml.xsd")); 00029 ReferenceBehavior ref = EBMLListTest.createReference(logger, xml, 00030 "GS-REF", "object", 0.75); 00031 00032 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00033 SituationKnowledge situation = new SituationKnowledge(logger, handle); 00034 GestureState state = new GestureState(new Point(1, 2, 3), new Point(4, 00035 5, 6), new Point(7, 8, 9)); 00036 MasterSpinner spin = new MasterSpinner(logger, false); 00037 BMLRealizer realizer = new BMLRealizer(handle, spin, logger); 00038 GazeKnowledge knowledge = new GazeKnowledge(handle, logger, xml, 00039 realizer); 00040 00041 EntityPosition pos = new EntityPosition(); 00042 pos.entity.id = "object"; 00043 pos.entity.type = Entity.OBJECT; 00044 pos.x = -1; 00045 pos.y = -2; 00046 pos.z = -3; 00047 pos.rotation = 0; 00048 situation.call(pos); 00049 00050 pos = new EntityPosition(); 00051 pos.entity.id = "ROBOT"; 00052 pos.entity.type = Entity.UNKNOWN; 00053 pos.x = -20; 00054 pos.y = -30; 00055 pos.z = 0; 00056 pos.rotation = 0; 00057 situation.call(pos); 00058 00059 // now start the testing 00060 try { 00061 NoPointZone noZone = new NoPointZone(logger, situation, knowledge); 00062 ReferenceOptions options = new ReferenceOptions(logger, ref, 00063 situation); 00064 double best = options.findBest(situation, state, noZone); 00065 00066 options.setNextOption(new ReferenceOptions(logger, ref, situation)); 00067 assertTrue(options.findBest(situation, state, noZone) > best); 00068 00069 assertNotNull(options.createSpeech()); 00070 options.createGaze(); 00071 options.createPoint(situation); 00072 } catch (Exception e) { 00073 fail("the basic reference behavior is bad"); 00074 } 00075 00076 situation.shutdown(); 00077 handle.shutdown(); 00078 } 00079 00080 } |