Exemple #1
0
    def __init__(self, name):
        """
        Constructor.

        @param name: camera identifier.  You can get a list of valid
                     identifiers by calling the ROS service /cameras/list.

                     Expected names are right_hand_camera, left_hand_camera
                     and head_camera.  However if the cameras are not
                     identified via the parameter server, they are simply
                     indexed starting at 0.
        """
        self._id = name

        list_svc = rospy.ServiceProxy('/cameras/list', ListCameras)
        rospy.wait_for_service('/cameras/list', timeout=10)
        if not self._id in list_svc().cameras:
            raise AttributeError("Invalid camera name '%s'" % (self._id, ))

        self._open_svc = rospy.ServiceProxy('/cameras/open', OpenCamera)
        self._close_svc = rospy.ServiceProxy('/cameras/close', CloseCamera)

        self._settings = CameraSettings()
        self._settings.width = 320
        self._settings.height = 200
        self._settings.fps = 20
        self._open = False
    def __init__(self, name, robot_ns='/'):
        """
        Constructor.

        @param name: camera identifier.  You can get a list of valid
                     identifiers by calling the ROS service /cameras/list.

                     Expected names are right_hand_camera, left_hand_camera
                     and head_camera.  However if the cameras are not
                     identified via the parameter server, they are simply
                     indexed starting at 0.
        """
        self._id = name

        list_svc = rospy.ServiceProxy(robot_ns + 'cameras/list', ListCameras)
        rospy.wait_for_service(robot_ns + 'cameras/list', timeout=10)
        if not self._id in list_svc().cameras:
            raise AttributeError(
                ("Cannot locate a service for camera name '{0}'. "
                 "Close a different camera first and try again.".format(
                     self._id)))

        self._open_svc = rospy.ServiceProxy(robot_ns + 'cameras/open',
                                            OpenCamera)
        self._close_svc = rospy.ServiceProxy(robot_ns + 'cameras/close',
                                             CloseCamera)

        self._settings = CameraSettings()
        self._settings.width = 320
        self._settings.height = 200
        self._settings.fps = 20
        self._open = False
Exemple #3
0
    def open_camera(self, arm):

        self.image_pub = rospy.Publisher('/robot/xdisplay',
                                         Image,
                                         queue_size=10)

        self.image_sub = rospy.Subscriber("image_topic", Image, self.callback)
        self.subscribe_to_camera(arm)

        # reset cameras
        """
        Constructor.
        @param name: camera identifier.  You can get a list of valid
                     identifiers by calling the ROS service /cameras/list.
                     Expected names are right_hand_camera, left_hand_camera
                     and head_camera.  However if the cameras are not
                     identified via the parameter server, they are simply
                     indexed starting at 0.
        """
        if (arm == "left"):
            self._id = "left_hand_camera"
        elif (arm == "right"):
            self._id = "right_hand_camera"
        else:
            self._id = "head_camera"

        # camera parameters (NB. other parameters in open_camera)
        self.cam_calib = 0.0025  # meters per pixel at 1 meter
        self.cam_x_offset = 0.045  # camera gripper offset
        self.cam_y_offset = -0.01

        list_svc = rospy.ServiceProxy('/cameras/list', ListCameras)
        rospy.wait_for_service('/cameras/list', timeout=10)
        if not self._id in list_svc().cameras:
            raise AttributeError(
                ("Cannot locate a service for camera name '{0}'. "
                 "Close a different camera first and try again.".format(
                     self._id)))

        self._settings = CameraSettings()
        self.width = self._settings.width = 960
        self.height = self._settings.height = 600
        self._settings.fps = 20
        self._open = False

        self._open_svc = rospy.ServiceProxy('/cameras/open', OpenCamera)
        self._close_svc = rospy.ServiceProxy('/cameras/close', CloseCamera)
        self.image_num = 0
 def createCameraSettings(**kwargs):
     settings = CameraSettings()
     settings.controls = []
     if "width" in kwargs:
         settings.width = kwargs["width"]
     if "height" in kwargs:
         settings.height = kwargs["height"]
     if "fps" in kwargs:
         settings.fps = kwargs["fps"]
     if "exposure" in kwargs:
         CameraController._setCameraController(
             settings.controls, CameraControl.CAMERA_CONTROL_EXPOSURE,
             kwargs["exposure"])
     if "gain" in kwargs:
         CameraController._setCameraController(
             settings.controls, CameraControl.CAMERA_CONTROL_GAIN,
             kwargs["gain"])
     if "whiteBalanceR" in kwargs:
         CameraController._setCameraController(
             settings.controls,
             CameraControl.CAMERA_CONTROL_WHITE_BALANCE_R,
             kwargs["whiteBalanceR"])
     if "whiteBalanceG" in kwargs:
         CameraController._setCameraController(
             settings.controls,
             CameraControl.CAMERA_CONTROL_WHITE_BALANCE_G,
             kwargs["whiteBalanceG"])
     if "whiteBalanceB" in kwargs:
         CameraController._setCameraController(
             settings.controls,
             CameraControl.CAMERA_CONTROL_WHITE_BALANCE_B,
             kwargs["whiteBalanceB"])
     if "windowX" in kwargs:
         CameraController._setCameraController(
             settings.controls, CameraControl.CAMERA_CONTROL_WINDOW_X,
             kwargs["windowX"])
     if "windowY" in kwargs:
         CameraController._setCameraController(
             settings.controls, CameraControl.CAMERA_CONTROL_WINDOW_Y,
             kwargs["windowY"])
     if "flip" in kwargs:
         CameraController._setCameraController(
             settings.controls, CameraControl.CAMERA_CONTROL_FLIP,
             kwargs["flip"])
     if "mirror" in kwargs:
         CameraController._setCameraController(
             settings.controls, CameraControl.CAMERA_CONTROL_MIRROR,
             kwargs["mirror"])
     if "resolutionHalf" in kwargs:
         CameraController._setCameraController(
             settings.controls,
             CameraControl.CAMERA_CONTROL_RESOLUTION_HALF,
             kwargs["resolutionHalf"])
     return settings
