Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double t265 connection #4183

Closed
stino78 opened this issue Jun 11, 2019 · 12 comments
Closed

Double t265 connection #4183

stino78 opened this issue Jun 11, 2019 · 12 comments
Labels
multicam T260 series Intel® T265 library

Comments

@stino78
Copy link

stino78 commented Jun 11, 2019

I am trying to connect 2 trackers t265 on the same PC. While with the Viewer everything works just fine, I have problems in Python. I tried a couple of different possibilities, always with the same result, the second unit cannot be opened...

Here's the code:

import pyrealsense2 as rs
import numpy as np
import transformations as tf
import math as m
import time

H_aeroRef_T265Ref = np.array([[0,0,-1,0],[1,0,0,0],[0,-1,0,0],[0,0,0,1]])
H_T265body_aeroBody = np.linalg.inv(H_aeroRef_T265Ref)

### FIRST UNIT
ctx1 = rs.context()
###devices = ctx.query_devices()

print ctx1
time.sleep(1)

### Declare RealSense pipeline, encapsulating the actual device and sensors
pipe1 = rs.pipeline(ctx1)
### Build config object and request pose data
cfg1 = rs.config()
cfg1.enable_stream(rs.stream.pose)



### SECOND UNIT
ctx2 = rs.context()
###devices = ctx.query_devices()

print ctx2
time.sleep(1)
### Declare RealSense pipeline, encapsulating the actual device and sensors
pipe2 = rs.pipeline(ctx2)

### Build config object and request pose data
cfg2 = rs.config()
cfg2.enable_stream(rs.stream.pose)

### Start streaming with requested config
pipe1.start(cfg1)
pipe2.start(cfg2)

 ### Wait for the next set of frames from the camera
 frame1 = pipe1.wait_for_frames()
frame2 = pipe2.wait_for_frames()

### Fetch pose frame
pose1 = frame1.get_pose_frame()
pose2 = frame1.get_pose_frame()

### Close
pipe1.stop()
pipe2.stop()

and here's the output

<pyrealsense2.pyrealsense2.context object at 0x0000000004CE56F8>
<pyrealsense2.pyrealsense2.context object at 0x0000000004CFC228>
Traceback (most recent call last):
File "double_t265_example.py", line 40, in
pipe2.start(cfg2)
RuntimeError: No device connected

@ev-mp
Copy link
Collaborator

ev-mp commented Jun 11, 2019

@stino78 hello,
For T265 there is a limitation that requires the sensors to be mapped to the first context created in code.
To make your code run you just need to reuse the first context when opening the second device:

pipe2 = rs.pipeline(ctx2ctx1)

It seem that you can drop the second context altogether.
Note that this doesn't apply to the other Realsense devices - D400 and SR300.

See more discussions on this topic in #3892, #3734, #3434, #3437, #3892

P.S: The original snippet was re-formatted for readability

@ev-mp ev-mp added multicam T260 series Intel® T265 library labels Jun 11, 2019
@stino78
Copy link
Author

stino78 commented Jun 11, 2019

Hi ev-mp, thanks for the quick feedback!

Sadly I get a similar error...

11:04:50:536 [011440] [E] Device-0C40: State [ACTIVE_STATE] got event [ON_PLAYBACK_SET] ==> [ERROR_STATE]
11:04:50:536 [011440] [E] Device-0C40: Entered state [ERROR_STATE]
Traceback (most recent call last):
File "double_t265_example.py", line 40, in
pipe2.start(cfg2)
RuntimeError: Failed to start TM2 camera

I am looking at the other related discussion, but I could not find a solution.

Can you help me with this?

Thank you,

Agostino

@dorodnic
Copy link
Contributor

This will have to be resolved via a code fix, and not a trivial one, unfortunately. We are working on it, but it can take more time.

@karry3775
Copy link

@stino78 I am facing the exact issue right now. I was using a ros package called realsense-ros to launch multiple cameras using (rs_multiple_devices.launch) but I guess that doesn't support t265 cameras. Were you able to extract any pose information from t265 using your code. Thanks

@stino78
Copy link
Author

stino78 commented Jan 14, 2020 via email

@karry3775
Copy link

karry3775 commented Jan 14, 2020 via email

@karry3775
Copy link

@stino78 Do I need any other dependencies / files installed for this to work. Or is there a command line argument that I need to pass for connecting two devices. Currently just running the python file gives some syntax error :

File "more_devices_test.py", line 18
def get_devices_serial_numbers(device_suffix:str='T265') -> [str]:
^
SyntaxError: invalid syntax

Please let me know if you faced similar issues.

@stino78
Copy link
Author

stino78 commented Jan 15, 2020 via email

@karry3775
Copy link

@stino78 I think python version was the issue now , I was running on Python 2.7
I ran with python 3 now.
It gives the following output, Were you also getting something similar:

[DEBUG] 15:48:22.070: (MainThread) T265 (943222110577) camera is ready.
[DEBUG] 15:48:22.111: (MainThread) T265 (845412111129) camera is ready.
Serial experiment --------------------------------------------------
serial_numbers ['943222110577', '845412111129']
0 0 943222110577 (0.0, 0.0, 0.0) 2020-01-15 15:48:22.537152
1 0 943222110577 (0.0, 0.0, 0.0) 2020-01-15 15:48:22.544937
0 1 845412111129 (0.0, 0.0, 0.0) 2020-01-15 15:48:22.642573
1 1 845412111129 (0.0, 0.0, 0.0) 2020-01-15 15:48:22.651024
Parallel experiment --------------------------------------------------
0 0 943222110577 (0.00025890962569974363, -0.002097188727930188, 0.00010264413140248507) 2020-01-15 15:48:22.651212
0 1 845412111129 (0.0, 0.0, 0.0) 2020-01-15 15:48:22.652803
1 0 943222110577 (0.00034518822212703526, -0.001163087203167379, 0.0002176408306695521) 2020-01-15 15:48:22.656179
1 1 845412111129 (-5.85176576350932e-06, -0.00012395156954880804, -4.087463821633719e-06) 2020-01-15 15:48:22.657700

@stino78
Copy link
Author

stino78 commented Jan 15, 2020 via email

@karry3775
Copy link

karry3775 commented Jan 17, 2020 via email

@stino78
Copy link
Author

stino78 commented Jan 17, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multicam T260 series Intel® T265 library
Projects
None yet
Development

No branches or pull requests

5 participants