示例#1
0
 def test_pan_tilt(self, hpos, vpos):
     a = Axis()
     #a.fields = Axis.SELECT_PAN + Axis.SELECT_TILT
     a.pan = hpos  # Horizontal position
     a.tilt = vpos  # Vertical position
     print("Moving to %f %f " % (a.pan, a.tilt))
     self.pub.publish(a)
示例#2
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
示例#3
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()
    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
 def run(self):
     r = rospy.Rate(1)
     self.msg = Axis()
     while True:
         self.queryCameraPosition()
         self.publishCameraState()
         self.publishJointStates()
         r.sleep()
示例#6
0
    def __init__(self):
        rospy.init_node('axis_ptz_teleop')
        self.enable_button = rospy.get_param('~enable_button', 1)
        self.state = Axis(pan=220)
        self.joy = None

        self.pub = rospy.Publisher('cmd', Axis)
        rospy.Subscriber("joy", Joy, self.joy_callback)
示例#7
0
    def __init__(self):
        rospy.init_node('ptz_control_joystick')
        self.enable_button = rospy.get_param('~enable_button', 2)
        self.pan_axis = rospy.get_param('~teleop_axis_pan', 1)
        self.tilt_axis = rospy.get_param('~teleop_axis_tilt', 2)
        self.state = Axis(pan=220)
        self.joy = None

        self.pub = rospy.Publisher('cmd', Axis)
        rospy.Subscriber("joy", Joy, self.joy_callback)
 def initialiseVariables(self):
     self.joy = None
     self.msg = Axis()  # instantiate Axis message
     self.msg.autofocus = True  # autofocus is on by default
     # sensitivities[0..5] corresponding to fwd, left, up, tilt right,
     # tilt forwards, anticlockwise twist
     self.mirror = False
     self.mirror_already_actioned = False  # to stop mirror flip-flopping
     self.sensitivities = [120, -60, 40, 0, 0, 30]
     self.deadband = [0.2, 0.2, 0.2, 0.2, 0.4, 0.4]
示例#9
0
    def __init__(self):
        rospy.init_node('axis_twist_teleop')
        self.enable_button = rospy.get_param('~enable_button', 1)
        self.zero_button = rospy.get_param('~zero_button', 2)
        self.scale_pan = rospy.get_param('~scale_pan_deg', 10)
        self.scale_tilt = rospy.get_param('~scale_tilt_deg', 10)
        self.state = Axis(pan=180, tilt=0, zoom=1)
        self.joy = None

        self.cmd_pub = rospy.Publisher('cmd', Axis)
        self.twist_pub = rospy.Publisher('twist', Twist)
        rospy.Subscriber("/joy", Joy, self.joy_callback)
示例#10
0
    def __init__(self):
        self.enable_button = rospy.get_param('~enable_button', 1)
        self.enable_turbo_button = rospy.get_param('~enable_turbo_button', 3)
        self.camera_reset_pose_1 = rospy.get_param('~camera_reset_pose_1', 4)
        self.camera_reset_pose_2 = rospy.get_param('~camera_reset_pose_2', 5)
        self.axis_pan = rospy.get_param('~axis_pan', 0)
        self.axis_tilt = rospy.get_param('~axis_tilt', 1)
        self.axis_zoom = rospy.get_param('~axis_zoom', 6)
        self.pub_time = rospy.Time.now()
        self.pub = rospy.Publisher('cmd', Axis, queue_size=1)
        self.state = Axis(pan=10)
        self.state.brightness = 5000
        self.pub.publish(self.state)

        rospy.Subscriber("joy", Joy, self.joy_callback, queue_size=1)
示例#11
0
    def __init__(self):
        self.current_state = Axis()

        #PUB
        self.pub_pantilts = rospy.Publisher('/pan_tilts',
                                            PanTilts,
                                            queue_size=10)
        self.pub = rospy.Publisher('/imgg/compressed',
                                   CompressedImage,
                                   queue_size=10)

        #SUB
        self.sub_cam = rospy.Subscriber('/axis/state', Axis, self.update_state)
        self.sub = rospy.Subscriber('axis/image_raw/compressed',
                                    CompressedImage, self.callback)

        print("Detect node started")
示例#12
0
    def __init__(self):

        self.current_state = Axis()
        self.lastcall = time.time()
        self.mode = 'TRACK'
        self.sens_pan = 1

        #PUB
        self.pub_cam = rospy.Publisher('axis/cmd', Axis)

        #SUB
        self.sub_cam = rospy.Subscriber('/axis/state', Axis, self.update_state)
        self.sub_pantilts = rospy.Subscriber('/pan_tilts', PanTilts,
                                             self.callback)

        #http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28python%29#rospy_tutorials.2BAC8-Tutorials.2BAC8-WritingServiceClient.CA-27047f5058d93f3c972525600be4e0b4132b06a5_13
        self.ser_mode = rospy.Service('/camera_mod', ChangeTrackingMode,
                                      self.change_mode)

        print("Tracker started in mode : " + self.mode)
示例#13
0
    def __init__(self, pos_filename):

        self.current_state = Axis()

        #SUB
        self.sub_cam = rospy.Subscriber('/axis/state', Axis, self.update_state)

        #http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28python%29#rospy_tutorials.2BAC8-Tutorials.2BAC8-WritingServiceClient.CA-27047f5058d93f3c972525600be4e0b4132b06a5_13
        self.ser = rospy.Service('/record', Empty, self.save_position)
        self.positions = []

        print('ICI')
        print(os.getcwd())

        with open(pos_filename, 'r') as f:
            self.positions = [x.split(',') for x in f.read().split('\n')[1:-1]]

        self.pos_index = 0

        self.data = open('positions_pan_tilt.txt', 'a')

        self.next_pos()
    def __init__(self, axis, api):
        """Create the thread.

        :param axis: The parameter source.
        :type axis: :py:class:`AxisPTZ`
        :param api: The VAPIX API instance that allows the thread to access positional data.
        :type api: :py:class:`VAPIX`
        """
        threading.Thread.__init__(self)

        self.axis = axis
        self.api = api

        # Permit program to exit even if threads are still running by flagging
        # thread as a daemon:
        self.daemon = True

        self._diagnostic_updater = Updater()
        self._diagnostic_updater.setHardwareID(api.hostname)

        # BACKWARDS COMPATIBILITY LAYER
        self.cameraPosition = None  # deprecated
        self.msg = Axis()  # deprecated
示例#15
0
 def __init__(self):
     rospy.init_node('axis_ptz_random_move')
     self.pub = rospy.Publisher('/cmd', Axis)
     a = Axis()
     self.pub.publish(a)
plt.plot(t, y, 'o-')
plt.legend(['data'], loc='best')
plt.show(block = False)



def sigint_handler(sig, frame):
    print("Ending...")
    sys.exit()



#ROS Axis control 
rospy.init_node('axis_spline')
axis_state = Axis(pan=0)
command_state = Float64()
#spline_pub = rospy.Publisher('cmd', Axis, queue_size=10)
spline_pub = rospy.Publisher('pan_joint_position_controller/command', Float64, queue_size=10)
r = rospy.Rate( 1/(max_time/samples))

# Set signal to exit using terminal
signal.signal(signal.SIGINT, sigint_handler)

count = int()
count = 0

while not rospy.is_shutdown():

    for point in y:
        
示例#17
0
 def test_zoom(self, z):
     print("Zooming %f " % z)
     a = Axis()
     #a.fields = Axis.SELECT_ZOOM
     a.zoom = z
     self.pub.publish(a)