Пример #1
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)
Пример #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)
Пример #3
0
 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()
Пример #4
0
import rospy
from robots import Robot, Animal, Person, DifferentRobot, PickerRobot, CarrierRobot, Bin, Tractor, EducatedPerson
from actions import MoveAction, RotateAction, NavigateAction, Figure8Action, MoveRandomAction
import robot_storage
from math import pi

"""Main file for initializing and executing the robots of the orchard simulator."""
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.
Пример #5
0
from robots import Robot, Animal, Person, DifferentRobot, PickerRobot, CarrierRobot, Bin, Tractor, EducatedPerson
from actions import MoveAction, RotateAction, NavigateAction, Figure8Action, MoveRandomAction
import robot_storage
from math import pi

"""Main file for initializing and executing the robots of the orchard simulator."""
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)


Пример #6
0
 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()