class TestPicker(unittest.TestCase): def setUp(self): rospy.init_node('test_picker') self.picker = PickerRobot('robot_0', 2, 0.9, -20, 43, 0) def test_picker_count(self): """Test that the kiwifruit count increments when in orchard""" self.picker.position['x'] = 0 self.picker.position['y'] = 0 #origin is in orchard self.picker.fruit_count = 0 self.picker.execute_callback() if self.picker.randint == 1: self.assertEqual(self.picker.fruit_count,1) else: self.assertEqual(self.picker.fruit_count,0) def test_picker_picking_speed(self): """Check the picker slows down to its picking speed when in orchard""" self.picker.current_speed = 4 self.picker.position['x'] = 0 self.picker.position['y'] = 0 #origin is in orchard self.picker.execute_callback() self.assertEqual(self.picker.current_speed, 1) # Designated pick speed def test_picker_normal_speed(self): """Check the picker sets a normal speed when it's outside orchard""" self.picker.current_speed = 0.1 self.picker.position['x'] = 9000 self.picker.position['y'] = 9000 #position out of orchard self.picker.execute_callback() self.assertEqual(self.picker.current_speed, self.picker.top_speed) def test_check_full_true(self): """Test check_full method to see if it detects a full count""" self.picker.fruit_count = 999999999 self.assertTrue(self.picker.check_full()) def test_check_full_false(self): """Test check_full method to see if it detects non-full bin""" self.picker.fruit_count = 0 self.assertFalse(self.picker.check_full())
class TestPicker(unittest.TestCase): def setUp(self): rospy.init_node('test_picker') self.picker = PickerRobot('robot_0', 2, 0.9, -20, 43, 0) def test_picker_count(self): """Test that the kiwifruit count increments when in orchard""" self.picker.position['x'] = 0 self.picker.position['y'] = 0 #origin is in orchard self.picker.fruit_count = 0 self.picker.execute_callback() if self.picker.randint == 1: self.assertEqual(self.picker.fruit_count, 1) else: self.assertEqual(self.picker.fruit_count, 0) def test_picker_picking_speed(self): """Check the picker slows down to its picking speed when in orchard""" self.picker.current_speed = 4 self.picker.position['x'] = 0 self.picker.position['y'] = 0 #origin is in orchard self.picker.execute_callback() self.assertEqual(self.picker.current_speed, 1) # Designated pick speed def test_picker_normal_speed(self): """Check the picker sets a normal speed when it's outside orchard""" self.picker.current_speed = 0.1 self.picker.position['x'] = 9000 self.picker.position['y'] = 9000 #position out of orchard self.picker.execute_callback() self.assertEqual(self.picker.current_speed, self.picker.top_speed) def test_check_full_true(self): """Test check_full method to see if it detects a full count""" self.picker.fruit_count = 999999999 self.assertTrue(self.picker.check_full()) def test_check_full_false(self): """Test check_full method to see if it detects non-full bin""" self.picker.fruit_count = 0 self.assertFalse(self.picker.check_full())
def setUp(self): rospy.init_node('test_picker') self.picker = PickerRobot('robot_0', 2, 0.9, -20, 43, 0)
rospy.init_node("main") animal = Animal("robot_0", 2, 0.5, 20.5, 0, 0) person1 = Person("robot_1", 2, 0.5, 0, 45, 0) person2 = EducatedPerson("robot_2", 2, 0.5, -20.5, 0, 0) tractor = Tractor("robot_3", 2, 0.9, -20.5, 45, 0) binbot1 = Bin("robot_4", 3, 0.5, -8.75, -39, pi / 2) binbot2 = Bin("robot_5", 3, 0.5, -1.75, -39, pi / 2) binbot3 = Bin("robot_6", 3, 0.5, 1.75, -39, pi / 2) binbot4 = Bin("robot_7", 3, 0.5, 5.25, -39, pi / 2) picker1 = PickerRobot("robot_8", 3, 0.5, -8.75, -44, 0) picker2 = PickerRobot("robot_9", 3, 0.5, 1, -44, 0) picker3 = PickerRobot("robot_10", 3, 0.5, 7, -44, 0) carrier1 = CarrierRobot("robot_11", 3, 0.5, 35.5, -25, 0) carrier2 = CarrierRobot("robot_12", 2, 0.5, 41.5, -35, 0) # Add all robots to robot_storage. robot_storage.addRobot(animal, "robot_0") robot_storage.addRobot(person1, "robot_1") robot_storage.addRobot(person2, "robot_2") robot_storage.addRobot(tractor, "robot_3") robot_storage.addRobot(binbot1, "robot_4") robot_storage.addRobot(binbot2, "robot_5") robot_storage.addRobot(binbot3, "robot_6")
animal = Animal('robot_0', 2, 0.5, 20.5, 0, 0) person1 = Person('robot_1', 2, 0.5, 0, 45, 0) person2 = EducatedPerson('robot_2', 2, 0.5, -20.5, 0, 0) tractor = Tractor('robot_3', 2, 0.9, -20.5, 45, 0) binbot1 = Bin('robot_4', 3, 0.5, -8.75, -39, pi/2) binbot2 = Bin('robot_5', 3, 0.5, -1.75, -39, pi/2) binbot3 = Bin('robot_6', 3, 0.5, 1.75, -39, pi/2) binbot4 = Bin('robot_7', 3, 0.5, 5.25, -39, pi/2) picker1 = PickerRobot('robot_8', 3, 0.5, -8.75, -44, 0) picker2 = PickerRobot('robot_9', 3, 0.5, 1, -44, 0) picker3 = PickerRobot('robot_10', 3, 0.5, 7, -44, 0) carrier1 = CarrierRobot('robot_11', 3, 0.5, 35.5, -25, 0) carrier2 = CarrierRobot('robot_12', 2, 0.5, 41.5, -35, 0) # Add all robots to robot_storage. robot_storage.addRobot(animal, "robot_0") robot_storage.addRobot(person1, "robot_1") robot_storage.addRobot(person2, "robot_2") robot_storage.addRobot(tractor, "robot_3") robot_storage.addRobot(binbot1, "robot_4") robot_storage.addRobot(binbot2, "robot_5")