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

import rospy
import smach


class GuideInterface(smach.State):
    def __init__(self, waypointset):
        smach.State.__init__(
            self,
            outcomes=['move_to_point', 'aborted', 'killall'],
            input_keys=['current_waypoint'],
            output_keys=['waypoint']
        )
        self.waypointset = waypointset

    def execute(self, userdata):
        rospy.loginfo("Showing guide interface")
        rospy.sleep(1)
        # Guide interface returning the next waypoint

        waypoints = self.waypointset['slow']
        rospy.loginfo("I am at: " + userdata.current_waypoint)
        next_waypoint = ""
        for elem in waypoints.items():
            if elem[1] == userdata.current_waypoint:
                key = str(int(elem[0])+1)
                if not key in waypoints.keys():
                    key = "1"
                next_waypoint = waypoints[key]

        rospy.loginfo("I will go to: " + next_waypoint)
        userdata.waypoint = next_waypoint
        return 'move_to_point'<commit_msg>add action server to GuideInterface class<commit_after>#!/usr/bin/env python

import rospy
import smach
import actionlib
from aaf_walking_group.msg import InterfaceAction, InterfaceGoal

class GuideInterface(smach.State):
    def __init__(self, waypointset):
        smach.State.__init__(
            self,
            outcomes=['move_to_point', 'aborted', 'killall'],
            input_keys=['current_waypoint'],
            output_keys=['waypoint']
        )
        self.waypointset = waypointset

        rospy.loginfo("Creating guide interface client...")
        self._client = actionlib.SimpleActionClient(
            'interface_server',
            InterfaceAction
        )
        self._client.wait_for_server()
        rospy.loginfo("...done")

    def execute(self, userdata):
        rospy.loginfo("Showing guide interface")
        rospy.sleep(1)

        # Guide interface returning the next waypoint
        waypoints = self.waypointset['slow']
        rospy.loginfo("I am at: " + userdata.current_waypoint)
        next_waypoint = ""
        for elem in waypoints.items():
            if elem[1] == userdata.current_waypoint:
                key = str(int(elem[0])+1)
                if not key in waypoints.keys():
                    key = "1"
                next_waypoint = waypoints[key]

        # Getting the next waypoint from guide interface
        rospy.loginfo("Opening the guide interface...")
        goal = InterfaceGoal()
        goal.possible_points = waypoints
        goal.next_point = next_waypoint
        rospy.loginfo("Sending a goal to interface server...")
        self._client.send_goal_and_wait(goal)
        result = self._client.get_result()
        rospy.loginfo("Got the chosen next waypoint.")
        next_waypoint = result.chosen_point

        rospy.loginfo("I will go to: " + next_waypoint)
        userdata.waypoint = next_waypoint
        return 'move_to_point'
{'fraction_non_alphanumeric': 0.10060160427807487, 'fraction_numerical': 0.0033422459893048127, 'mean_word_length': 2.228694714131607, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2126363', 'n_tokens_mistral': 894, 'n_tokens_neox': 866, 'n_words': 188}