def _allow_network(self, req):
        data = req.data

        resp = SetBoolResponse()
        resp.success = False

        if pulseaudio.submit_module(
                'module-zeroconf-discover',
                'load' if data else 'unload',
        ) != 0:
            resp.message = "Couldn't load module zeroconf discover"
            return resp

        if pulseaudio.submit_module(
                'module-native-protocol-tcp',
                'load' if data else 'unload',
                'auth-anonymous=1',
        ) != 0:
            resp.message = "Couldn't load module native protocol"
            return resp

        if pulseaudio.submit_module(
                'module-zeroconf-publish',
                'load' if data else 'unload',
        ) != 0:
            resp.message = "Couldn't load module zeroconf publish"
            return resp

        resp.success = True
        return resp
예제 #2
0
    def _movement_controller_state_callback(self, req):
        '''
        Callback function for the movement controller enable/disable service. If true,
        the movement controller will make corrections to meet the desired speed and
        steering direction with PID controller. Else if disabled, the controller will
        simply send PWM values of [0, 0, 0, 0] to the motor driver.

        Parameters:
            req: The request message (bool) to enable/disable the motor. Type std_srvs/SetBool.
        Returns:
            response: A response with a string & bool notifiying if the request was valid. Type std_srvs/SetBoolResponse
        '''
        self.movement_controller_enabled = req.data
        response = SetBoolResponse()
        response.success = True

        if (self.movement_controller_enabled):
            response.message = "Movement Controller Enabled"
        else:
            response.message = "Movement Controller Disabled"
            pwm_msg = Int16MultiArray()
            pwm_msg.data = [0, 0, 0, 0]
            self.pwm_pub.publish(pwm_msg)

        return response
예제 #3
0
 def enableChargeCb(self, req):
     '''
         ROS service server to start/stop the charge
     '''
     response = SetBoolResponse()
     if req.data:
         # Enable charge if ready to charge
         if self.ready_to_charge and ((self.now - self.io_last_stamp) <  RECEIVED_IO_TIMEOUT):
             res_charge_off = self.write_digital_output_client(self.charge_off_output, False)
             res_charge_on = self.write_digital_output_client(self.charge_on_output, req.data)
             response.success = res_charge_off.ret and res_charge_on.ret
             if response.success:
                 response.message = 'ok'
             else: 
                 response.message = 'error'
             self.last_enable_charge_msg_sent = True
         else:
             rospy.logwarn('%s::enableCharge: The robot is not ready to charge'%self.node_name)
             response.success = False
             response.message = 'not ready to start charging'
             self.last_enable_charge_msg_sent = False
     else: 
         # Disable charge
         res_charge_on = self.write_digital_output_client(self.charge_on_output, req.data)
         res_charge_off = self.write_digital_output_client(self.charge_off_output, True)
         print(res_charge_on, res_charge_off)
         response.success = res_charge_on.ret and res_charge_off.ret
         if response.success:
             response.message = 'ok'
         else: 
             response.message = 'error'
         self.last_enable_charge_msg_sent = False
     
     return response
예제 #4
0
def callback_srv(data):
    resp = SetBoolResponse()
    if data.data == True:
        resp.message = "called"
        resp.success = True
    else:
        resp.message = "ready"
        resp.success = False
    print(resp.message)
    return resp
예제 #5
0
 def enable_detection(self, req):
     global enable_node
     enable_node = req.data
     res = SetBoolResponse()
     res.success = True
     if enable_node:
         res.message = "Node enabled"
     else:
         res.message = "Node disabled"
     return res
예제 #6
0
  def setLoopFlagServiceCallback(self, req):
    res = SetBoolResponse()

    self.loop_flag = req.data
    res.success = True
    if req.data == True:
      res.message = "Starting publishing images in loop."
    else:
      res.message = "Stopping publishing images in loop."

    return res
def destroy(req):
    print "received this request: ", req
    print "Roger that!.."
    # do your logic here and send a respinse after it
    response = SetBoolResponse()
    response.success = True
    if req.data:
        response.message = "You are victorious!"
    else:
        response.message = "enemy spared!"
    return response
예제 #8
0
    def enable_service_cb(self, req):
        self.enable_trajectory = req.data
        resp = SetBoolResponse()
        resp.success = True

        if req.data:
            resp.message = "Topp Tracker enabled successfully."
        else:
            resp.message = "Topp Tracker disabled successfully."

        return resp
    def handle_service(self, req):
        rep = SetBoolResponse()
        try:
            self.ard.setLed(req.data)
            rep.success = True
            rep.message = "succeed"

        except Exception as e:
            rep = SetBoolResponse()
            rep.success = False
            rep.message = e
        return rep
예제 #10
0
 def taskStartCallback(self, req):
     res = SetBoolResponse()
     if req.data == True:
         self.task_start_ = True
         res.success = True
         res.message = "Task Start"
         rospy.loginfo("Task Start")
     else:
         self.task_start_ = False
         res.success = False
         res.message = "Task does not start"
         rospy.loginfo("Task does not start")
     return res
예제 #11
0
def changeState_handler(req):
    global g_state
    rospy.loginfo("Service called with data = %d", req.data)

    response = SetBoolResponse()

    if req.data == g_state:
        response.success = False
        response.message = "Incorrect call of the service"
    else:
        g_state = req.data
        response.success = True
        response.message = "Service succesfully called"

    return response
