<commit_before>#!/usr/bin/env python

import rospy
import smach
from std_msgs.msg import String
import actionlib
from actionlib_msgs.msg import GoalStatus
from aaf_walking_group.msg import GuidingAction, GuidingGoal
from music_player.srv import MusicPlayerService, MusicPlayerServiceRequest
from aaf_waypoint_sounds.srv import WaypointSoundsService, WaypointSoundsServiceRequest
from sound_player_server.srv import PlaySoundService


class Guiding(smach.State):
    def __init__(self):
        smach.State.__init__(
            self,
            outcomes=['reached_point', 'reached_final_point', 'key_card', 'killall'],
            input_keys=['waypoints', 'play_music'],
            output_keys=['waypoints', 'play_music']
        )
        self.sub = None
        self.card = False
        rospy.loginfo("Creating guiding client...")
        self.nav_client = actionlib.SimpleActionClient("guiding", GuidingAction)
        self.nav_client.wait_for_server()
        rospy.loginfo(" ... done")

    def music_control(self, command):
        try:
            music_client = rospy.ServiceProxy('music_player_service', MusicPlayerService)
            rospy.loginfo("Creating waypoint sound service proxy and waiting ...")
            s = rospy.ServiceProxy('aaf_waypoint_sounds_service', WaypointSoundsService)
            if command == "play":
                music_client(MusicPlayerServiceRequest.PLAY)
                s(WaypointSoundsServiceRequest.PAUSE)
            elif command == "pause":
                music_client(MusicPlayerServiceRequest.PAUSE)
                s(WaypointSoundsServiceRequest.RESUME)
        except rospy.ServiceException, e:
            rospy.logwarn("Service call failed: %s" % e)

    def execute(self, userdata):
        rospy.loginfo("Guiding group")
        last_waypoint = userdata.waypoints.get_resting_waypoints()[-1]
        self.recall_preempt()
        try:
            s = rospy.ServiceProxy('/sound_player_server/sound_player_service', PlaySoundService)
            s.wait_for_service()
            s("jingle_therapist_continue.mp3")
        except rospy.ServiceException, e:
            rospy.logwarn("Service call failed: %s" % e)
        rospy.sleep(2) # Magic number :(
        self.card = False

        if userdata.play_music:
            self.music_control("play")
        else:
            self.music_control("pause")
<commit_msg>Using resume instead of play for music player.<commit_after>#!/usr/bin/env python

import rospy
import smach
from std_msgs.msg import String
import actionlib
from actionlib_msgs.msg import GoalStatus
from aaf_walking_group.msg import GuidingAction, GuidingGoal
from music_player.srv import MusicPlayerService, MusicPlayerServiceRequest
from aaf_waypoint_sounds.srv import WaypointSoundsService, WaypointSoundsServiceRequest
from sound_player_server.srv import PlaySoundService


class Guiding(smach.State):
    def __init__(self):
        smach.State.__init__(
            self,
            outcomes=['reached_point', 'reached_final_point', 'key_card', 'killall'],
            input_keys=['waypoints', 'play_music'],
            output_keys=['waypoints', 'play_music']
        )
        self.sub = None
        self.card = False
        rospy.loginfo("Creating guiding client...")
        self.nav_client = actionlib.SimpleActionClient("guiding", GuidingAction)
        self.nav_client.wait_for_server()
        rospy.loginfo(" ... done")

    def music_control(self, command):
        try:
            music_client = rospy.ServiceProxy('music_player_service', MusicPlayerService)
            rospy.loginfo("Creating waypoint sound service proxy and waiting ...")
            s = rospy.ServiceProxy('aaf_waypoint_sounds_service', WaypointSoundsService)
            if command == "play":
                music_client(MusicPlayerServiceRequest.RESUME)
                s(WaypointSoundsServiceRequest.PAUSE)
            elif command == "pause":
                music_client(MusicPlayerServiceRequest.PAUSE)
                s(WaypointSoundsServiceRequest.RESUME)
        except rospy.ServiceException, e:
            rospy.logwarn("Service call failed: %s" % e)

    def execute(self, userdata):
        rospy.loginfo("Guiding group")
        last_waypoint = userdata.waypoints.get_resting_waypoints()[-1]
        self.recall_preempt()
        try:
            s = rospy.ServiceProxy('/sound_player_server/sound_player_service', PlaySoundService)
            s.wait_for_service()
            s("jingle_therapist_continue.mp3")
        except rospy.ServiceException, e:
            rospy.logwarn("Service call failed: %s" % e)
        rospy.sleep(2) # Magic number :(
        self.card = False

        if userdata.play_music:
            self.music_control("play")
        else:
            self.music_control("pause")

{'fraction_non_alphanumeric': 0.0932610056332151, 'fraction_numerical': 0.0012518255789693302, 'mean_word_length': 2.795724465558195, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7385264', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1375, 'n_words': 265}