Exemple #5
0
 def _getDefaultSettings():
     defaultSettings = CameraSettings()
     # Default camera setting on startup: http://sdk.rethinkrobotics.com/wiki/Cameras
     # defaultSettings.width = CameraControls._defaultWidth
     # defaultSettings.height = CameraControls._defaultHeight
     # defaultSettings.fps = CameraControls._defaultFps
     # NOTE (amal): the below default values were removed because Baxter has
     # built-in defaults it sets internally, so I decided to defer to those.
     # # Auto Camera CameraControls
     # controls = []
     # CameraControls._setCameraControls(controls, CameraControl.CAMERA_CONTROL_EXPOSURE, CameraControls._autoControl)
     # CameraControls._setCameraControls(controls, CameraControl.CAMERA_CONTROL_GAIN, CameraControls._autoControl)
     # CameraControls._setCameraControls(controls, CameraControl.CAMERA_CONTROL_WHITE_BALANCE_R, CameraControls._autoControl)
     # CameraControls._setCameraControls(controls, CameraControl.CAMERA_CONTROL_WHITE_BALANCE_G, CameraControls._autoControl)
     # CameraControls._setCameraControls(controls, CameraControl.CAMERA_CONTROL_WHITE_BALANCE_B, CameraControls._autoControl)
     # CameraControls._setCameraControls(controls, CameraControl.CAMERA_CONTROL_RESOLUTION_HALF, 1)
     # defaultSettings.controls = controls
     return defaultSettings
    def __init__(self, name):
        """
        Constructor.

        @param name: camera identifier.  You can get a list of valid
                     identifiers by calling the ROS service /cameras/list.

                     Expected names are right_hand_camera, left_hand_camera
                     and head_camera.  However if the cameras are not
                     identified via the parameter server, they are simply
                     indexed starting at 0.
        """
        self._id = name

        self._open_svc = rospy.ServiceProxy('/cameras/open', OpenCamera)
        self._close_svc = rospy.ServiceProxy('/cameras/close', CloseCamera)

        self._settings = CameraSettings()
        self._settings.width = 320
        self._settings.height = 200
        self._settings.fps = 20
        self._open = False