Can't control THETA Z1 using Raspberry Pi and USB API

I am trying to use the THETA USB API to control a THETA Z1 from a Raspberry Pi.

I created the following shell script and tried to run it periodically using cron on multiple THETA Z1. However, some THETA Z1 are not able to run it regularly.

The shutter speed is set in an external file.

echo '   --- Wake Theta from Sleep !!'
theta --set-property=0xD80E --val=0x00
sleep 15

echo '   --- Set Exposure Mode -> Manual !!'
theta --set-property=0x500E --val=0x0001

echo '   --- Set F-Number -> F2.1 !!'
theta --set-property=0x5007 --val=0x00D2

echo '   --- Set Image Size -> 6720x3360 !!'
theta --set-property=0x5003 --val="6720x3360"

echo '   --- Set ISO Number -> 100 !!'
theta --set-property=0x500F --val=100

echo '   --- Set Audio volume -> 0 !!'
theta --set-property=0x502C --val=0

echo '   --- Set Color Temperature Mode -> Manual !!'
theta --set-property=0x5005 --val=0x8007
echo '   --- Set Color Temperature[K] -> 6500 !!'
theta --set-property=0xD813 --val=6500

echo '   --- Set File Format -> JPEG !!'
theta --set-property=0xD827 --val=0x00

sleep 5

##  ---------------------------

wait_cap=3

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 25000 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_25000.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}


echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 12500 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_12500.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 3200 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_3200.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 1600 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_1600.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 400 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_400.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 200 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_200.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 50 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_50.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 25 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_25.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 6 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_6.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 3 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-1_3.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}

echo ' '
echo ' #### #### #### #### #### #### #### #### #### #### #### ####'
echo ' ' 
echo '   --- Set Shutter Speed from Config File !!'
echo '   --- 1 / 1.6 ---'
echo ' ' 
theta -R 0x1016,0xd00f,0,0,0,0,/home/kankyo/theta/ext-10_16.bin
sleep 0.5

echo ' '
echo '   ### Capture Command! ###'
echo ' '
theta --capture
echo ' '
sleep ${wait_cap}


## ---------------------------------------------------------------------

theta --set-property=0xD80E --val=0x01

The current situation is as follows.

・There were no particular problems when running the program before regular execution.

・When I checked the log during regular execution, it said “Could not open session.”

・If I enter the “theta --info” command, device information will appear, so it is probably unmounted.

・THETA Z1, which cannot be executed regularly, is a rental product. The shooting settings set by the previous user remain on the THETA.

There seems to be a problem with THETA Z1, but I don’t know why it cannot be run regularly. I would appreciate your advice.

  1. confirm that automount is disabled

See this article:
Disable THETA Automount on Linux and NVIDIA Jetson for USB API

  1. Upgrade firmware of Z1.
  2. Try using gphoto2 instead of libptp2.

Post version of firmware you are using on the Z1.

libptp2 is getting old.

What is the frequency of pictures?

It’s possible that you’ll need to check the status of the camera before taking the next picture.

I do not know the correct API. However, these two might be relevant.

theta-api-specs/theta-usb-api/event/capture_complete.md at main · ricohapi/theta-api-specs · GitHub

theta-api-specs/theta-usb-api/property/capture_status.md at main · ricohapi/theta-api-specs · GitHub

Thank you for your reply.

When I reboot the Raspberry Pi, THETA will be unmounted and the above shell script will be executed. After that, the shell script will be executed periodically. The periodic execution interval is 1 hour.

@reboot sleep 25; /home/kankyo/theta/unmountTheta.sh >> unmountTheta.log 2>&1
@reboot sleep 30; /home/kankyo/theta/thetaUsbApi.sh >> thetaAPI-sh.log 2>&1

0 10-15 * * * /home/kankyo/theta/thetaUsbApi.sh >> thetaAPI-sh.log 2>&1

I wrote a command in crontab to automatically unmount the system when I reboot. I didn’t know how to disable automount, so I’ll try that.

The firmware version is 3.30.2, which is probably the latest version.
In addition, THETA Z1 is controlled using a Raspberry Pi 4 model B (OS: Bullseye 64bit).

I’ll look into gphoto2.

The log when the shell script does not run properly is shown below. When running a shell script in crontab, it may not work as shown below, but it may run without any problems.

 --- Start Script ---
 ---  2024年 8月 21日 水曜日 15:48:17 JST
 
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
   --- Wake Theta from Sleep !!
ERROR: Could not open session!

   --- Set Exposure Mode -> Manual !!

