Exemplo n.º 1
0
  def run(self):
    r = rospy.Rate(10)
    msg = Axis()

    while True:
      url = '%s:%s@%s' % (self.axis.username, self.axis.password, self.axis.hostname)
      auth = base64.encodestring("%s:%s" % (self.axis.username, self.axis.password))
      headers = {"Authorization" : "Basic %s" % auth}
      conn = httplib.HTTPConnection(self.axis.hostname)
      params = { 'query':'position' }
      conn.request("GET", "/axis-cgi/com/ptz.cgi?query=position",headers=headers) #, urllib.urlencode(params)
      response = conn.getresponse()
      #print(response.status)
      if response.status == 200:
        body = response.read()
        params = dict([s.split('=',2) for s in body.splitlines()])
        msg.pan = float(params['pan'])
        # Flip pan orient if the camera is mounted backwards and facing down
        if self.axis.flip:
            msg.pan = 180 - msg.pan
            if msg.pan > 180:
                msg.pan -= 360
            if msg.pan < -180:
                msg.pan += 360
        msg.tilt = float(params['tilt'])
        msg.zoom = float(params['zoom'])
        msg.iris = float(params['iris'])
        msg.focus = 0.0
        if 'focus' in params:
          msg.focus = float(params['focus'])
        msg.autofocus = (params['autofocus'] == 'on')
        self.axis.pub.publish(msg)
      r.sleep()
    def callback(self, config, level):
        #self.speedControl = config.speed_control

        # create temporary message and fill with data from dynamic reconfigure
        temp_msg = Axis()
        temp_msg.pan = config.pan
        temp_msg.tilt = config.tilt
        temp_msg.zoom = config.zoom
        temp_msg.focus = config.focus
        temp_msg.brightness = config.brightness
        temp_msg.autofocus = config.autofocus

        # check sanity and apply values
        self.cmd(temp_msg)

        # read sanitized values and update GUI
        config.pan = self.msg.pan
        config.tilt = self.msg.tilt
        config.zoom = self.msg.zoom
        config.focus = self.msg.focus
        config.brightness = self.msg.brightness
        config.autofocus = self.msg.autofocus

        # update GUI with sanitized values
        return config
Exemplo n.º 3
0
  def run(self):
    r = rospy.Rate(10)
    msg = Axis()

    while True:
      if not self.axis.timeout and ((rospy.Time.now() - self.axis.last_request).to_sec() > 1.0):
          self.axis.timeout = True
          self.axis.cmd(Twist(),reset_timeout=False)
      conn = httplib.HTTPConnection(self.axis.hostname)
      params = { 'query':'position' }
      conn.request("GET", "/axis-cgi/com/ptz.cgi?%s" % urllib.urlencode(params))
      response = conn.getresponse()
      if response.status == 200:
        body = response.read()
        params = dict([s.split('=',2) for s in body.splitlines()])
        msg.pan = float(params['pan'])
        # Flip pan orient if the camera is mounted backwards and facing down
        if self.axis.flip:
            msg.pan = 180 - msg.pan
            if msg.pan > 180:
                msg.pan -= 360
            if msg.pan < -180:
                msg.pan += 360
        msg.tilt = float(params['tilt'])
        msg.zoom = float(params['zoom'])
        msg.iris = float(params['iris'])
        msg.focus = 0.0
        if 'focus' in params:
          msg.focus = float(params['focus'])
        msg.autofocus = (params['autofocus'] == 'on')
        self.axis.pub.publish(msg)
      r.sleep()
Exemplo n.º 4
0
 def dynamicReconfigCallback(self, config, level):
     #self.speedControl = config.speed_control
     
     # create temporary message and fill with data from dynamic reconfigure
     temp_msg = Axis()
     temp_msg.pan = config.pan
     temp_msg.tilt = config.tilt
     temp_msg.zoom = config.zoom
     temp_msg.focus = config.focus
     temp_msg.brightness = config.brightness
     temp_msg.autofocus = config.autofocus
     
     # check sanity and apply values
     self.cmdCallback(temp_msg)
     
     # read sanitized values and update GUI
     config.pan = self.msg.pan
     config.tilt = self.msg.tilt
     config.zoom = self.msg.zoom
     config.focus = self.msg.focus
     config.brightness = self.msg.brightness
     config.autofocus = self.msg.autofocus
     
     # update GUI with sanitized values
     return config
Exemplo n.º 5
0
    def run(self):
        r = rospy.Rate(10)
        msg = Axis()

        while True:
            if not self.axis.twist_timeout and (
                (rospy.Time.now() - self.axis.last_request).to_sec() > 1.0):
                self.axis.twist_timeout = True
                self.axis.cmd_twist(Twist(), reset_timeout=False)
            conn = httplib.HTTPConnection(self.axis.hostname)
            params = {'query': 'position'}
            conn.request("GET",
                         "/axis-cgi/com/ptz.cgi?%s" % urllib.urlencode(params))
            response = conn.getresponse()
            if response.status == 200:
                body = response.read()
                params = dict([s.split('=', 2) for s in body.splitlines()])
                msg.pan = float(params['pan'])
                # Flip pan orient if the camera is mounted backwards and facing down
                if self.axis.flip:
                    msg.pan = 180 - msg.pan
                    if msg.pan > 180:
                        msg.pan -= 360
                    if msg.pan < -180:
                        msg.pan += 360
                msg.tilt = float(params['tilt'])
                msg.zoom = float(params['zoom'])
                msg.iris = float(params['iris'])
                msg.focus = 0.0
                if 'focus' in params:
                    msg.focus = float(params['focus'])
                msg.autofocus = (params['autofocus'] == 'on')
                self.axis.pub.publish(msg)
            r.sleep()
Exemplo n.º 6
0
    def callback(self, config, level):
        """Deprecated."""
        #self.speedControl = config.speed_control

        if self._executing_reconfigure or (hasattr(self, '_camera_controller') and (self._camera_controller._executing_parameter_update or self._camera_controller._executing_reconfigure)):
            return config

        with self._reconfigure_mutex:
            self._executing_reconfigure = True

            # create temporary message and fill with data from dynamic reconfigure
            command = Axis()
            command.pan = config.pan
            command.tilt = config.tilt
            command.zoom = config.zoom
            command.focus = config.focus
            command.brightness = config.brightness
            command.autofocus = config.autofocus

            # check sanity and apply values
            self.cmd(command)

            # read sanitized values and update GUI
            config.pan = command.pan
            config.tilt = command.tilt
            config.zoom = command.zoom
            config.focus = self._camera_controller._focus
            config.brightness = self._camera_controller._brightness
            config.autofocus = self._camera_controller._autofocus

            self._executing_reconfigure = False

            # update GUI with sanitized values
            return config