feat(file_channel): always set params with new version format
This commit is contained in:
parent
05c5c1f238
commit
a67bd6a04e
|
@ -176,32 +176,22 @@ ImgParamsParser::~ImgParamsParser() {
|
||||||
std::size_t ImgParamsParser::GetFromData(
|
std::size_t ImgParamsParser::GetFromData(
|
||||||
const std::uint8_t *data, const std::uint16_t &data_size,
|
const std::uint8_t *data, const std::uint16_t &data_size,
|
||||||
img_params_t *img_params) const {
|
img_params_t *img_params) const {
|
||||||
if (spec_version_ == Version(1, 0) || spec_version_ == Version(1, 1)) {
|
// s1030 old params
|
||||||
// get img params without version header
|
if (spec_version_ == Version(1, 0) && data_size == 250) {
|
||||||
if (spec_version_ == Version(1, 0)) {
|
return GetFromData_v1_0(data, data_size, img_params);
|
||||||
return GetFromData_v1_0(data, data_size, img_params);
|
|
||||||
} else {
|
|
||||||
return GetFromData_v1_1(data, data_size, img_params);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// get img params with version header
|
|
||||||
return GetFromData_new(data, data_size, img_params);
|
|
||||||
}
|
}
|
||||||
|
// s210a old params
|
||||||
|
if (spec_version_ == Version(1, 1) && data_size == 404) {
|
||||||
|
return GetFromData_v1_1(data, data_size, img_params);
|
||||||
|
}
|
||||||
|
// get img params with new version format
|
||||||
|
return GetFromData_new(data, data_size, img_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t ImgParamsParser::SetToData(
|
std::size_t ImgParamsParser::SetToData(
|
||||||
const img_params_t *img_params, std::uint8_t *data) const {
|
const img_params_t *img_params, std::uint8_t *data) const {
|
||||||
if (spec_version_ == Version(1, 0) || spec_version_ == Version(1, 1)) {
|
// always set img params with new version format
|
||||||
// set img params without version header
|
return SetToData_new(img_params, data);
|
||||||
if (spec_version_ == Version(1, 0)) {
|
|
||||||
return SetToData_v1_0(img_params, data);
|
|
||||||
} else {
|
|
||||||
return SetToData_v1_1(img_params, data);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// set img params with version header
|
|
||||||
return SetToData_new(img_params, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t ImgParamsParser::GetFromData_v1_0(
|
std::size_t ImgParamsParser::GetFromData_v1_0(
|
||||||
|
@ -356,14 +346,16 @@ std::size_t ImgParamsParser::SetToData_new(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Version version_new(1, 2); // new version
|
||||||
|
Version version_raw(img_params->begin()->second.version);
|
||||||
|
|
||||||
std::size_t i = 3; // skip id, size
|
std::size_t i = 3; // skip id, size
|
||||||
// version, 2
|
// version, 2
|
||||||
Version version(img_params->begin()->second.version);
|
data[i] = version_new.major();
|
||||||
data[i] = version.major();
|
data[i + 1] = version_new.minor();
|
||||||
data[i + 1] = version.minor();
|
|
||||||
i += 2;
|
i += 2;
|
||||||
// set img params according to version
|
// set img params with new version format
|
||||||
if (version == Version(1, 2)) { // v1.2
|
if (version_raw <= version_new) {
|
||||||
for (auto &&entry : *img_params) {
|
for (auto &&entry : *img_params) {
|
||||||
auto &¶ms = entry.second;
|
auto &¶ms = entry.second;
|
||||||
// calib_model, 1
|
// calib_model, 1
|
||||||
|
@ -382,7 +374,7 @@ std::size_t ImgParamsParser::SetToData_new(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG(FATAL) << "Could not set img params of version "
|
LOG(FATAL) << "Could not set img params of version "
|
||||||
<< version.to_string() << ", please use latest SDK.";
|
<< version_raw.to_string() << ", please use latest SDK.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// others
|
// others
|
||||||
|
@ -404,24 +396,22 @@ ImuParamsParser::~ImuParamsParser() {
|
||||||
std::size_t ImuParamsParser::GetFromData(
|
std::size_t ImuParamsParser::GetFromData(
|
||||||
const std::uint8_t *data, const std::uint16_t &data_size,
|
const std::uint8_t *data, const std::uint16_t &data_size,
|
||||||
imu_params_t *imu_params) const {
|
imu_params_t *imu_params) const {
|
||||||
if (spec_version_ == Version(1, 0) || spec_version_ == Version(1, 1)) {
|
// s1030 old params
|
||||||
// get imu params without version header
|
if (spec_version_ == Version(1, 0) && data_size == 384) {
|
||||||
return GetFromData_old(data, data_size, imu_params);
|
return GetFromData_old(data, data_size, imu_params);
|
||||||
} else {
|
|
||||||
// get imu params with version header
|
|
||||||
return GetFromData_new(data, data_size, imu_params);
|
|
||||||
}
|
}
|
||||||
|
// s210a old params
|
||||||
|
if (spec_version_ == Version(1, 1) && data_size == 384) {
|
||||||
|
return GetFromData_old(data, data_size, imu_params);
|
||||||
|
}
|
||||||
|
// get imu params with new version format
|
||||||
|
return GetFromData_new(data, data_size, imu_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t ImuParamsParser::SetToData(
|
std::size_t ImuParamsParser::SetToData(
|
||||||
const imu_params_t *imu_params, std::uint8_t *data) const {
|
const imu_params_t *imu_params, std::uint8_t *data) const {
|
||||||
if (spec_version_ == Version(1, 0) || spec_version_ == Version(1, 1)) {
|
// always set imu params with new version format
|
||||||
// set imu params without version header
|
return SetToData_new(imu_params, data);
|
||||||
return SetToData_old(imu_params, data);
|
|
||||||
} else {
|
|
||||||
// set imu params with version header
|
|
||||||
return SetToData_new(imu_params, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t ImuParamsParser::GetFromData_old(
|
std::size_t ImuParamsParser::GetFromData_old(
|
||||||
|
@ -473,19 +463,22 @@ std::size_t ImuParamsParser::GetFromData_new(
|
||||||
std::size_t ImuParamsParser::SetToData_new(
|
std::size_t ImuParamsParser::SetToData_new(
|
||||||
const imu_params_t *imu_params, std::uint8_t *data) const {
|
const imu_params_t *imu_params, std::uint8_t *data) const {
|
||||||
std::size_t i = 3; // skip id, size
|
std::size_t i = 3; // skip id, size
|
||||||
|
|
||||||
|
Version version_new(1, 2); // new version
|
||||||
|
Version version_raw(imu_params->version);
|
||||||
|
|
||||||
// version, 2
|
// version, 2
|
||||||
Version version(imu_params->version);
|
data[i] = version_new.major();
|
||||||
data[i] = version.major();
|
data[i + 1] = version_new.minor();
|
||||||
data[i + 1] = version.minor();
|
|
||||||
i += 2;
|
i += 2;
|
||||||
// set imu params according to version
|
// set imu params with new version format
|
||||||
if (version == Version(1, 2)) { // v1.2
|
if (version_raw <= version_new) {
|
||||||
i += bytes::to_data(&imu_params->in_accel, data + i);
|
i += bytes::to_data(&imu_params->in_accel, data + i);
|
||||||
i += bytes::to_data(&imu_params->in_gyro, data + i);
|
i += bytes::to_data(&imu_params->in_gyro, data + i);
|
||||||
i += bytes::to_data(&imu_params->ex_left_to_imu, data + i);
|
i += bytes::to_data(&imu_params->ex_left_to_imu, data + i);
|
||||||
} else {
|
} else {
|
||||||
LOG(FATAL) << "Could not set imu params of version "
|
LOG(FATAL) << "Could not set imu params of version "
|
||||||
<< version.to_string() << ", please use latest SDK.";
|
<< version_raw.to_string() << ", please use latest SDK.";
|
||||||
}
|
}
|
||||||
// others
|
// others
|
||||||
std::size_t size = i - 3;
|
std::size_t size = i - 3;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user