librealsense: rs2::pipeline can't open T265 given the serial number
Required Info | |
---|---|
Camera Model | T265 |
Firmware Version | 0.0.18.5129 |
Operating System & Version | Ubuntu 16 |
Kernel Version (Linux Only) | 4.15.0-43-generic |
Platform | PC |
SDK Version | 2 |
Language | C++ |
Segment | others |
Issue Description
I have a T265 plugged in the laptop and followed the multicam example to open it given its serial number. Like this:
rs2::pipeline pipe;
rs2::config cfg;
cfg.enable_device(serial_number);
cfg.enable_stream(RS2_STREAM_POSE, RS2_FORMAT_6DOF);
pipe.start(cfg);
But I always get a No device connected
exception.
Full example:
#include <iostream>
#include <iomanip>
#include <string>
#include <thread>
#include <librealsense2/rs.hpp>
void print_info(rs2::device& dev);
int main() {
rs2::device dev = [] {
rs2::context ctx;
std::cout << "waiting for device..." << std::endl;
while (true) {
for (auto&& dev : ctx.query_devices())
return dev;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}();
print_info(dev);
rs2::pipeline pipe;
rs2::config cfg;
std::string serial_number = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
std::cout << "opening pipeline for " << serial_number << std::endl;
cfg.enable_device(serial_number);
cfg.enable_stream(RS2_STREAM_POSE, RS2_FORMAT_6DOF);
if (!pipe.start(cfg)) return 1;
while (true) {
auto frames = pipe.wait_for_frames();
auto f = frames.first_or_default(RS2_STREAM_POSE);
auto pose_data = f.as<rs2::pose_frame>().get_pose_data();
std::cout << "\r" << "Device Position: " << std::setprecision(3) << std::fixed << pose_data.translation.x << " "
<< pose_data.translation.y << " " << pose_data.translation.z << " (meters)";
}
}
void print_info(rs2::device& dev) {
std::cout << "device found:" << std::endl;
std::cout << dev.get_info(RS2_CAMERA_INFO_NAME) << " "
<< dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER) << " "
<< dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID) << std::endl;
auto sensors = dev.query_sensors();
for (rs2::sensor& sensor : sensors) {
std::cout << "sensor " << sensor.get_info(RS2_CAMERA_INFO_NAME) << std::endl;
for (rs2::stream_profile& profile : sensor.get_stream_profiles()) {
std::cout << " stream " << profile.stream_name() << std::endl;
}
}
}
Output:
waiting for device...
device found:
Intel RealSense T265 845412110806 0B37
sensor Tracking Module
stream Fisheye 1
stream Fisheye 2
stream Gyro
stream Accel
stream Pose
opening pipeline for 845412110806
terminate called after throwing an instance of 'rs2::error'
what(): No device connected
Aborted (core dumped)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (6 by maintainers)
@macmason, if you only have a T265 device connected to the pc, you don’t need to provide the serial number, setting the stream in
config
should be enough:If you do need to specify the serial number, try something along this line: