<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (C) 2015  <NAME>
# Released under BSD version 4
"""
Beep when pose does not change for `TIMEOUT_TIME`

"""
import os
import pygame
import rospy
from geometry_msgs.msg import PoseStamped


TIMEOUT = 0.25  # seconds
SPIRIT_ROOT = os.path.expanduser("~/catkin_ws/src/spirit")


class Beeper(object):
    def __init__(self):
        pygame.init()
        pygame.mixer.music.load(os.path.join(SPIRIT_ROOT, "audio/beep.wav"))
        self.beep()
        rospy.loginfo("Trial beep made.")

        self.subscriber = rospy.Subscriber("/ardrone/pose", PoseStamped,
                                           self.callback, queue_size=1)

        self._last_pose = None
        self._tracking_lost = False
        self._no_contact = True

    def beep(self):
        """
        Beeps an audio file.

        """
        pygame.mixer.music.play()

    def callback(self, pose):
        if not self._no_contact:
            rospy.loginfo("Callback called!")
            self._no_contact = False

        if self._tracking_lost and self._last_pose.pose != pose.pose:
            self._tracking_lost = False
            rospy.loginfo("Tracking reacquired.")

        if (not self._tracking_lost and self._last_pose is not None and
            (self._last_pose.header.stamp - rospy.Time.now())
                .to_secs() > TIMEOUT):
            self._tracking_lost = True
            rospy.loginfo("Tracking lost.")
            self.beep()

        self._last_pose = pose
<commit_msg>Fix name of method: to_secs to to_sec<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (C) 2015  <NAME>
# Released under BSD version 4
"""
Beep when pose does not change for `TIMEOUT_TIME`

"""
import os
import pygame
import rospy
from geometry_msgs.msg import PoseStamped


TIMEOUT = 0.25  # seconds
SPIRIT_ROOT = os.path.expanduser("~/catkin_ws/src/spirit")


class Beeper(object):
    def __init__(self):
        pygame.init()
        pygame.mixer.music.load(os.path.join(SPIRIT_ROOT, "audio/beep.wav"))
        self.beep()
        rospy.loginfo("Trial beep made.")

        self.subscriber = rospy.Subscriber("/ardrone/pose", PoseStamped,
                                           self.callback, queue_size=1)

        self._last_pose = None
        self._tracking_lost = False
        self._no_contact = True

    def beep(self):
        """
        Beeps an audio file.

        """
        pygame.mixer.music.play()

    def callback(self, pose):
        if not self._no_contact:
            rospy.loginfo("Callback called!")
            self._no_contact = False

        if self._tracking_lost and self._last_pose.pose != pose.pose:
            self._tracking_lost = False
            rospy.loginfo("Tracking reacquired.")

        if (not self._tracking_lost and self._last_pose is not None and
            (self._last_pose.header.stamp - rospy.Time.now())
                .to_sec() > TIMEOUT):
            self._tracking_lost = True
            rospy.loginfo("Tracking lost.")
            self.beep()

        self._last_pose = pose

{'fraction_non_alphanumeric': 0.11298154742635157, 'fraction_numerical': 0.006474587245063127, 'mean_word_length': 2.080757726819541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1529190', 'n_tokens_mistral': 1026, 'n_tokens_neox': 961, 'n_words': 212}