From e0bb3729ef7a38d643bec60f27e0e1868e16af25 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Tue, 30 Apr 2024 12:58:05 -1000 Subject: [PATCH] DSLR Camera Initialization (#1252) * DSLR Camera Initialization * Use the values rather than the index settings, which seem to be more consistent across models. * * Testing without `autoexposuremode` * Change the order as a test. * Don't use quotes. --- src/panoptes/pocs/camera/gphoto/base.py | 3 +- src/panoptes/pocs/camera/gphoto/canon.py | 72 +++++++++++++----------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/panoptes/pocs/camera/gphoto/base.py b/src/panoptes/pocs/camera/gphoto/base.py index 77ce7db7a..e5f1f186f 100644 --- a/src/panoptes/pocs/camera/gphoto/base.py +++ b/src/panoptes/pocs/camera/gphoto/base.py @@ -89,6 +89,7 @@ def command(self, cmd: Union[List[str], str], check_exposing: bool = True): stderr=subprocess.PIPE, universal_newlines=True, ) + self.logger.debug(f'Started command on proc={self._command_proc.pid}') except OSError as e: raise error.InvalidCommand(f"Can't send command to gphoto2. {e} \t {run_cmd}") except ValueError as e: @@ -143,7 +144,7 @@ def set_property(self, prop: str, val: Union[str, int], is_value: bool = False, if is_index: set_cmd = ['--set-config-index', f'{prop}={val}'] elif is_value: - set_cmd = ['--set-config-value', f'{prop}="{val}"'] + set_cmd = ['--set-config-value', f'{prop}={val}'] else: set_cmd = ['--set-config', f'{prop}="{val}"'] diff --git a/src/panoptes/pocs/camera/gphoto/canon.py b/src/panoptes/pocs/camera/gphoto/canon.py index f5c1b668e..8b9fa26a5 100644 --- a/src/panoptes/pocs/camera/gphoto/canon.py +++ b/src/panoptes/pocs/camera/gphoto/canon.py @@ -1,14 +1,17 @@ from astropy import units as u -from panoptes.pocs.camera.gphoto.base import AbstractGPhotoCamera from panoptes.utils import error from panoptes.utils.time import current_time from panoptes.utils.utils import get_quantity_value +from panoptes.pocs.camera.gphoto.base import AbstractGPhotoCamera + class Camera(AbstractGPhotoCamera): - def __init__(self, readout_time: float = 1.0, file_extension: str = 'cr2', connect: bool = True, - *args, **kwargs): + def __init__( + self, readout_time: float = 1.0, file_extension: str = 'cr2', connect: bool = True, + *args, **kwargs + ): """Create a camera object for a Canon EOS DSLR. Args: @@ -48,42 +51,41 @@ def connect(self): self._serial_number = _serial_number # Properties to be set upon init. - prop2index = { - '/main/capturesettings/autoexposuremode': 3, # 3 - Manual; 4 - Bulb - '/main/capturesettings/drivemode': 0, # Single exposure - '/main/capturesettings/focusmode': 0, # Manual (don't try to focus) - '/main/imgsettings/imageformat': 9, # RAW - '/main/imgsettings/imageformatsd': 9, # RAW - '/main/settings/capturetarget': 0, # Capture to RAM, for download - '/main/settings/reviewtime': 0, # Screen off after taking pictures - '/main/imgsettings/iso': 1, # ISO 100 - '/main/capturesettings/shutterspeed': 0, # Bulb - } - owner_name = 'PANOPTES' artist_name = self.get_config('pan_id', default=owner_name) copy_right = f'{owner_name}_{current_time().datetime:%Y}' prop2value = { + 'drivemode': 'Single', + 'focusmode': 'Manual', + 'imageformat': 'RAW', + # 'autoexposuremode': 'Manual', # Need physical toggle. + # 'imageformatsd': 'RAW', # We shouldn't need to set this. + 'capturetarget': 'Internal RAM', + 'reviewtime': 'None', + 'iso': 100, + 'shutterspeed': 'bulb', 'artist': artist_name, 'copyright': copy_right, 'ownername': owner_name, } - self.set_properties(prop2index=prop2index, prop2value=prop2value) + self.set_properties(prop2value=prop2value) # TODO check this works on all Canon models. - # self.model = self.get_property('d402') + self.model = self.get_property('d402') self._connected = True - def _start_exposure(self, - seconds=None, - filename=None, - dark=False, - header=None, - iso=100, - *args, **kwargs): + def _start_exposure( + self, + seconds=None, + filename=None, + dark=False, + header=None, + iso=100, + *args, **kwargs + ): """Start the exposure. Tested With: @@ -109,17 +111,21 @@ def _start_exposure(self, if shutterspeed_idx == 0: # Bulb setting. - cmd_args.extend([ - f'--set-config-index', 'eosremoterelease=2', - f'--wait-event={int(seconds):d}s', - f'--set-config-index', 'eosremoterelease=4', - f'--wait-event-and-download=2s', - ]) + cmd_args.extend( + [ + f'--set-config-index', 'eosremoterelease=2', + f'--wait-event={int(seconds):d}s', + f'--set-config-index', 'eosremoterelease=4', + f'--wait-event-and-download=2s', + ] + ) else: # Known shutterspeed value. - cmd_args.extend([ - f'--capture-image-and-download', - ]) + cmd_args.extend( + [ + f'--capture-image-and-download', + ] + ) try: self.command(cmd_args, check_exposing=False)