class TestTractor(unittest.TestCase):

    def setUp(self):
        rospy.init_node('test_tractor')
        self.tractor = Tractor('robot_0', 2, 0.9, -20, 43, 0)
        for i in range(0, 20):
            self.tractor.execute()

    def test_init(self):
        """Checks if subscribed information has been received."""
        self.assertIsNot(self.tractor.odometry, None)
        self.assertIsNot(self.tractor.leftLaser, None)
        self.assertIsNot(self.tractor.rightLaser, None)

    def test_execute_callback_was_blocked_false(self):
        """Test actions are added to queue when was_blocked is false"""
        self.tractor.was_blocked = False
        self.tractor._action_queue[:] = [] #clear the list
        self.tractor.execute_callback()
        self.assertEqual(len(self.tractor._action_queue),4)

    def test_execute_callback_was_blocked_true(self):
        """test was_blocked is true and action queue is old 
        queue when was_blocked is true"""
        self.tractor.was_blocked = True
        self.tractor.old_queue = []
        self.tractor.execute_callback()
        self.assertFalse(self.tractor.was_blocked)
        self.assertEqual(self.tractor._action_queue,self.tractor.old_queue)

    def test_orchard_get_coordinates(self):
        """Test the boundary values obtained from file are floats
        NOTE: This is based on default world file. If configured world is run last this will fail"""
        boundaries = locations.get_wall_boundaries()
        self.tractor.min_x = boundaries["min_x"]
        self.tractor.max_x = boundaries["max_x"]
        self.tractor.min_y = boundaries["min_y"]
        self.tractor.max_y = boundaries["max_y"]
        self.assertEqual(self.tractor.min_x, -35)
        self.assertEqual(self.tractor.min_y, -60)
        self.assertEqual(self.tractor.max_x, 35)
        self.assertEqual(self.tractor.max_y, 60)
Exemple #2
0
class TestTractor(unittest.TestCase):
    def setUp(self):
        rospy.init_node('test_tractor')
        self.tractor = Tractor('robot_0', 2, 0.9, -20, 43, 0)
        for i in range(0, 20):
            self.tractor.execute()

    def test_init(self):
        """Checks if subscribed information has been received."""
        self.assertIsNot(self.tractor.odometry, None)
        self.assertIsNot(self.tractor.leftLaser, None)
        self.assertIsNot(self.tractor.rightLaser, None)

    def test_execute_callback_was_blocked_false(self):
        """Test actions are added to queue when was_blocked is false"""
        self.tractor.was_blocked = False
        self.tractor._action_queue[:] = []  #clear the list
        self.tractor.execute_callback()
        self.assertEqual(len(self.tractor._action_queue), 4)

    def test_execute_callback_was_blocked_true(self):
        """test was_blocked is true and action queue is old 
        queue when was_blocked is true"""
        self.tractor.was_blocked = True
        self.tractor.old_queue = []
        self.tractor.execute_callback()
        self.assertFalse(self.tractor.was_blocked)
        self.assertEqual(self.tractor._action_queue, self.tractor.old_queue)

    def test_orchard_get_coordinates(self):
        """Test the boundary values obtained from file are floats
        NOTE: This is based on default world file. If configured world is run last this will fail"""
        boundaries = locations.get_wall_boundaries()
        self.tractor.min_x = boundaries["min_x"]
        self.tractor.max_x = boundaries["max_x"]
        self.tractor.min_y = boundaries["min_y"]
        self.tractor.max_y = boundaries["max_y"]
        self.assertEqual(self.tractor.min_x, -35)
        self.assertEqual(self.tractor.min_y, -60)
        self.assertEqual(self.tractor.max_x, 35)
        self.assertEqual(self.tractor.max_y, 60)
Exemple #3
0
robot_storage.addRobot(binbot1, "robot_4")
robot_storage.addRobot(binbot2, "robot_5")
robot_storage.addRobot(binbot3, "robot_6")
robot_storage.addRobot(binbot4, "robot_7")
robot_storage.addRobot(picker1, "robot_8")
robot_storage.addRobot(picker2, "robot_9")
robot_storage.addRobot(picker3, "robot_10")
robot_storage.addRobot(carrier1, "robot_11")
robot_storage.addRobot(carrier2, "robot_12")

rate = rospy.Rate(10)

# Continually execute robots in execution loop.
while not rospy.is_shutdown():

    animal.execute()
    tractor.execute()
    person1.execute()
    person2.execute()
    picker1.execute()
    picker2.execute()
    picker3.execute()
    carrier1.execute()
    carrier2.execute()
    binbot1.execute()
    binbot2.execute()
    binbot3.execute()
    binbot4.execute()

    rate.sleep()
Exemple #4
0
robot_storage.addRobot(binbot1, "robot_4")
robot_storage.addRobot(binbot2, "robot_5")
robot_storage.addRobot(binbot3, "robot_6")
robot_storage.addRobot(binbot4, "robot_7")
robot_storage.addRobot(picker1, "robot_8")
robot_storage.addRobot(picker2, "robot_9")
robot_storage.addRobot(picker3, "robot_10")
robot_storage.addRobot(carrier1, "robot_11")
robot_storage.addRobot(carrier2, "robot_12")

rate = rospy.Rate(10)

# Continually execute robots in execution loop.
while not rospy.is_shutdown():

    animal.execute()
    tractor.execute()
    person1.execute()
    person2.execute()
    picker1.execute()
    picker2.execute()
    picker3.execute()
    carrier1.execute()
    carrier2.execute()
    binbot1.execute()
    binbot2.execute()
    binbot3.execute()
    binbot4.execute()

    rate.sleep()