Skip to content

Commit

Permalink
DSLR Camera Initialization (#1252)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
wtgee authored Apr 30, 2024
1 parent b93d547 commit e0bb372
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/panoptes/pocs/camera/gphoto/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}"']

Expand Down
72 changes: 39 additions & 33 deletions src/panoptes/pocs/camera/gphoto/canon.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit e0bb372

Please sign in to comment.