mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-13 19:40:19 +08:00
ignore undeclare paramer exception
This commit is contained in:
@@ -27,9 +27,9 @@ namespace orbbec_camera {
|
|||||||
sensor_msgs::msg::CameraInfo convertToCameraInfo(OBCameraIntrinsic intrinsic,
|
sensor_msgs::msg::CameraInfo convertToCameraInfo(OBCameraIntrinsic intrinsic,
|
||||||
OBCameraDistortion distortion, int width);
|
OBCameraDistortion distortion, int width);
|
||||||
|
|
||||||
void saveRGBPointsToPly(std::shared_ptr<ob::Frame> frame, std::string fileName);
|
void saveRGBPointsToPly(const std::shared_ptr<ob::Frame>& frame, const std::string& fileName);
|
||||||
|
|
||||||
void savePointsToPly(std::shared_ptr<ob::Frame> frame, std::string fileName);
|
void savePointsToPly(const std::shared_ptr<ob::Frame>& frame, const std::string& fileName);
|
||||||
|
|
||||||
tf2::Quaternion rotationMatrixToQuaternion(const float rotation[9]);
|
tf2::Quaternion rotationMatrixToQuaternion(const float rotation[9]);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ Parameters::~Parameters() noexcept {
|
|||||||
try {
|
try {
|
||||||
node_->undeclare_parameter(param.first);
|
node_->undeclare_parameter(param.first);
|
||||||
} catch (const rclcpp::exceptions::InvalidParameterTypeException &e) {
|
} catch (const rclcpp::exceptions::InvalidParameterTypeException &e) {
|
||||||
|
// ignore
|
||||||
|
} catch (const std::exception &e) {
|
||||||
RCLCPP_ERROR_STREAM(logger_, e.what());
|
RCLCPP_ERROR_STREAM(logger_, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-15
@@ -55,9 +55,13 @@ sensor_msgs::msg::CameraInfo convertToCameraInfo(OBCameraIntrinsic intrinsic,
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveRGBPointsToPly(std::shared_ptr<ob::Frame> frame, std::string fileName) {
|
void saveRGBPointsToPly(const std::shared_ptr<ob::Frame> &frame, const std::string &fileName) {
|
||||||
size_t point_size = frame->dataSize() / sizeof(OBColorPoint);
|
size_t point_size = frame->dataSize() / sizeof(OBColorPoint);
|
||||||
FILE *fp = fopen(fileName.c_str(), "wb+");
|
FILE *fp = fopen(fileName.c_str(), "wb+");
|
||||||
|
std::shared_ptr<int> fp_guard(nullptr, [&fp](int *) {
|
||||||
|
fflush(fp);
|
||||||
|
fclose(fp);
|
||||||
|
});
|
||||||
fprintf(fp, "ply\n");
|
fprintf(fp, "ply\n");
|
||||||
fprintf(fp, "format ascii 1.0\n");
|
fprintf(fp, "format ascii 1.0\n");
|
||||||
fprintf(fp, "element vertex %zu\n", point_size);
|
fprintf(fp, "element vertex %zu\n", point_size);
|
||||||
@@ -69,20 +73,21 @@ void saveRGBPointsToPly(std::shared_ptr<ob::Frame> frame, std::string fileName)
|
|||||||
fprintf(fp, "property uchar blue\n");
|
fprintf(fp, "property uchar blue\n");
|
||||||
fprintf(fp, "end_header\n");
|
fprintf(fp, "end_header\n");
|
||||||
|
|
||||||
auto *point = (OBColorPoint *)frame->data();
|
const auto *points = (OBColorPoint *)frame->data();
|
||||||
|
CHECK_NOTNULL(points);
|
||||||
for (size_t i = 0; i < point_size; i++) {
|
for (size_t i = 0; i < point_size; i++) {
|
||||||
fprintf(fp, "%.3f %.3f %.3f %d %d %d\n", point->x, point->y, point->z, (int)point->r,
|
fprintf(fp, "%.3f %.3f %.3f %d %d %d\n", points[i].x, points[i].y, points[i].z,
|
||||||
(int)point->g, (int)point->b);
|
(int)points[i].r, (int)points[i].g, (int)points[i].b);
|
||||||
point++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void savePointsToPly(std::shared_ptr<ob::Frame> frame, std::string fileName) {
|
void savePointsToPly(const std::shared_ptr<ob::Frame> &frame, const std::string &fileName) {
|
||||||
size_t point_size = frame->dataSize() / sizeof(OBPoint);
|
size_t point_size = frame->dataSize() / sizeof(OBPoint);
|
||||||
FILE *fp = fopen(fileName.c_str(), "wb+");
|
FILE *fp = fopen(fileName.c_str(), "wb+");
|
||||||
|
std::shared_ptr<int> fp_guard(nullptr, [&fp](int *) {
|
||||||
|
fflush(fp);
|
||||||
|
fclose(fp);
|
||||||
|
});
|
||||||
fprintf(fp, "ply\n");
|
fprintf(fp, "ply\n");
|
||||||
fprintf(fp, "format ascii 1.0\n");
|
fprintf(fp, "format ascii 1.0\n");
|
||||||
fprintf(fp, "element vertex %zu\n", point_size);
|
fprintf(fp, "element vertex %zu\n", point_size);
|
||||||
@@ -91,14 +96,11 @@ void savePointsToPly(std::shared_ptr<ob::Frame> frame, std::string fileName) {
|
|||||||
fprintf(fp, "property float z\n");
|
fprintf(fp, "property float z\n");
|
||||||
fprintf(fp, "end_header\n");
|
fprintf(fp, "end_header\n");
|
||||||
|
|
||||||
auto *points = (OBPoint *)frame->data();
|
const auto *points = (OBPoint *)frame->data();
|
||||||
|
CHECK_NOTNULL(points);
|
||||||
for (size_t i = 0; i < point_size; i++) {
|
for (size_t i = 0; i < point_size; i++) {
|
||||||
fprintf(fp, "%.3f %.3f %.3f\n", points->x, points->y, points->z);
|
fprintf(fp, "%.3f %.3f %.3f\n", points[i].x, points[i].y, points[i].z);
|
||||||
points++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tf2::Quaternion rotationMatrixToQuaternion(const float rotation[9]) {
|
tf2::Quaternion rotationMatrixToQuaternion(const float rotation[9]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user