Project: engagement_generation License: BSD Dependencies:
Used by:
None |
engagement_generation/test/edu/wpi/hri/gen/policy/HIDGPolicyTest.javaGo to the documentation of this file.00001 package edu.wpi.hri.gen.policy; 00002 00003 import java.util.ArrayList; 00004 import java.util.List; 00005 00006 import junit.framework.TestCase; 00007 00008 import org.junit.Test; 00009 00010 import ros.NodeHandle; 00011 import ros.Ros; 00012 import ros.RosException; 00013 import ros.pkg.bml_msgs.msg.Entity; 00014 import ros.pkg.engagement_msgs.msg.HumanDirectedGaze; 00015 import edu.wpi.hri.bml.XMLInterface; 00016 import edu.wpi.hri.comm.MasterSpinner; 00017 import edu.wpi.hri.gen.Generation; 00018 import edu.wpi.hri.gen.comm.BMLRealizer; 00019 import edu.wpi.hri.gen.comm.GazeKnowledge; 00020 import edu.wpi.hri.log.Logger; 00021 00022 public class HIDGPolicyTest extends TestCase { 00023 00024 private boolean called = false; 00025 00026 @Test 00027 public void testPolicy() throws RosException { 00028 Logger logger = Logger.createDefault(); 00029 XMLInterface xml = Generation.createXML(logger); 00030 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00031 MasterSpinner spin = new MasterSpinner(logger, false); 00032 BMLRealizer realizer = new BMLRealizer(handle, spin, logger); 00033 GazeKnowledge gaze = new GazeKnowledge(handle, logger, xml, realizer) { 00034 @Override 00035 public boolean trySetGaze(String target) { 00036 called = true; 00037 return true; 00038 } 00039 }; 00040 HIDGPolicy policy = new HIDGPolicy(handle, logger, gaze, gaze); 00041 00042 ArrayList<Entity> targets = new ArrayList<Entity>(); 00043 Entity ent = new Entity(); 00044 ent.id = "target-1"; 00045 ent.type = Entity.UNKNOWN; 00046 targets.add(ent); 00047 00048 assertFalse(called); 00049 HumanDirectedGaze dgrequest = new HumanDirectedGaze(); 00050 dgrequest.objects = targets; 00051 dgrequest.timeout = 0; 00052 dgrequest.actor.id = "actor-test"; 00053 policy.call(dgrequest); 00054 assertTrue(called); 00055 00056 policy.shutdown(); 00057 gaze.shutdown(); 00058 realizer.shutdown(); 00059 spin.stop(); 00060 spin.joinOldMasters(); 00061 handle.shutdown(); 00062 } 00063 } |