コード例 #1
0
    def move(self):
        if (self._movements % self.getMovementsBetweenAttack() == 0):
            nearest_tower = self.getNearestTower()
            if nearest_tower is not None:
                if not DistanceCalculator.targetOutOfRange(
                        self, nearest_tower, self._attack_range):
                    self._attack.attack(nearest_tower, self)

        if self.getHealth() <= 0:
            #TODO: Remove this invader from the board
            if self._alive:
                self._bank.getInvaderRansom()
                self._alive = False
            self.notifyObservers()
            return

        if (self._x, self._y) == self._dest_cell.get_center():
            # move on to the next cell
            # TODO: HANDLE END OF PATH!
            self._compute_new_dir()

        self._x += self._xdir
        self._y += self._ydir
        self._movements += 1
        self.notifyObservers()
コード例 #2
0
    def __init__(self):

        self.bridge = cv_bridge.CvBridge()

        self.logger = logging.getLogger('cv_test')
        logging.basicConfig(level=logging.INFO)

        self.dist_calc = DistanceCalculator('parking')
        self.show_matcher_points = True
        self.timer = ElapsedTime()

        self.show_matched_points = True

        self.sift = cv2.xfeatures2d.SIFT_create()
        self.img1 = cv2.imread('parking_marker.png', cv2.IMREAD_COLOR)
        if self.img1 is None:
            print 'img1 is deleted'
        self.kp1, self.des1 = self.sift.detectAndCompute(self.img1, None)

        self.image_sub = rospy.Subscriber(
            '/center_camera/image_raw/compressed', CompressedImage,
            self.find_callback)
        self.key_pub = rospy.Publisher('t3burger/control/parking',
                                       Bool,
                                       queue_size=1)
        rospy.init_node("test_driver")
        self.rate = rospy.Rate(100)
コード例 #3
0
 def sendAttack(self):
     if (DistanceCalculator.targetOutOfRange(self, self._target, self._attack_range)):
         self._target = None
         return
 
     if (self._notification_count % self._attack.getMovementsBetweenFire()) == 0:
         self._attack.attack(self._target, self)
     self._notification_count += 1
コード例 #4
0
    def __init__(self):
    	self.count = 0
        self.cnt = 0
        self.bridge = cv_bridge.CvBridge()
        self.dist_calc = DistanceCalculator('parking')
        self.tunnel_state = False
        self.surf = cv2.xfeatures2d.SURF_create(1500) # 물체 인식하려면 300~500이 적당
        self.blocking_img = cv2.imread('tunnel.png', cv2.IMREAD_GRAYSCALE)
        self.image_sub = rospy.Subscriber('/python_image1/compressed', CompressedImage,  self.image_callback)
        self.tunnel_pub = rospy.Publisher('/tb3/control/tunnel',Bool,queue_size = 1)

        self.kp1, self.des1 = self.surf.detectAndCompute(self.blocking_img, None)
コード例 #5
0
    def getNearestTower(self):
        known_towers = self._observers
        smallest_distance = math.inf
        return_tower = None

        for t in known_towers:
            current_distance = DistanceCalculator.calculateDistance(
                self.getXCoord(), self.getYCoord(), t.getXCoord(),
                t.getYCoord())
            if current_distance < smallest_distance:
                smallest_distance = current_distance
                return_tower = t

        return return_tower
コード例 #6
0
ファイル: sign_match.py プロジェクト: kts006/deu_racer
 def __init__(self):
     self.bridge = cv_bridge.CvBridge()
     self.dist_calc = DistanceCalculator('parking')
     self.cnt = 0
     self.parking_state = False
     self.white_state = False
     # 물체 인식하려면 300~500이 적당
     self.surf = cv2.xfeatures2d.SURF_create(1000)
     self.blocking_img = cv2.imread('parking_marker.png', cv2.IMREAD_COLOR)
     self.image_sub = rospy.Subscriber('/python_image1/compressed',
                                       CompressedImage, self.image_callback)
     self.white_sub = rospy.Subscriber('tb3/control/parking_white', Bool,
                                       self.white_callback)
     self.parking_pub = rospy.Publisher('tb3/control/parking', Bool)