Camera: RICOH THETA Z1
'Exposure Program Mode' is set to: [Automatic (P)]
Changing property value to 0x0001 [(null)] succeeded.
   --- Set F-Number -> F2.1 !!
ERROR: Could not open session!

   --- Set Image Size -> 6720x3360 !!
ERROR: Could not open session!

   --- Set ISO Number -> 100 !!

Camera: RICOH THETA Z1
'Exposure Index (film speed ISO)' is set to: 0x0064 (100)
Changing property value to 100 [(null)] succeeded.
   --- Set Audio volume -> 0 !!
ERROR: Could not open session!

   --- Set Color Temperature Mode -> Manual !!
ERROR: Could not open session!

   --- Set Color Temperature[K] -> 6500 !!
ERROR: Could not open session!

   --- Set File Format -> JPEG !!

Camera: RICOH THETA Z1
'UNKNOWN' is set to: 0
Changing property value to 0x00 [(null)] succeeded.
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 25000 ---
 
data to send : '/home/kankyo/theta/ext-1_25000.bin'
--- data to send ---
01 00 00 00 a8 61 00 00                         - .....a..        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
PTP: response OK
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 12500 ---
 
PTP: Device Busy
PTP: ERROR: response 0x2019
data to send : '/home/kankyo/theta/ext-1_12500.bin'
--- data to send ---
01 00 00 00 d4 30 00 00                         - .....0..        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
 
   ### Capture Command! ###
 

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 3200 ---
 
data to send : '/home/kankyo/theta/ext-1_3200.bin'
--- data to send ---
01 00 00 00 80 0c 00 00                         - ........        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
PTP: response OK
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 1600 ---
 
PTP: Device Busy
PTP: ERROR: response 0x2019
data to send : '/home/kankyo/theta/ext-1_1600.bin'
--- data to send ---
01 00 00 00 40 06 00 00                         - ....@...        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
 
   ### Capture Command! ###
 

Initiating capture...
Object added 0x00001192
Capture completed successfully!
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 400 ---
 
ERROR: Could not open session!
data to send : '/home/kankyo/theta/ext-1_400.bin'
--- data to send ---
01 00 00 00 90 01 00 00                         - ........        
--------------------
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 200 ---
 
data to send : '/home/kankyo/theta/ext-1_200.bin'
--- data to send ---
01 00 00 00 c8 00 00 00                         - ........        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
PTP: response OK
 
   ### Capture Command! ###
 

Initiating capture...
Object added 0x00001194
Capture completed successfully!
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 50 ---
 
ERROR: Could not open session!
data to send : '/home/kankyo/theta/ext-1_50.bin'
--- data to send ---
01 00 00 00 32 00 00 00                         - ....2...        
--------------------
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 25 ---
 
data to send : '/home/kankyo/theta/ext-1_25.bin'
--- data to send ---
01 00 00 00 19 00 00 00                         - ........        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
PTP: response OK
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 6 ---
 
ERROR: Could not open session!
data to send : '/home/kankyo/theta/ext-1_6.bin'
--- data to send ---
01 00 00 00 06 00 00 00                         - ........        
--------------------
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 3 ---
 
data to send : '/home/kankyo/theta/ext-1_3.bin'
--- data to send ---
01 00 00 00 03 00 00 00                         - ........        
--------------------
Camera: RICOH THETA Z1
Sending generic request: reqCode=0x1016, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
PTP: response OK
 
   ### Capture Command! ###
 

Initiating capture...
Object added 0x00001197
Capture completed successfully!
 
 
 #### #### #### #### #### #### #### #### #### #### #### ####
 
   --- Set Shutter Speed from Config File !!
   --- 1 / 1.6 ---
 
ERROR: Could not open session!
data to send : '/home/kankyo/theta/ext-10_16.bin'
--- data to send ---
0a 00 00 00 10 00 00 00                         - ........        
--------------------
 
   ### Capture Command! ###
 
ERROR: Could not open session!

Initiating capture...
 

Camera: RICOH THETA Z1
'UNKNOWN' is set to: 0
Changing property value to 0x01 [(null)] succeeded.

I have not tested this on a Raspberry Pi yet, but it seems you can disable automount within /home/pi/.config/pcmanfm/LXDE-pi/pcmanfm.conf

https://forums.raspberrypi.com/viewtopic.php?t=91677

Here’s another example:

There are some examples of using gphoto2 here

THETA X Firmware 2.50.2 Improves USB API in Unofficial Community Tests

Thank you for the additional information.
I will check it.