Exemplo n.º 1
0
class TestEducatedPerson(unittest.TestCase):

    def setUp(self):
        rospy.init_node('test_educated_person')
        self.person = EducatedPerson('robot_0', 1, 0.5, 0, 0, 0)

    def test_init(self):
        """Checks if attributes are set correctly after init."""
        self.assertTrue(1, 1)

    def test_cmd_handler_up(self):
        """Checks that a person moves forward when given up msg."""
        msg = String()
        msg.data = "up"
        self.person.cmd_handler(msg)
        self.assertEqual(self.person.current_speed, 1)

    def test_cmd_handler_down(self):
        """Checks that a person reverses when given down msg."""
        msg = String()
        msg.data = "down"
        self.person.cmd_handler(msg)
        self.assertEqual(self.person.current_speed, -1)

    def test_cmd_handler_left(self):
        """Checks that person rotates anticlockwise when given left msg."""
        msg = String()
        msg.data = "left"
        self.person.cmd_handler(msg)
        self.assertTrue(self.person.rotation_executing)
        self.assertEqual(self.person.velocity.angular.z, 0.5)

    def test_cmd_handler_right(self):
        """Checks that person rotates clockwise when given right msg."""
        msg = String()
        msg.data = "right"
        self.person.cmd_handler(msg)
        self.assertTrue(self.person.rotation_executing)
        self.assertEqual(self.person.velocity.angular.z, -0.5)

    def test_cmd_handler_other(self):
        """Checks that person doesn't move when given a random input."""
        msg = String()
        msg.data = "this_does_nothing"
        self.person.cmd_handler(msg)
        self.assertFalse(self.person.rotation_executing)
        self.assertEqual(self.person.velocity.angular.x, 0)
        self.assertEqual(self.person.velocity.angular.y, 0)
        self.assertEqual(self.person.velocity.angular.z, 0)
Exemplo n.º 2
0
#!/usr/bin/env python

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)
Exemplo n.º 3
0
 def setUp(self):
     rospy.init_node('test_educated_person')
     self.person = EducatedPerson('robot_0', 1, 0.5, 0, 0, 0)
Exemplo n.º 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)