예제 #12
0
    def srvSwitch(self, request):
        """

        Args:
            request (:obj:`std_srvs.srv.SetBool`): The switch request from the ``~switch`` callback.

        Returns:
            :obj:`std_srvs.srv.SetBoolResponse`: Response for successful feedback

        """

        old_state = self._switch
        new_state = request.data

        self._switch = new_state
        for pub in self.publishers:
            pub.active = self._switch
        for sub in self.subscribers:
            sub.active = self._switch


        msg = 'Node switched from %s to %s' % ('on' if old_state else 'off',
                                               'on' if new_state else 'off')
        response = SetBoolResponse()
        response.success = True
        response.message = msg
        self.log(msg)

        return response
예제 #13
0
def safetyCallback(req):
    global safety_flag
    safety_flag = bool(req.data)
    safety_resp = SetBoolResponse()
    safety_resp.success = True
    safety_resp.message = ""
    return safety_resp
예제 #14
0
    def _srv_switch(self, request):
        """
        Args:
            request (:obj:`std_srvs.srv.SetBool`): The switch request from the ``~switch`` callback.

        Returns:
            :obj:`std_srvs.srv.SetBoolResponse`: Response for successful feedback

        """
        old_state = self._switch
        self._switch = new_state = request.data
        # propagate switch change to publishers and subscribers
        for pub in self.publishers:
            pub.active = self._switch
        for sub in self.subscribers:
            sub.active = self._switch
        # update node switch in the diagnostics manager
        if DTROSDiagnostics.enabled():
            DTROSDiagnostics.getInstance().update_node(
                enabled=self._switch
            )
        # create a response to the service call
        msg = 'Node switched from [%s] to [%s]' % (
            'on' if old_state else 'off',
            'on' if new_state else 'off'
        )
        # print out the change in state
        self.log(msg)
        # reply to the service call
        response = SetBoolResponse()
        response.success = True
        response.message = msg
        return response
def wall_follower_switch_counterclockwise(req):
    global active_
    active_ = req.data
    res = SetBoolResponse()
    res.success = True
    res.message = 'Done!'
    return res
def go_to_point_switch(req):
    global active_
    active_ = req.data
    res = SetBoolResponse()
    res.success = True
    res.message = 'Done!'
    return res
예제 #17
0
 def save_cb(self, req):
     if req.data == True:
         self.save_calibrate_result()
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #18
0
 def save_cb(self, req):
     if req.data == True:
         rospy.loginfo("Save File")
         self.close_file()
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #19
0
 def start_cb(self, req):
     if req.data == True:
         self.odom_start = self.odom[:]
         self.start = True
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #20
0
    def __saveImg_callback(self, req):
        """Service server request callback."""
        res = SetBoolResponse()

        if req.data:
            result = self.save()
            res.success = result
            res.message = self.__file_name if result else 'image not ready'
        else:
            """Data of requset is false then change name of directory."""
            self.__set_saveDirectory()
            res.success = True
            res.message = self.__directory
            print 'Change directory:', self.__directory
            self.__save_count = 0

        return res
예제 #21
0
 def finish_diving_cb(self, req):
     if req.data == True:
         rospy.loginfo("Finish Diving")
         self.finish_diving = True
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #22
0
def goal_stop(msg):
    global stop
    stop = msg.data
    response = SetBoolResponse()
    response.success = True
    response.message = "{} ".format(stop)
    rospy.loginfo("Goal Stopped Set: {}".format(stop))
    return response
예제 #23
0
 def clear_cb(self, req):
     if req.data == True:
         self.clear = True
     else:
         self.clear = False
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #24
0
    def srv_cb(self, req):

        self.safe_operation = req.data

        ans = SetBoolResponse()
        ans.success = True
        ans.message = self.event_msg + "{}".format(req.data)

        return ans
예제 #25
0
파일: test.py 프로젝트: yiannis88/sentor
    def func_pub_expr_2(self, req):

        self.pub_expr_2 = req.data

        ans = SetBoolResponse()
        ans.success = True
        ans.message = "Publishing expr_2 = {}".format(req.data)

        return ans
예제 #26
0
파일: test.py 프로젝트: yiannis88/sentor
    def set_expr_2(self, req):

        self.expr_2 = req.data

        ans = SetBoolResponse()
        ans.success = True
        ans.message = "Set expr_2 = {}".format(req.data)

        return ans
예제 #27
0
 def emergency_stop_cb(self, req):
     if req.data == True:
         self.emergency_stop = True
     else:
         self.emergency_stop = False
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #28
0
 def reset_cb(self, req):
     if req.data == True:
         self.full_goals = []
         self.goals = []
         self.get_path = False
     res = SetBoolResponse()
     res.success = True
     res.message = "recieved"
     return res
예제 #29
0
 def call_set_bool_common(self, event, client, request):
     try:
         resp = client.call(request)
         wx.CallAfter(self.update_reply_show, resp)
     except rospy.ServiceException, e:
         resp = SetBoolResponse()
         resp.success = False
         resp.message = 'no such service in simulation'
         wx.CallAfter(self.update_reply_show, resp)
예제 #30
0
    def set_safety_tag(self, req):

        self.safe_operation = req.data

        ans = SetBoolResponse()
        ans.success = True
        ans.message = "safe operation: {}".format(req.data)

        return ans
예제 #31
0
	def start_aruco_place(self, req):
		success = self.pick_type.pick_and_place_aruco("place")
		reply = SetBoolResponse()
		reply.success = success
		reply.message = ""
		return reply