Project: engagement_generation License: BSD Dependencies:
Used by:
None |
engagement_generation/test/edu/wpi/hri/gen/policy/ref/GestureOptionTest.javaGo to the documentation of this file.00001 package edu.wpi.hri.gen.policy.ref; 00002 00003 import junit.framework.TestCase; 00004 00005 import org.junit.Test; 00006 00007 import ros.NodeHandle; 00008 import ros.Ros; 00009 import ros.RosException; 00010 import ros.pkg.bml_msgs.msg.Entity; 00011 import ros.pkg.bml_msgs.msg.EntityPosition; 00012 import edu.wpi.hri.bml.XMLInterface; 00013 import edu.wpi.hri.comm.MasterSpinner; 00014 import edu.wpi.hri.gen.Generation; 00015 import edu.wpi.hri.gen.comm.BMLRealizer; 00016 import edu.wpi.hri.gen.comm.GazeKnowledge; 00017 import edu.wpi.hri.gen.comm.SituationKnowledge; 00018 import edu.wpi.hri.log.Logger; 00019 00020 public class GestureOptionTest extends TestCase { 00021 00022 @Test 00023 public void testLabmda() { 00024 GestureOption option = GestureOption.LAMBDA; 00025 assertEquals(0.0, option.getReliability()); 00026 assertNull(option.getDistractors(null, null)); 00027 assertEquals(0.0, option.getCost(null, null, null, null)); 00028 GestureState state = new GestureState(null, null, null); 00029 assertEquals(state, option.getNextState(state, null, null)); 00030 assertNull(option.createGaze(null, null, null, false)); 00031 assertNull(option.createGesture(null, null, null, false, false)); 00032 } 00033 00034 @Test 00035 public void testGaze() throws RosException { 00036 Logger logger = Logger.createDefault(); 00037 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00038 SituationKnowledge situation = new SituationKnowledge(logger, handle); 00039 00040 EntityPosition pos = new EntityPosition(); 00041 pos.entity.id = "ROBOT"; 00042 pos.entity.type = Entity.UNKNOWN; 00043 pos.rotation = 0; 00044 pos.x = 10; 00045 pos.y = -20; 00046 pos.z = 0; 00047 situation.call(pos); 00048 00049 pos = new EntityPosition(); 00050 pos.entity.id = "obj"; 00051 pos.entity.type = Entity.OBJECT; 00052 pos.rotation = 0; 00053 pos.x = -40; 00054 pos.y = 20; 00055 pos.z = 85; 00056 situation.call(pos); 00057 00058 GestureState old = new GestureState(new Point(1, 2, 3), new Point(4, 5, 00059 6), new Point(7, 8, 9)); 00060 00061 GestureOption option = GestureOption.GAZE; 00062 assertNotSame(0.0, option.getReliability()); 00063 assertNotNull(option.getDistractors("obj", situation)); 00064 assertNotSame(0.0, option.getCost(old, "obj", situation, null)); 00065 assertNotSame(old, option.getNextState(old, "obj", situation)); 00066 assertNotNull(option.createGaze(logger, "obj-gaze", "obj", false)); 00067 assertNull(option 00068 .createGesture(logger, "obj-point", "obj", false, true)); 00069 } 00070 00071 @Test 00072 public void testDirectedGaze() throws RosException { 00073 Logger logger = Logger.createDefault(); 00074 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00075 SituationKnowledge situation = new SituationKnowledge(logger, handle); 00076 00077 EntityPosition pos = new EntityPosition(); 00078 pos.entity.id = "ROBOT"; 00079 pos.entity.type = Entity.UNKNOWN; 00080 pos.rotation = 0; 00081 pos.x = 10; 00082 pos.y = -20; 00083 pos.z = 0; 00084 situation.call(pos); 00085 00086 pos = new EntityPosition(); 00087 pos.entity.id = "obj"; 00088 pos.entity.type = Entity.OBJECT; 00089 pos.rotation = 0; 00090 pos.x = -40; 00091 pos.y = 20; 00092 pos.z = 85; 00093 situation.call(pos); 00094 00095 GestureState old = new GestureState(new Point(1, 2, 3), new Point(4, 5, 00096 6), new Point(7, 8, 9)); 00097 00098 GestureOption option = GestureOption.DIRECTED_GAZE; 00099 assertNotSame(0.0, option.getReliability()); 00100 assertNotNull(option.getDistractors("obj", situation)); 00101 assertNotSame(0.0, option.getCost(old, "obj", situation, null)); 00102 assertNotSame(old, option.getNextState(old, "obj", situation)); 00103 assertNotNull(option.createGaze(logger, "obj-gaze", "obj", false)); 00104 assertNull(option 00105 .createGesture(logger, "obj-point", "obj", false, true)); 00106 } 00107 00108 @Test 00109 public void testDirectedGazePointing() throws RosException { 00110 Logger logger = Logger.createDefault(); 00111 NodeHandle handle = Ros.getInstance().createNodeHandle(); 00112 SituationKnowledge situation = new SituationKnowledge(logger, handle); 00113 XMLInterface xml = Generation.createXML(logger); 00114 MasterSpinner spin = new MasterSpinner(logger, false); 00115 BMLRealizer realizer = new BMLRealizer(handle, spin, logger); 00116 GazeKnowledge knowledge = new GazeKnowledge(handle, logger, xml, 00117 realizer); 00118 00119 EntityPosition pos = new EntityPosition(); 00120 pos.entity.id = "ROBOT"; 00121 pos.entity.type = Entity.UNKNOWN; 00122 pos.rotation = 0; 00123 pos.x = 10; 00124 pos.y = -20; 00125 pos.z = 0; 00126 situation.call(pos); 00127 00128 pos = new EntityPosition(); 00129 pos.entity.id = "obj"; 00130 pos.entity.type = Entity.OBJECT; 00131 pos.rotation = 0; 00132 pos.x = -40; 00133 pos.y = 20; 00134 pos.z = 85; 00135 situation.call(pos); 00136 00137 GestureState old = new GestureState(new Point(1, 2, 3), new Point(4, 5, 00138 6), new Point(7, 8, 9)); 00139 00140 GestureOption option = GestureOption.DIRECTED_GAZE_POINTING; 00141 assertNotSame(0.0, option.getReliability()); 00142 assertNotNull(option.getDistractors("obj", situation)); 00143 assertNotSame(0.0, option.getCost(old, "obj", situation, 00144 new NoPointZone(logger, situation, knowledge))); 00145 assertNotSame(old, option.getNextState(old, "obj", situation)); 00146 assertNotNull(option.createGaze(logger, "obj-gaze", "obj", false)); 00147 assertNotNull(option.createGesture(logger, "obj-point", "obj", false, 00148 true)); 00149 } 00150 } |