Skip to content

Conversation

@erblinium
Copy link
Contributor

Add parsing of calibration plates in virtual_object_handler

@benthie
Copy link
Contributor

benthie commented Sep 6, 2023

Hi @erblinium,

thanks for the contribution. Being able to also publish calibration patterns sounds like a very good idea. Right now the code does not satisfy the code checker yet. And your changes contain a few unwanted indentation changes which makes it hard to add a review via GitHub.

You could try to configure your IDE such that it automatically uses the provided .clang-format file in the repository to format your code when saving a file. By doing so you could be sure that there will be way less issues with the code checker.

Looking forward to add the review as soon as the code checker is happy.

Kind regards
Benny

Comment on lines +134 to +147
else if (type.asString() == valSingleCustom || type.asString() == valSingle) {
// Ensenso and halcon calibration type markers
marker.type = visualization_msgs::msg::Marker::CUBE;
auto grid_size_x = object[itmGridSize][0].asDouble();
auto grid_size_y = object[itmGridSize][1].asDouble();
auto grid_spacing = object[itmGridSpacing].asDouble();

auto plate_width = std::round(0.5 * grid_size_x * grid_spacing / 0.9);
auto plate_height = std::round(0.5 * grid_size_y * grid_spacing / 0.9);

marker.scale.x = plate_width / 1000.0;
marker.scale.y = plate_height / 1000.0;
marker.scale.z = 3 / 1000.0;
}
Copy link
Contributor

@benthie benthie Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we internally distinguish between Halcon and Ensenso patterns and how we calculate the actual pattern size:

Suggested change
else if (type.asString() == valSingleCustom || type.asString() == valSingle) {
// Ensenso and halcon calibration type markers
marker.type = visualization_msgs::msg::Marker::CUBE;
auto grid_size_x = object[itmGridSize][0].asDouble();
auto grid_size_y = object[itmGridSize][1].asDouble();
auto grid_spacing = object[itmGridSpacing].asDouble();
auto plate_width = std::round(0.5 * grid_size_x * grid_spacing / 0.9);
auto plate_height = std::round(0.5 * grid_size_y * grid_spacing / 0.9);
marker.scale.x = plate_width / 1000.0;
marker.scale.y = plate_height / 1000.0;
marker.scale.z = 3 / 1000.0;
}
else if (object[itmGridSpacing].exists())
{
// Halcon pattern spacing.
auto spacing = object[itmGridSpacing].asDouble();
// Ensenso pattern spacing.
if (type.exists() && type != "")
{
spacing /= 2;
}
auto width = object[itmGridSize][0].asDouble();
auto height = object[itmGridSize][1].asDouble();
auto thickness = object[itmThickness].exists() ? object[itmThickness].asDouble() : 3.;
marker.type = visualization_msgs::msg::Marker::CUBE;
marker.scale.x = (width + 1) * spacing / 1000.0;
marker.scale.y = (height + 1) * spacing / 1000.0;
marker.scale.z = thickness / 1000.0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants