# Extensions and tracking camera

Source: https://forum.modalai.com/topic/880/extensions-and-tracking-camera
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2022-04-23 07:40:57 UTC by Steve Turner
Replies: 6 · Views: 1103

## Steve Turner · 2022-04-23 07:40:57 UTC

Trying out extensions on all cameras given the design of my prototype and finding that I cannot get the tracking camera to initialize when an extension is connected. Tracking camera is installed on J4. It boots and shows up fine in the portal/camera server when there is no extension.

I've reviewed https://forum.modalai.com/topic/290/tracking-camera-bricks-boot?_=1650699418574

and https://forum.modalai.com/topic/333/max-mipi-cable-extension-length?_=1650699561031

Which led me to validate the orientation of the connectors and also try the shorter 6cm extension. What's odd is the stereo cameras and ToF work fine on extensions, but I cannot get the tracking camera to initialize. `voxl-camera-server` segfaults everytime after a successful boot with any extension installed.

Thanks for any help troubleshooting.

## Reply by Steve Turner · 2022-04-25 05:54:25 UTC

For more data -- here's the debug output of the camera server.
Have been trying to load up a segfault/dump without success as of yet.
```
------ voxl-camera-server INFO: Port J2

------ voxl-camera-server: Done configuring tof camera
	 Port       : port_J2
	 Name       : tof
	 Enabled    : 1
	 Type       : tof
	 Api        : hal3
	 P-W        : 224
	 P-H        : 1557
	 P-Fmt      : blob
	 FPS        : 15
	 Tof Mode   : 9
	 OverrideId : -1
	 AEAlgo     : isp

------ voxl-camera-server INFO: Port J3

------ voxl-camera-server: Done configuring stereo camera
	 Port       : port_J3
	 Name       : stereo
	 Enabled    : 1
	 Type       : stereo
	 Api        : hal3
	 P-W        : 1280
	 P-H        : 480
	 P-Fmt      : nv21
	 FPS        : 30
	 OverrideId : -1
	 AEAlgo     : modalai
=================MODALAI Auto Exposure Settings==================
gain_min:                        0
gain_max:                        1000
exposure_min_us:                 20
exposure_max_us:                 33000
desired_msv:                     58.000000
k_p_ns:                          32000.000000
k_i_ns:                          20.000000
max_i:                           250.000000
p_good_thresh:                   3
exposure_period:                 1
gain_period:                     2
display_debug:                   no
exposure_offset_for_gain_calc:   8000
=================================================================

------ voxl-camera-server INFO: Port J4

------ voxl-camera-server: Done configuring tracking camera
	 Port       : port_J4
	 Name       : tracking
	 Enabled    : 1
	 Type       : tracking
	 Api        : hal3
	 P-W        : 640
	 P-H        : 480
	 P-Fmt      : raw8
	 FPS        : 30
	 OverrideId : -1
	 AEAlgo     : modalai
=================MODALAI Auto Exposure Settings==================
gain_min:                        0
gain_max:                        1000
exposure_min_us:                 20
exposure_max_us:                 33000
desired_msv:                     58.000000
k_p_ns:                          32000.000000
k_i_ns:                          20.000000
max_i:                           250.000000
p_good_thresh:                   3
exposure_period:                 1
gain_period:                     2
display_debug:                   no
exposure_offset_for_gain_calc:   8000
=================================================================

Writing new configuration to /etc/modalai/voxl-camera-server.conf
Created pipe: tof channel: 5
Created pipe: stereo channel: 6
Created pipe: tracking channel: 7
Starting Camera: tracking
SUCCESS: Camera module opened
----------- Number of cameras: 2

----------- Stereo camera id: 1
----------- Mono   camera id: 0
Available resolutions for camera: tracking:
640 x 480
320 x 240
Resolution: 640 x 480 Found!
------ voxl-camera-server: Preview buffer allocations
Internal Exposure for: tracking 7
/builds/voxl-public/voxl-sdk/services/apq8096-camera-server/src/expgain_interface/expgain_interface_factory.cpp 45 Creating exposure interface
Creating ModalAI exposure interface
Initialize
Initialize
------ voxl-camera-server WARNING: Thread: tracking result thread recieved ESTOP
	 Port       : port_J4
------ voxl-camera-server WARNING: Thread: tracking request thread recieved ESTOP
	 Name       : tracking
	 Enabled    : 1
	 Type       : tracking
	 Api        : hal3
	 P-W        : 640
	 P-H        : 480
	 P-Fmt      : raw8
	 FPS        : 30
	 OverrideId : -1
	 AEAlgo     : modalai
=================MODALAI Auto Exposure Settings==================
gain_min:                        0
gain_max:                        1000
exposure_min_us:                 20
exposure_max_us:                 33000
desired_msv:                     58.000000
k_p_ns:                          32000.000000
k_i_ns:                          20.000000
max_i:                           250.000000
p_good_thresh:                   3
exposure_period:                 1
gain_period:                     2
display_debug:                   no
exposure_offset_for_gain_calc:   8000
=================================================================

Starting Camera: tof

------ voxl-camera-server INFO: Camera server is now stopping
		There is a chance that it may segfault here, this is a mmqcamera bug, ignore it

------ voxl-camera-server INFO: Stopping tracking camera
------ voxl-camera-server INFO: tracking camera stopped successfully

------ voxl-camera-server INFO: Stopping tof camera

Segmentation fault:
Fault thread: voxl-camera-ser(tid: 3431)
Fault address: 0x68
Address not mapped.
Segmentation fault

## Reply by Guest · 2022-04-25 17:22:13 UTC

Hi Steve, 

It looks like the tof camera is causing the issue here, camera server only found 2 cameras (tracking and stereo), but is configured for 3. I think the segfault may be a result of not properly handling a misconfiguration, but the camera server is stopping because the TOF camera is failing to start (we see "starting camera: tof" and then none of the rest of the initialization info)

## Reply by Steve Turner · 2022-07-11 05:32:37 UTC

@Alex-Gardner Thanks for your support a few months ago.

Having a strange issue on a VOXL 1 with the camera configuration and latest released VOXL system image. This is a Starling with ToF, Tracking, and HiRES camera all connected. I am running `VOXL Platform 3.8.0-0.7` and `voxl-camera-server 0.9.1`.

When I run `voxl-configure-cameras 5` and start the server all is well. I get good outputs from the ToF and the tracking camera. However, when I configure with `voxl-configure-cameras 6` to enable the HIRES camera, I get a segfault as shown below. I've tried reseating the camera a few times to see if that made a difference. I've also tried now on two devices with the same result since upgrading to 3.8.0 system image. I'm sure I'm missing something silly or maybe a dependency is off?

Here's the output from the camera server before it crashes.

```
root@apq8096:~# voxl-camera-server -d 0
------ voxl-camera-server INFO: Port J2

------ voxl-camera-server: Done configuring hires camera
	 Port       : port_J2
	 Name       : hires
	 Enabled    : 1
	 Type       : hires
	 Api        : hal3
	 P-W        : 640
	 P-H        : 480
	 P-Fmt      : nv21
	 FPS        : 30
	 OverrideId : -1
	 AEAlgo     : isp

------ voxl-camera-server INFO: Port J3

------ voxl-camera-server: Done configuring tof camera
	 Port       : port_J3
	 Name       : tof
	 Enabled    : 1
	 Type       : tof
	 Api        : hal3
	 P-W        : 224
	 P-H        : 1557
	 P-Fmt      : blob
	 FPS        : 15
	 Tof Mode   : 9
	 OverrideId : -1
	 AEAlgo     : isp

------ voxl-camera-server INFO: Port J4

------ voxl-camera-server: Done configuring tracking camera
	 Port       : port_J4
	 Name       : tracking
	 Enabled    : 1
	 Type       : tracking
	 Api        : hal3
	 P-W        : 640
	 P-H        : 480
	 P-Fmt      : raw8
	 FPS        : 30
	 OverrideId : -1
	 AEAlgo     : modalai
=================MODALAI Auto Exposure Settings==================
gain_min:                        100
gain_max:                        1000
exposure_min_us:                 20
exposure_max_us:                 30000
desired_msv:                     68.000000
k_p_ns:                          6000.000000
k_i_ns:                          20.000000
max_i:                           250.000000
p_good_thresh:                   3
exposure_period:                 2
gain_period:                     4
display_debug:                   no
exposure_offset_for_gain_calc:   3000
=================================================================

Writing new configuration to /etc/modalai/voxl-camera-server.conf
Created pipe: hires channel: 0
Created pipe: tof channel: 6
Created pipe: tracking channel: 7
Starting Camera: tracking
SUCCESS: Camera module opened
----------- Number of cameras: 2

----------- ToF    camera id: 0
----------- Mono   camera id: 1
------ voxl-camera-server INFO: Client: qvio-server0 connected to channel: 7
Available resolutions for camera: tracking:
640 x 480
320 x 240
Resolution: 640 x 480 Found!
------ voxl-camera-server: Preview buffer allocations
Internal Exposure for: tracking 7
/builds/voxl-public/voxl-sdk/services/apq8096-camera-server/src/expgain_interface/expgain_interface_factory.cpp 45 Creating exposure interface
Creating ModalAI exposure interface
Initialize
Initialize
	 Port       : port_J4
	 Name       : tracking
	 Enabled    : 1
	 Type       : tracking
	 Api        : hal3
	 P-W        : 640
	 P-H        : 480
	 P-Fmt      : raw8
	 FPS        : 30
	 OverrideId : -1
	 AEAlgo     : modalai
