Improve intrinsics & extrinsics interfaces

This commit is contained in:
John Zhao 2018-04-19 22:44:40 +08:00
parent e04a05f6f9
commit f6120d5ae6
6 changed files with 210 additions and 268 deletions

View File

@ -248,9 +248,9 @@ std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
/** /**
* @ingroup calibration * @ingroup calibration
* Image intrinsics. * Stream intrinsics,
*/ */
struct MYNTEYE_API ImgIntrinsics { struct MYNTEYE_API Intrinsics {
/** width of the image in pixels */ /** width of the image in pixels */
std::uint16_t width; std::uint16_t width;
/** height of the image in pixels */ /** height of the image in pixels */
@ -269,13 +269,13 @@ struct MYNTEYE_API ImgIntrinsics {
double coeffs[5]; double coeffs[5];
}; };
std::ostream &operator<<(std::ostream &os, const ImgIntrinsics &in); std::ostream &operator<<(std::ostream &os, const Intrinsics &in);
/** /**
* @ingroup calibration * @ingroup calibration
* IMU sensor intrinsics: scale, drift and variances. * IMU intrinsics: scale, drift and variances.
*/ */
struct MYNTEYE_API ImuSensorIntrinsics { struct MYNTEYE_API ImuIntrinsics {
/** /**
* Scale X cross axis cross axis * Scale X cross axis cross axis
* cross axis Scale Y cross axis * cross axis Scale Y cross axis
@ -291,18 +291,18 @@ struct MYNTEYE_API ImuSensorIntrinsics {
double bias[3]; double bias[3];
}; };
std::ostream &operator<<(std::ostream &os, const ImuSensorIntrinsics &in); std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in);
/** /**
* @ingroup calibration * @ingroup calibration
* IMU intrinsics, including accelerometer and gyroscope. * Motion intrinsics, including accelerometer and gyroscope.
*/ */
struct MYNTEYE_API ImuIntrinsics { struct MYNTEYE_API MotionIntrinsics {
ImuSensorIntrinsics accel; ImuIntrinsics accel;
ImuSensorIntrinsics gyro; ImuIntrinsics gyro;
}; };
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in); std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in);
/** /**
* @ingroup calibration * @ingroup calibration
@ -315,26 +315,6 @@ struct MYNTEYE_API Extrinsics {
std::ostream &operator<<(std::ostream &os, const Extrinsics &ex); std::ostream &operator<<(std::ostream &os, const Extrinsics &ex);
/**
* @ingroup calibration
* Image extrinsics.
*/
struct MYNTEYE_API ImgExtrinsics {
Extrinsics left_to_right;
};
std::ostream &operator<<(std::ostream &os, const ImgExtrinsics &ex);
/**
* @ingroup calibration
* IMU extrinsics.
*/
struct MYNTEYE_API ImuExtrinsics {
Extrinsics left_to_imu;
};
std::ostream &operator<<(std::ostream &os, const ImuExtrinsics &ex);
/** /**
* @defgroup datatypes Datatypes * @defgroup datatypes Datatypes
* @brief Public data types. * @brief Public data types.

View File

@ -151,36 +151,60 @@ std::string Device::GetInfo(const Info &info) const {
} }
} }
ImgIntrinsics Device::GetImgIntrinsics() const { Intrinsics Device::GetIntrinsics(const Stream &stream) const {
return img_intrinsics_; try {
return stream_intrinsics_.at(stream);
} catch (const std::out_of_range &e) {
LOG(WARNING) << "Intrinsics of " << stream << " not found";
return {};
}
} }
ImgExtrinsics Device::GetImgExtrinsics() const { Extrinsics Device::GetExtrinsics(const Stream &from, const Stream &to) const {
return img_extrinsics_; try {
return stream_from_extrinsics_.at(from).at(to);
} catch (const std::out_of_range &e) {
LOG(WARNING) << "Extrinsics from " << from << " to " << to << " not found";
return {};
}
} }
void Device::SetImgIntrinsics(const ImgIntrinsics &in) { MotionIntrinsics Device::GetMotionIntrinsics() const {
img_intrinsics_ = std::move(in); if (motion_intrinsics_) {
return *motion_intrinsics_;
} else {
LOG(WARNING) << "Motion intrinsics not found";
return {};
}
} }
void Device::SetImgExtrinsics(const ImgExtrinsics &ex) { Extrinsics Device::GetMotionExtrinsics(const Stream &from) const {
img_extrinsics_ = std::move(ex); try {
return motion_from_extrinsics_.at(from);
} catch (const std::out_of_range &e) {
LOG(WARNING) << "Motion extrinsics from " << from << " not found";
return {};
}
} }
ImuIntrinsics Device::GetImuIntrinsics() const { void Device::SetIntrinsics(const Stream &stream, const Intrinsics &in) {
return imu_intrinsics_; stream_intrinsics_[stream] = in;
} }
ImuExtrinsics Device::GetImuExtrinsics() const { void Device::SetExtrinsics(
return imu_extrinsics_; const Stream &from, const Stream &to, const Extrinsics &ex) {
stream_from_extrinsics_[from][to] = ex;
} }
void Device::SetImuIntrinsics(const ImuIntrinsics &in) { void Device::SetMotionIntrinsics(const MotionIntrinsics &in) {
imu_intrinsics_ = std::move(in); if (motion_intrinsics_ == nullptr) {
motion_intrinsics_ = std::make_shared<MotionIntrinsics>();
}
*motion_intrinsics_ = in;
} }
void Device::SetImuExtrinsics(const ImuExtrinsics &ex) { void Device::SetMotionExtrinsics(const Stream &from, const Extrinsics &ex) {
imu_extrinsics_ = std::move(ex); motion_from_extrinsics_[from] = ex;
} }
void Device::LogOptionInfos() const { void Device::LogOptionInfos() const {
@ -426,7 +450,7 @@ void Device::ReadAllInfos() {
if (!channels_->GetFiles(device_info_.get(), &img_params, &imu_params)) { if (!channels_->GetFiles(device_info_.get(), &img_params, &imu_params)) {
LOG(FATAL) << "Read device infos failed :("; LOG(FATAL) << "Read device infos failed :(";
} }
VLOG(2) << "Device name: " << device_info_->name VLOG(2) << "Device info: {name: " << device_info_->name
<< ", serial_number: " << device_info_->serial_number << ", serial_number: " << device_info_->serial_number
<< ", firmware_version: " << ", firmware_version: "
<< device_info_->firmware_version.to_string() << device_info_->firmware_version.to_string()
@ -435,56 +459,28 @@ void Device::ReadAllInfos() {
<< ", spec_version: " << device_info_->spec_version.to_string() << ", spec_version: " << device_info_->spec_version.to_string()
<< ", lens_type: " << device_info_->lens_type.to_string() << ", lens_type: " << device_info_->lens_type.to_string()
<< ", imu_type: " << device_info_->imu_type.to_string() << ", imu_type: " << device_info_->imu_type.to_string()
<< ", nominal_baseline: " << device_info_->nominal_baseline; << ", nominal_baseline: " << device_info_->nominal_baseline << "}";
device_info_->name = uvc::get_name(*device_); device_info_->name = uvc::get_name(*device_);
if (img_params.ok) { if (img_params.ok) {
img_intrinsics_ = img_params.in; SetIntrinsics(Stream::LEFT, img_params.in_left);
img_extrinsics_ = img_params.ex; SetIntrinsics(Stream::RIGHT, img_params.in_right);
VLOG(2) << "ImgIntrinsics " << img_intrinsics_; SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params.ex_left_to_right);
VLOG(2) << "ImgExtrinsics " << img_extrinsics_; VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
VLOG(2) << "Extrinsics left to right: {"
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
} else { } else {
LOG(WARNING) << "Img intrinsics & extrinsics not exist"; LOG(WARNING) << "Intrinsics & extrinsics not exist";
} }
if (imu_params.ok) { if (imu_params.ok) {
imu_intrinsics_ = imu_params.in; SetMotionIntrinsics({imu_params.in_accel, imu_params.in_gyro});
imu_extrinsics_ = imu_params.ex; SetMotionExtrinsics(Stream::LEFT, imu_params.ex_left_to_imu);
VLOG(2) << "ImuIntrinsics " << imu_intrinsics_; VLOG(2) << "Motion intrinsics: {" << GetMotionIntrinsics() << "}";
VLOG(2) << "ImuExtrinsics " << imu_extrinsics_; VLOG(2) << "Motion extrinsics left to imu: {"
<< GetMotionExtrinsics(Stream::LEFT) << "}";
} else { } else {
LOG(WARNING) << "Imu intrinsics & extrinsics not exist"; LOG(WARNING) << "Motion intrinsics & extrinsics not exist";
}
}
void Device::WriteDeviceInfo(const DeviceInfo &device_info) {
CHECK_NOTNULL(channels_);
DeviceInfo info = device_info;
if (channels_->SetFiles(&info, nullptr, nullptr)) {
device_info_->lens_type = info.lens_type;
device_info_->imu_type = info.imu_type;
device_info_->nominal_baseline = info.nominal_baseline;
}
}
void Device::WriteImgParams(
const ImgIntrinsics &intrinsics, const ImgExtrinsics &extrinsics) {
CHECK_NOTNULL(channels_);
Channels::img_params_t img_params{false, intrinsics, extrinsics};
if (channels_->SetFiles(
nullptr, &img_params, nullptr, &device_info_->spec_version)) {
img_intrinsics_ = intrinsics;
img_extrinsics_ = extrinsics;
}
}
void Device::WriteImuParams(
const ImuIntrinsics &intrinsics, const ImuExtrinsics &extrinsics) {
CHECK_NOTNULL(channels_);
Channels::imu_params_t imu_params{false, intrinsics, extrinsics};
if (channels_->SetFiles(
nullptr, nullptr, &imu_params, &device_info_->spec_version)) {
imu_intrinsics_ = intrinsics;
imu_extrinsics_ = extrinsics;
} }
} }

View File

@ -57,15 +57,16 @@ class Device {
std::shared_ptr<DeviceInfo> GetInfo() const; std::shared_ptr<DeviceInfo> GetInfo() const;
std::string GetInfo(const Info &info) const; std::string GetInfo(const Info &info) const;
ImgIntrinsics GetImgIntrinsics() const; Intrinsics GetIntrinsics(const Stream &stream) const;
ImgExtrinsics GetImgExtrinsics() const; Extrinsics GetExtrinsics(const Stream &from, const Stream &to) const;
void SetImgIntrinsics(const ImgIntrinsics &in); MotionIntrinsics GetMotionIntrinsics() const;
void SetImgExtrinsics(const ImgExtrinsics &ex); Extrinsics GetMotionExtrinsics(const Stream &from) const;
ImuIntrinsics GetImuIntrinsics() const; void SetIntrinsics(const Stream &stream, const Intrinsics &in);
ImuExtrinsics GetImuExtrinsics() const; void SetExtrinsics(
void SetImuIntrinsics(const ImuIntrinsics &in); const Stream &from, const Stream &to, const Extrinsics &ex);
void SetImuExtrinsics(const ImuExtrinsics &ex); void SetMotionIntrinsics(const MotionIntrinsics &in);
void SetMotionExtrinsics(const Stream &from, const Extrinsics &ex);
void LogOptionInfos() const; void LogOptionInfos() const;
OptionInfo GetOptionInfo(const Option &option) const; OptionInfo GetOptionInfo(const Option &option) const;
@ -120,10 +121,11 @@ class Device {
std::shared_ptr<uvc::device> device_; std::shared_ptr<uvc::device> device_;
std::shared_ptr<DeviceInfo> device_info_; std::shared_ptr<DeviceInfo> device_info_;
ImgIntrinsics img_intrinsics_; std::map<Stream, Intrinsics> stream_intrinsics_;
ImgExtrinsics img_extrinsics_; std::map<Stream, std::map<Stream, Extrinsics>> stream_from_extrinsics_;
ImuIntrinsics imu_intrinsics_;
ImuExtrinsics imu_extrinsics_; std::shared_ptr<MotionIntrinsics> motion_intrinsics_;
std::map<Stream, Extrinsics> motion_from_extrinsics_;
stream_callbacks_t stream_callbacks_; stream_callbacks_t stream_callbacks_;
motion_callback_t motion_callback_; motion_callback_t motion_callback_;
@ -140,11 +142,9 @@ class Device {
void ReadAllInfos(); void ReadAllInfos();
void WriteDeviceInfo(const DeviceInfo &device_info); std::shared_ptr<Channels> channels() {
void WriteImgParams( return channels_;
const ImgIntrinsics &intrinsics, const ImgExtrinsics &extrinsics); }
void WriteImuParams(
const ImuIntrinsics &intrinsics, const ImuExtrinsics &extrinsics);
// friend DeviceWriter; // friend DeviceWriter;
}; };

View File

@ -386,49 +386,64 @@ std::size_t from_data(Channels::device_info_t *info, const std::uint8_t *data) {
} }
std::size_t from_data( std::size_t from_data(
Channels::img_params_t *img_params, const std::uint8_t *data, Intrinsics *in, const std::uint8_t *data, const Version *spec_version) {
const Version *spec_version) {
std::size_t i = 0; std::size_t i = 0;
auto &&in = img_params->in;
// width, 2 // width, 2
in.width = _from_data<std::uint16_t>(data + i); in->width = _from_data<std::uint16_t>(data + i);
i += 2; i += 2;
// height, 2 // height, 2
in.height = _from_data<std::uint16_t>(data + i); in->height = _from_data<std::uint16_t>(data + i);
i += 2; i += 2;
// fx, 8 // fx, 8
in.fx = _from_data<double>(data + i); in->fx = _from_data<double>(data + i);
i += 8; i += 8;
// fy, 8 // fy, 8
in.fy = _from_data<double>(data + i); in->fy = _from_data<double>(data + i);
i += 8; i += 8;
// cx, 8 // cx, 8
in.cx = _from_data<double>(data + i); in->cx = _from_data<double>(data + i);
i += 8; i += 8;
// cy, 8 // cy, 8
in.cy = _from_data<double>(data + i); in->cy = _from_data<double>(data + i);
i += 8; i += 8;
// model, 1 // model, 1
in.model = data[i]; in->model = data[i];
i += 1; i += 1;
// coeffs, 40 // coeffs, 40
for (std::size_t j = 0; j < 5; j++) { for (std::size_t j = 0; j < 5; j++) {
in.coeffs[j] = _from_data<double>(data + i + j * 8); in->coeffs[j] = _from_data<double>(data + i + j * 8);
} }
i += 40; i += 40;
auto &&ex = img_params->ex.left_to_right; UNUSED(spec_version)
// rotation return i;
}
std::size_t from_data(
ImuIntrinsics *in, const std::uint8_t *data, const Version *spec_version) {
std::size_t i = 0;
// scale
for (std::size_t j = 0; j < 3; j++) { for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) { for (std::size_t k = 0; k < 3; k++) {
ex.rotation[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8); in->scale[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
} }
} }
i += 72; i += 72;
// translation // drift
for (std::size_t j = 0; j < 3; j++) { for (std::size_t j = 0; j < 3; j++) {
ex.translation[j] = _from_data<double>(data + i + j * 8); in->drift[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// noise
for (std::size_t j = 0; j < 3; j++) {
in->noise[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// bias
for (std::size_t j = 0; j < 3; j++) {
in->bias[j] = _from_data<double>(data + i + j * 8);
} }
i += 24; i += 24;
@ -437,67 +452,19 @@ std::size_t from_data(
} }
std::size_t from_data( std::size_t from_data(
Channels::imu_params_t *imu_params, const std::uint8_t *data, Extrinsics *ex, const std::uint8_t *data, const Version *spec_version) {
const Version *spec_version) {
std::size_t i = 0; std::size_t i = 0;
auto &&in = imu_params->in;
// acc_scale
for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) {
in.accel.scale[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
}
}
i += 72;
// gyro_scale
for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) {
in.gyro.scale[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
}
}
i += 72;
// acc_drift
for (std::size_t j = 0; j < 3; j++) {
in.accel.drift[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// gyro_drift
for (std::size_t j = 0; j < 3; j++) {
in.gyro.drift[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// acc_noise
for (std::size_t j = 0; j < 3; j++) {
in.accel.noise[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// gyro_noise
for (std::size_t j = 0; j < 3; j++) {
in.gyro.noise[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// acc_bias
for (std::size_t j = 0; j < 3; j++) {
in.accel.bias[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
// gyro_bias
for (std::size_t j = 0; j < 3; j++) {
in.gyro.bias[j] = _from_data<double>(data + i + j * 8);
}
i += 24;
auto &&ex = imu_params->ex.left_to_imu;
// rotation // rotation
for (std::size_t j = 0; j < 3; j++) { for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) { for (std::size_t k = 0; k < 3; k++) {
ex.rotation[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8); ex->rotation[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
} }
} }
i += 72; i += 72;
// translation // translation
for (std::size_t j = 0; j < 3; j++) { for (std::size_t j = 0; j < 3; j++) {
ex.translation[j] = _from_data<double>(data + i + j * 8); ex->translation[j] = _from_data<double>(data + i + j * 8);
} }
i += 24; i += 24;
@ -505,6 +472,26 @@ std::size_t from_data(
return i; return i;
} }
std::size_t from_data(
Channels::img_params_t *img_params, const std::uint8_t *data,
const Version *spec_version) {
std::size_t i = 0;
i += from_data(&img_params->in_left, data + i, spec_version);
i += from_data(&img_params->in_right, data + i, spec_version);
i += from_data(&img_params->ex_left_to_right, data + i, spec_version);
return i;
}
std::size_t from_data(
Channels::imu_params_t *imu_params, const std::uint8_t *data,
const Version *spec_version) {
std::size_t i = 0;
i += from_data(&imu_params->in_accel, data + i, spec_version);
i += from_data(&imu_params->in_gyro, data + i, spec_version);
i += from_data(&imu_params->ex_left_to_imu, data + i, spec_version);
return i;
}
} // namespace } // namespace
bool Channels::GetFiles( bool Channels::GetFiles(
@ -669,54 +656,99 @@ std::size_t to_data(
} }
std::size_t to_data( std::size_t to_data(
const Channels::img_params_t *img_params, std::uint8_t *data, const Intrinsics *in, std::uint8_t *data, const Version *spec_version) {
const Version *spec_version) { std::size_t i = 0;
std::size_t i = 3; // skip id, size
auto &&in = img_params->in;
// width, 2 // width, 2
_to_data(in.width, data + i); _to_data(in->width, data + i);
i += 2; i += 2;
// height, 2 // height, 2
_to_data(in.height, data + i); _to_data(in->height, data + i);
i += 2; i += 2;
// fx, 8 // fx, 8
_to_data(in.fx, data + i); _to_data(in->fx, data + i);
i += 8; i += 8;
// fy, 8 // fy, 8
_to_data(in.fy, data + i); _to_data(in->fy, data + i);
i += 8; i += 8;
// cx, 8 // cx, 8
_to_data(in.cx, data + i); _to_data(in->cx, data + i);
i += 8; i += 8;
// cy, 8 // cy, 8
_to_data(in.cy, data + i); _to_data(in->cy, data + i);
i += 8; i += 8;
// model, 1 // model, 1
data[i] = in.model; data[i] = in->model;
i += 1; i += 1;
// coeffs, 40 // coeffs, 40
for (std::size_t j = 0; j < 5; j++) { for (std::size_t j = 0; j < 5; j++) {
_to_data(in.coeffs[j], data + i + j * 8); _to_data(in->coeffs[j], data + i + j * 8);
} }
i += 40; i += 40;
auto &&ex = img_params->ex.left_to_right; UNUSED(spec_version)
return i;
}
std::size_t to_data(
const ImuIntrinsics *in, std::uint8_t *data, const Version *spec_version) {
std::size_t i = 0;
// scale
for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) {
_to_data(in->scale[j][k], data + i + (j * 3 + k) * 8);
}
}
i += 72;
// drift
for (std::size_t j = 0; j < 3; j++) {
_to_data(in->drift[j], data + i + j * 8);
}
i += 24;
// noise
for (std::size_t j = 0; j < 3; j++) {
_to_data(in->noise[j], data + i + j * 8);
}
i += 24;
// bias
for (std::size_t j = 0; j < 3; j++) {
_to_data(in->bias[j], data + i + j * 8);
}
i += 24;
UNUSED(spec_version)
return i;
}
std::size_t to_data(
const Extrinsics *ex, std::uint8_t *data, const Version *spec_version) {
std::size_t i = 0;
// rotation // rotation
for (std::size_t j = 0; j < 3; j++) { for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) { for (std::size_t k = 0; k < 3; k++) {
_to_data(ex.rotation[j][k], data + i + (j * 3 + k) * 8); _to_data(ex->rotation[j][k], data + i + (j * 3 + k) * 8);
} }
} }
i += 72; i += 72;
// translation // translation
for (std::size_t j = 0; j < 3; j++) { for (std::size_t j = 0; j < 3; j++) {
_to_data(ex.translation[j], data + i + j * 8); _to_data(ex->translation[j], data + i + j * 8);
} }
i += 24; i += 24;
UNUSED(spec_version) UNUSED(spec_version)
return i;
}
std::size_t to_data(
const Channels::img_params_t *img_params, std::uint8_t *data,
const Version *spec_version) {
std::size_t i = 3; // skip id, size
i += to_data(&img_params->in_left, data + i, spec_version);
i += to_data(&img_params->in_right, data + i, spec_version);
i += to_data(&img_params->ex_left_to_right, data + i, spec_version);
// others // others
std::size_t size = i - 3; std::size_t size = i - 3;
data[0] = Channels::FID_IMG_PARAMS; data[0] = Channels::FID_IMG_PARAMS;
@ -729,69 +761,9 @@ std::size_t to_data(
const Channels::imu_params_t *imu_params, std::uint8_t *data, const Channels::imu_params_t *imu_params, std::uint8_t *data,
const Version *spec_version) { const Version *spec_version) {
std::size_t i = 3; // skip id, size std::size_t i = 3; // skip id, size
i += to_data(&imu_params->in_accel, data + i, spec_version);
auto &&in = imu_params->in; i += to_data(&imu_params->in_gyro, data + i, spec_version);
// acc_scale i += to_data(&imu_params->ex_left_to_imu, data + i, spec_version);
for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) {
_to_data(in.accel.scale[j][k], data + i + (j * 3 + k) * 8);
}
}
i += 72;
// gyro_scale
for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) {
_to_data(in.gyro.scale[j][k], data + i + (j * 3 + k) * 8);
}
}
i += 72;
// acc_drift
for (std::size_t j = 0; j < 3; j++) {
_to_data(in.accel.drift[j], data + i + j * 8);
}
i += 24;
// gyro_drift
for (std::size_t j = 0; j < 3; j++) {
_to_data(in.gyro.drift[j], data + i + j * 8);
}
i += 24;
// acc_noise
for (std::size_t j = 0; j < 3; j++) {
_to_data(in.accel.noise[j], data + i + j * 8);
}
i += 24;
// gyro_noise
for (std::size_t j = 0; j < 3; j++) {
_to_data(in.gyro.noise[j], data + i + j * 8);
}
i += 24;
// acc_bias
for (std::size_t j = 0; j < 3; j++) {
_to_data(in.accel.bias[j], data + i + j * 8);
}
i += 24;
// gyro_bias
for (std::size_t j = 0; j < 3; j++) {
_to_data(in.gyro.bias[j], data + i + j * 8);
}
i += 24;
auto &&ex = imu_params->ex.left_to_imu;
// rotation
for (std::size_t j = 0; j < 3; j++) {
for (std::size_t k = 0; k < 3; k++) {
_to_data(ex.rotation[j][k], data + i + (j * 3 + k) * 8);
}
}
i += 72;
// translation
for (std::size_t j = 0; j < 3; j++) {
_to_data(ex.translation[j], data + i + j * 8);
}
i += 24;
UNUSED(spec_version)
// others // others
std::size_t size = i - 3; std::size_t size = i - 3;
data[0] = Channels::FID_IMU_PARAMS; data[0] = Channels::FID_IMU_PARAMS;

View File

@ -57,14 +57,16 @@ class Channels {
typedef struct ImgParams { typedef struct ImgParams {
bool ok; bool ok;
ImgIntrinsics in; Intrinsics in_left;
ImgExtrinsics ex; Intrinsics in_right;
Extrinsics ex_left_to_right;
} img_params_t; } img_params_t;
typedef struct ImuParams { typedef struct ImuParams {
bool ok; bool ok;
ImuIntrinsics in; ImuIntrinsics in_accel;
ImuExtrinsics ex; ImuIntrinsics in_gyro;
Extrinsics ex_left_to_imu;
} imu_params_t; } imu_params_t;
explicit Channels(std::shared_ptr<uvc::device> device); explicit Channels(std::shared_ptr<uvc::device> device);

View File

@ -145,7 +145,7 @@ std::ostream &operator<<(std::ostream &os, const StreamRequest &request) {
<< ", format: " << request.format << ", fps: " << request.fps; << ", format: " << request.format << ", fps: " << request.fps;
} }
std::ostream &operator<<(std::ostream &os, const ImgIntrinsics &in) { std::ostream &operator<<(std::ostream &os, const Intrinsics &in) {
os << "width: " << in.width << ", height: " << in.height << ", fx: " << in.fx os << "width: " << in.width << ", height: " << in.height << ", fx: " << in.fx
<< ", fy: " << in.fy << ", cx: " << in.cx << ", cy: " << in.cy << ", fy: " << in.fy << ", cx: " << in.cx << ", cy: " << in.cy
<< ", model: " << static_cast<int>(in.model) << ", coeffs: ["; << ", model: " << static_cast<int>(in.model) << ", coeffs: [";
@ -154,7 +154,7 @@ std::ostream &operator<<(std::ostream &os, const ImgIntrinsics &in) {
return os << in.coeffs[4] << "]"; return os << in.coeffs[4] << "]";
} }
std::ostream &operator<<(std::ostream &os, const ImuSensorIntrinsics &in) { std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in) {
os << "scale: ["; os << "scale: [";
for (int i = 0; i <= 2; i++) for (int i = 0; i <= 2; i++)
os << in.scale[0][i] << ", "; os << in.scale[0][i] << ", ";
@ -182,7 +182,7 @@ std::ostream &operator<<(std::ostream &os, const ImuSensorIntrinsics &in) {
return os; return os;
} }
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in) { std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in) {
return os << "accel: {" << in.accel << "}, gyro: {" << in.gyro << "}"; return os << "accel: {" << in.accel << "}, gyro: {" << in.gyro << "}";
} }
@ -204,12 +204,4 @@ std::ostream &operator<<(std::ostream &os, const Extrinsics &ex) {
return os; return os;
} }
std::ostream &operator<<(std::ostream &os, const ImgExtrinsics &ex) {
return os << "left_to_right: {" << ex.left_to_right << "}";
}
std::ostream &operator<<(std::ostream &os, const ImuExtrinsics &ex) {
return os << "left_to_imu: {" << ex.left_to_imu << "}";
}
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE