def __init__(self):
     # creates the action server
     self._as = actionlib.SimpleActionServer("action_custom_msg_as",
                                             record_odomAction,
                                             self.goal_callback, False)
     self._as.start()
     self._result = record_odomResult()
     self._feedback = record_odomFeedback()
     self.stack = record_odomResult()
     self.my_reader = odom_reader()
     self.rate = rospy.Rate(1)
Пример #2
0
    def goal_callback(self, goal):
        # helper variables
        r = rospy.Rate(1)
        success = True
        for i in xrange(self._seconds_recording):
            rospy.loginfo("Recording Odom index=" + str(i))
            if self._as.is_preempt_requested():
                rospy.loginfo('The goal has been cancelled/preempted')
                self._as.set_preempted()
                success = False
                break
            else:
                if not self.reached_distance_goal():
                    rospy.logdebug('Reading Odometry...')
                    self._result.result_odom_array.append(
                        self.odom_subs.get_odomdata())
                else:
                    rospy.logwarn('Reached distance Goal')
                    # we end the action loop
                    break
            r.sleep()

        if success:
            self._as.set_succeeded(self._result)
        self._result = record_odomResult()
Пример #3
0
 def __init__(self, maze_length):
     self._as = actionlib.SimpleActionServer("action_server",
                                             record_odomAction,
                                             self.goal_callback, False)
     self._as.start()
     self.odo_obj = OdomTopicReader()
     self.goal_length = maze_length
     self.result_var = record_odomResult()
     self.time_limit = 120
Пример #4
0
 def __init__(self, timeOut, distTarget):
   self.actionServer = actionlib.SimpleActionServer('turtleBotExit', record_odomAction, self.callback, False)
   self.actionServer.start()
   self.timeOut = timeOut
   self.distTarget = distTarget
   self.odomReader = OdomReader()
   self.result = record_odomResult()
   self.odomData = []
   rospy.loginfo("OdomActionServer instance created")
Пример #5
0
 def __init__(self, goal_distance=float(goal), seconds_recording=int(seconds)):
     # Creates the action server
     self._as = actionlib.SimpleActionServer("rec_odom_as", record_odomAction, self.execute_cb, False)
     self._as.start()
     # Create an object that reads from the topic Odom
     self._odom_sub_object = OdomSubscriber()
     # Create messages that are used to publish result
     self._result = record_odomResult()
     self._goal_distance = goal_distance
     self._seconds_recording = seconds_recording
Пример #6
0
 def __init__(self, goal_distance):
     # creates the action server
     self._as = actionlib.SimpleActionServer("record_odom",
                                             record_odomAction,
                                             self.goal_callback, False)
     self._as.start()
     self.odom_subs = OdomTopicReader()
     self._result = record_odomResult()
     self._seconds_recording = 120
     self._goal_distance = goal_distance
Пример #7
0
 def __init__(self):
     self.myActionOdomServerObj = actionlib.SimpleActionServer(
         '/myActionOdomServer', record_odomAction, self.actionOdomCallback,
         False)
     self.myActionOdomServerObj.start()
     self.myRate = rospy.Rate(1)
     self.tiempoMaxSeg = 90  #Time limit for the robot to get out of the maze
     self.miSubOdom = OdomTurtleSub(
     )  #OdomTurtleSub object, used to subscribe to the /odom topic
     self.miResultadoAct = record_odomResult()
     rospy.loginfo("Odometry Action Server ready!")
Пример #8
0
 def __init__(self,
              goal_dist=9,
              action_server_name='/rec_odom_as',
              time_limit=120):
     self._action_server = actionlib.SimpleActionServer(
         action_server_name, record_odomAction, self._cb, False)
     self._result = record_odomResult()
     self._odom_reader = OdomReader()
     self._odom_analyzer = OdomAnalysis()
     self._time_limit = time_limit
     self._goal_dist = goal_dist
     rospy.loginfo("Action server to calculate Odometry is launched")
     self._action_server.start()
Пример #9
0
class Odom_server(object):

    # create messages that are used to publish feedback/result
    _feedback = record_odomFeedback()
    _result = record_odomResult()

    def __init__(self):
        # creates the action server
        self._as = actionlib.SimpleActionServer("/rec_odom_as",
                                                record_odomAction,
                                                self.goal_callback, False)
        self._as.start()
        self.rate = rospy.Rate(10)
        self.tic = time.time()
        self.tok = time.time()

    def goal_callback(self, goal):
        # this callback is called when the action server is called.
        # this is the function that computes the Fibonacci sequence
        # and returns the sequence to the node that called the action server

        # helper variables
        r = rospy.Rate(1)

        self.tic = time.time()
        self.tok = time.time()
        while self.tok - self.tic < 42:
            self.tok = time.time()
            #print(self.tok - self.tic)
            #print(OdomClass.data)
            self._result.result_odom_array.append(OdomClass.data)
            if OdomClass.data.pose.pose.position.y < -8.5:
                rospy.loginfo("Congradulation! exit maze!")
                break
            time.sleep(0.1)

        time.sleep(1)
        print('Mission time : %f' % (self.tok - self.tic))
        self._as.set_succeeded(self._result)
Пример #10
0
 def clean_variables(self):
     """
     Cleans variables for the next call
     """
     self._result = record_odomResult()
Пример #11
0
 def clean_variables(self):
     self.result_var = record_odomResult()
Пример #12
0
 def _reset_action_server(self):
     self._result = record_odomResult()