=================MODALAI Auto Exposure Settings==================
gain_min:                        100
gain_max:                        1000
exposure_min_us:                 20
exposure_max_us:                 30000
desired_msv:                     68.000000
k_p_ns:                          6000.000000
k_i_ns:                          20.000000
max_i:                           250.000000
p_good_thresh:                   3
exposure_period:                 2
gain_period:                     4
display_debug:                   no
exposure_offset_for_gain_calc:   3000
=================================================================

Starting Camera: tof
------ voxl-camera-server: Preview buffer allocations

SUCCESS: TOF interface created!
Received raw10 frame, checking to see if is actually raw8
Frame was actually 8 bit, sending as is
Internal AE new val:exposure 20000 gain 100
Internal AE new val:exposure 406225 gain 100
Internal AE new val:exposure 804255 gain 100

=========== modalai  Royale3.31, Spectre4.7 CameraDevice::activateUseCase() : return SUCCESS!!
Setting use case: mode=9, fps = 15
=========== modalai  Royale3.31, Spectre4.7 CameraDevice::activateUseCase() : return SUCCESS!!SUCCESS: TOF interface initialized!
Libcamera sending RAW16 TOF data. App calling the PMD libs to postprocess the RAW16 data
Loading lens parameters from /data/misc/camera/irs10x0c_lens.cal.	 Port       : port_J3
	 Name       : tof
	 Enabled    : 1
	 Type       : tof
	 Api        : hal3
	 P-W        : 224
	 P-H        : 1557
	 P-Fmt      : blob
	 FPS        : 15
	 Tof Mode   : 9
	 OverrideId : -1
	 AEAlgo     : isp

Starting Camera: hires

------ voxl-camera-server INFO: Camera server is now stopping
		There is a chance that it may segfault here, this is a mmqcamera bug, ignore it

------ voxl-camera-server INFO: Stopping tracking camera
------ Result thread on camera: tracking recieved stop command, exiting
------ voxl-camera-server INFO: tracking camera stopped successfully

------ voxl-camera-server INFO: Stopping hires camera
```

Here is my config file:
```
{
	"version":	0.2,
	"port_J2":	{
		"name":	"hires",
		"enabled":	true,
		"type":	"hires",
		"api":	"hal3",
		"frame_rate":	30,
		"override_id":	-1,
		"auto_exposure_mode":	"isp",
		"preview":	{
			"enabled":	true,
			"width":	640,
			"height":	480,
			"format":	"nv21"
		},
		"video":	{
			"enabled":	false,
			"width":	1024,
			"height":	768,
			"format":	"h265"
		},
		"snapshot":	{
			"enabled":	false,
			"width":	1024,
			"height":	768,
			"format":	"jpg"
		}
	},
	"port_J3":	{
		"name":	"tof",
		"enabled":	true,
		"type":	"tof",
		"api":	"hal3",
		"tof_mode":	9,
		"frame_rate":	15,
		"override_id":	-1,
		"auto_exposure_mode":	"isp",
		"preview":	{
			"enabled":	true,
			"width":	224,
			"height":	1557,
			"format":	"blob"
		}
	},
	"port_J4":	{
		"name":	"tracking",
		"enabled":	true,
		"type":	"tracking",
		"api":	"hal3",
		"frame_rate":	30,
		"override_id":	-1,
		"auto_exposure_mode":	"modalai",
		"manual_gain":	1000,
		"modal_ae_gain_min":	100,
		"modal_ae_gain_max":	1000,
		"modal_ae_gain_period":	4,
		"modal_ae_exposure_min_us":	20,
		"modal_ae_exposure_max_us":	30000,
		"modal_ae_exposure_period":	2,
		"modal_ae_exposure_offset":	3000,
		"modal_ae_desired_msv":	68,
		"modal_ae_k_p_ns":	6000,
		"modal_ae_k_i_ns":	20,
		"modal_ae_max_i":	250,
		"modal_ae_good_thresh":	3,
		"modal_ae_display_debug":	false,
		"preview":	{
			"enabled":	true,
			"width":	640,
			"height":	480,
			"format":	"raw8"
		}
	}
}
```

## Reply by Guest · 2022-07-11 21:43:15 UTC

Can you post the output of a failed run?

I just ran a quick test on my board with camera config 6 with a fresh 3.8.0-0.7 flash and everything seems to be fine.

## Reply by Steve Turner · 2022-07-12 17:28:24 UTC

@Alex-Gardner 

After troubleshoothing this more. I think perhaps something is wrong with this particular VOXL Flight. I did get the other VOXL Flight working with the HIRES camera with the latest released 3.8.0-0.7 system image. I did a full reimage and wipe and it started working.

On the one unit that isn't working, it must be a hardware issue? Not sure what happened there. We haven't been unplugging the camera connections. I've tried reseating the connection several times without any luck. I've tried other cameras as well with no joy. Is there a process to return a VOXL Flight for evaluation/RMA?

Steve

## Reply by Guest · 2022-07-12 17:38:37 UTC

Yes,

We have a RMA process which can be found [here](https://www.modalai.com/pages/rma)
