10 #include <diagnostic_msgs/DiagnosticArray.h> 16 std::string cameraFrame, std::string targetFrame, std::string robotFrame,
17 std::string wristFrame, std::string linkFrame,
int captureTimeout,
18 std::unique_ptr<ensenso_camera::VirtualObjectHandler> virtualObjectHandler)
19 :
Camera(nh,
std::move(serial),
std::move(fileCameraPath), fixed,
std::move(cameraFrame),
std::move(targetFrame),
21 , robotFrame(
std::move(robotFrame))
22 , wristFrame(
std::move(wristFrame))
23 , captureTimeout(captureTimeout)
24 , virtualObjectHandler(
std::move(virtualObjectHandler))
91 NxLibCommand fitPrimitives(cmdFitPrimitive,
serial);
92 NxLibItem
const& primitives = fitPrimitives.parameters()[itmPrimitive];
94 int primitivesCount = 0;
95 for (
auto const& primitive : goal->primitives)
97 if (primitive.type == ensenso_camera_msgs::Primitive::SPHERE)
101 primitives[primitivesCount][itmCount] = primitive.count;
103 else if (primitive.type == ensenso_camera_msgs::Primitive::CYLINDER)
108 else if (primitive.type == ensenso_camera_msgs::Primitive::PLANE)
110 primitives[primitivesCount][itmCount] = primitive.count;
112 primitives[primitivesCount][itmType] = primitive.type;
114 primitives[primitivesCount][itmInlierFraction] = primitive.inlier_fraction_in;
119 NxLibItem
const& commandParameters = fitPrimitives.parameters();
120 if (goal->normal_radius)
122 commandParameters[itmNormal][itmRadius] = goal->normal_radius;
125 float const zeroThreshold = 10e-6;
126 if (!(std::abs(goal->region_of_interest.lower.x) < zeroThreshold &&
127 std::abs(goal->region_of_interest.lower.y) < zeroThreshold &&
128 std::abs(goal->region_of_interest.lower.z) < zeroThreshold))
132 if (!(std::abs(goal->region_of_interest.upper.x) < zeroThreshold &&
133 std::abs(goal->region_of_interest.upper.y) < zeroThreshold &&
134 std::abs(goal->region_of_interest.upper.z) < zeroThreshold))
139 if (goal->failure_probability != 0)
141 commandParameters[itmFailureProbability] = goal->failure_probability;
144 if (std::abs(goal->inlier_threshold) > zeroThreshold)
148 if (std::abs(goal->inlier_fraction) > zeroThreshold)
150 commandParameters[itmInlierFraction] = goal->inlier_fraction;
152 if (std::abs(goal->scaling) > zeroThreshold)
154 commandParameters[itmScaling] = goal->scaling;
156 if (goal->ransac_iterations != 0)
158 commandParameters[itmIterations] = goal->ransac_iterations;
161 fitPrimitives.execute();
163 ensenso_camera_msgs::FitPrimitiveResult result;
165 NxLibItem
const primitiveResults = fitPrimitives.result()[itmPrimitive];
166 if (primitiveResults.isArray())
168 result.primitives.reserve(primitiveResults.count());
169 for (
int primitiveCount = 0; primitiveCount < primitiveResults.count(); primitiveCount++)
171 NxLibItem
const& currentPrimitive = primitiveResults[primitiveCount];
172 ensenso_camera_msgs::Primitive primitive;
174 primitive.type = currentPrimitive[itmType].asString();
175 primitive.ransac_iterations = currentPrimitive[itmIterations].asInt();
176 primitive.inlier_count = currentPrimitive[itmInlierCount].asInt();
177 primitive.inlier_fraction_out = currentPrimitive[itmInlierFraction].asDouble();
178 primitive.score = currentPrimitive[itmScore].asDouble();
181 if (primitive.type == ensenso_camera_msgs::Primitive::PLANE)
187 else if (primitive.type == ensenso_camera_msgs::Primitive::SPHERE)
191 else if (primitive.type == ensenso_camera_msgs::Primitive::CYLINDER)
195 result.primitives.emplace_back(primitive);
208 ensenso_camera_msgs::RequestDataResult result;
209 ensenso_camera_msgs::RequestDataFeedback feedback;
211 bool publishResults = goal->publish_results;
212 if (!goal->publish_results && !goal->include_results_in_response)
214 publishResults =
true;
217 bool requestPointCloud = goal->request_point_cloud || goal->request_depth_image;
218 if (!goal->request_raw_images && !goal->request_rectified_images && !goal->request_point_cloud &&
219 !goal->request_normals && !goal->request_depth_image)
221 requestPointCloud =
true;
224 bool computePointCloud = requestPointCloud || goal->request_normals;
225 bool computeDisparityMap = goal->request_disparity_map || computePointCloud;
232 feedback.images_acquired =
true;
235 if (goal->request_raw_images)
244 if (goal->include_results_in_response)
246 for (
auto const& imagePair : rawImages)
248 result.left_raw_images.push_back(*imagePair.first);
249 result.right_raw_images.push_back(*imagePair.second);
267 if (goal->request_rectified_images && !computeDisparityMap)
269 NxLibCommand rectify(cmdRectifyImages,
serial);
270 rectify.parameters()[itmCameras] =
serial;
273 else if (computeDisparityMap)
275 NxLibCommand disparityMapCommand(cmdComputeDisparityMap,
serial);
276 disparityMapCommand.parameters()[itmCameras] =
serial;
277 disparityMapCommand.execute();
280 if (goal->request_rectified_images)
289 if (goal->include_results_in_response)
291 for (
auto const& imagePair : rectifiedImages)
293 result.left_rectified_images.push_back(*imagePair.first);
294 result.right_rectified_images.push_back(*imagePair.second);
308 if (goal->request_disparity_map)
312 if (goal->include_results_in_response)
314 result.disparity_map = *disparityMap;
330 if (computePointCloud)
334 NxLibCommand computePointMap(cmdComputePointMap,
serial);
335 computePointMap.parameters()[itmCameras] =
serial;
336 computePointMap.execute();
338 if (requestPointCloud && !goal->request_normals)
342 if (goal->include_results_in_response)
352 if (goal->request_depth_image)
359 if (goal->include_results_in_response)
361 result.depth_image = *depthImage;
371 ROS_WARN_ONCE(
"Currently it is not possible to determine the depth map once the stereo camera is extrinsically " 372 "calibrated because the point cloud is then transformed internally. If you want to have a depth " 373 "map, the camera must not be extrinsically calibrated (workspace-/ hand-eye calibration), or " 374 "have a link to another camera.");
381 if (goal->request_normals)
383 NxLibCommand computeNormals(cmdComputeNormals,
serial);
384 computeNormals.execute();
389 if (goal->include_results_in_response)
408 ensenso_camera_msgs::SetParameterResult result;
412 result.parameter_file_applied =
false;
413 if (!goal->parameter_file.empty())
415 result.parameter_file_applied =
loadSettings(goal->parameter_file);
416 if (!result.parameter_file_applied)
418 server->setAborted(result);
423 bool projectorChanged =
false;
424 for (
auto const& parameter : goal->parameters)
428 if (parameter.key == parameter.PROJECTOR || parameter.key == parameter.FRONT_LIGHT)
430 projectorChanged =
true;
435 NxLibCommand synchronize(cmdSynchronize,
serial);
436 synchronize.parameters()[itmCameras] =
serial;
437 synchronize.execute();
445 for (
auto const& parameter : goal->parameters)
459 ensenso_camera_msgs::LocatePatternResult result;
460 ensenso_camera_msgs::LocatePatternFeedback feedback;
464 int numberOfShots = goal->number_of_shots;
465 if (numberOfShots < 1)
470 std::vector<StereoCalibrationPattern> patterns;
472 for (
int i = 0; i < numberOfShots; i++)
478 imageTimestamp = timestamp;
482 if (i == (numberOfShots - 1))
485 feedback.images_acquired =
true;
489 bool clearBuffer = (i == 0);
491 if (patterns.empty())
493 result.found_pattern =
false;
498 if (patterns.size() > 1)
506 result.found_pattern =
true;
507 result.patterns.resize(patterns.size());
508 for (
size_t i = 0; i < patterns.size(); i++)
510 patterns[i].writeToMessage(result.patterns[i]);
516 if (!goal->target_frame.empty())
518 patternFrame = goal->target_frame;
521 result.frame = patternFrame;
523 if (patterns.size() > 1)
528 result.pattern_poses.resize(patternPoses.size());
529 for (
size_t i = 0; i < patternPoses.size(); i++)
540 result.pattern_poses.resize(1);
544 if (!goal->tf_frame.empty())
546 if (patterns.size() == 1)
553 ROS_WARN(
"Cannot publish the pattern pose in TF, because there are " 554 "multiple patterns!");
569 ensenso_camera_msgs::ProjectPatternResult result;
572 if (
isValid(targetFrameTransformation))
587 NxLibItem()[itmParameters][itmPattern][itmGridSpacing] = goal->grid_spacing * 1000;
592 NxLibCommand projectPattern(cmdProjectPattern,
serial);
593 projectPattern.parameters()[itmCameras] =
serial;
594 projectPattern.parameters()[itmGridSpacing] = goal->grid_spacing * 1000;
595 projectPattern.parameters()[itmGridSize][0] = goal->grid_size_x;
596 projectPattern.parameters()[itmGridSize][1] = goal->grid_size_y;
598 projectPattern.execute();
602 int sensorWidth =
cameraNode[itmSensor][itmSize][0].asInt();
603 int sensorHeight =
cameraNode[itmSensor][itmSize][1].asInt();
605 NxLibItem projectedPoints = projectPattern.result()[itmStereo][0][itmPoints];
606 NxLibItem leftPoints = projectedPoints[0];
607 NxLibItem rightPoints = projectedPoints[1];
609 result.pattern_is_visible =
true;
610 result.left_points.resize(leftPoints.count());
611 result.right_points.resize(leftPoints.count());
612 for (
int i = 0; i < leftPoints.count(); i++)
614 double leftX = leftPoints[i][0].asDouble();
615 double leftY = leftPoints[i][1].asDouble();
616 double rightX = rightPoints[i][0].asDouble();
617 double rightY = rightPoints[i][1].asDouble();
619 result.left_points[i].x = leftX;
620 result.left_points[i].y = leftY;
621 result.right_points[i].x = rightX;
622 result.right_points[i].y = rightY;
624 if (leftX < 0 || leftX > sensorWidth || leftY < 0 || leftY > sensorHeight || rightX < 0 || rightX > sensorWidth ||
625 rightY < 0 || rightY > sensorHeight)
627 result.pattern_is_visible =
false;
640 ensenso_camera_msgs::CalibrateHandEyeResult result;
641 result.command = goal->command;
643 if (goal->command == goal->RESET)
648 else if (goal->command == goal->CAPTURE_PATTERN)
652 result.error_message =
"You need to specify a robot base and wrist frame " 653 "to do a hand eye calibration!";
654 ROS_ERROR(
"%s", result.error_message.c_str());
668 NxLibCommand setPatternBuffer(cmdSetPatternBuffer,
serial);
670 setPatternBuffer.execute();
674 NxLibCommand(cmdDiscardPatterns,
serial).execute();
677 std::vector<StereoCalibrationPattern> patterns =
collectPattern();
678 if (patterns.empty())
680 result.found_pattern =
false;
684 if (patterns.size() > 1)
686 result.error_message =
"Detected multiple calibration patterns during a " 687 "hand eye calibration!";
688 ROS_ERROR(
"%s", result.error_message.c_str());
695 result.found_pattern =
true;
696 patterns[0].writeToMessage(result.pattern);
703 geometry_msgs::TransformStamped robotPose;
710 result.error_message = std::string(
"Could not look up the robot pose due to the TF error: ") + e.what();
711 ROS_ERROR(
"%s", result.error_message.c_str());
717 NxLibCommand getPatternBuffer(cmdGetPatternBuffer,
serial);
718 getPatternBuffer.execute();
725 else if (goal->command == goal->START_CALIBRATION)
729 result.error_message =
"You need collect at least 5 patterns before " 730 "starting a hand eye calibration!";
731 ROS_ERROR(
"%s", result.error_message.c_str());
737 size_t numberOfPatterns = 0;
738 NxLibCommand setPatternBuffer(cmdSetPatternBuffer,
serial);
739 if (!goal->pattern_observations.empty())
741 for (
size_t i = 0; i < goal->pattern_observations.size(); i++)
745 NxLibItem patternNode = setPatternBuffer.parameters()[itmPatterns][i][
serial];
754 numberOfPatterns = setPatternBuffer.parameters()[itmPatterns].count();
755 setPatternBuffer.execute();
759 if (!goal->robot_poses.empty())
762 for (
auto const& pose : goal->robot_poses)
765 robotPoses.push_back(tfPose);
769 if (robotPoses.size() != numberOfPatterns)
771 result.error_message =
"The number of pattern observations does not " 772 "match the number of robot poses!";
773 ROS_ERROR(
"%s", result.error_message.c_str());
781 patternPose =
fromMsg(goal->pattern_pose);
783 NxLibCommand calibrateHandEye(cmdCalibrateHandEye,
serial);
784 calibrateHandEye.parameters()[itmSetup] =
fixed ? valFixed : valMoving;
793 writePoseToNxLib(patternPose, calibrateHandEye.parameters()[itmPatternPose]);
795 for (
size_t i = 0; i < robotPoses.size(); i++)
797 writePoseToNxLib(robotPoses[i], calibrateHandEye.parameters()[itmTransformations][i]);
800 calibrateHandEye.execute(
false);
802 auto getCalibrationResidual = [](NxLibItem
const& node) {
803 if (node[itmResidual].
exists())
805 return node[itmResidual].asDouble();
808 return node[itmReprojectionError].asDouble();
812 while (!calibrateHandEye.finished())
814 if (calibrateHandEye.result()[itmProgress].exists())
816 ensenso_camera_msgs::CalibrateHandEyeFeedback feedback;
817 feedback.number_of_iterations = calibrateHandEye.result()[itmProgress][itmIterations].asInt();
818 feedback.residual = getCalibrationResidual(calibrateHandEye.result()[itmProgress]);
824 NxLibCommand(cmdBreak, serial).execute();
833 result.calibration_time =
834 calibrateHandEye.result()[itmTime].asDouble() / 1000;
836 result.number_of_iterations = calibrateHandEye.result()[itmIterations].asInt();
837 result.residual = getCalibrationResidual(calibrateHandEye.result());
842 if (goal->write_calibration_to_eeprom)
845 NxLibCommand storeCalibration(cmdStoreCalibration, serial);
846 storeCalibration.parameters()[itmCameras] =
serial;
847 storeCalibration.parameters()[itmLink] =
true;
848 storeCalibration.execute();
865 ROS_WARN(
"You are performing a workspace calibration for a moving camera. " 866 "Are you sure that this is what you want to do?");
869 ensenso_camera_msgs::CalibrateWorkspaceResult result;
870 result.successful =
true;
874 int numberOfShots = goal->number_of_shots;
875 if (numberOfShots < 1)
881 for (
int i = 0; i < numberOfShots; i++)
887 imageTimestamp = timestamp;
891 bool clearBuffer = (i == 0);
892 std::vector<StereoCalibrationPattern> patterns =
collectPattern(clearBuffer);
893 if (patterns.size() != 1)
895 result.successful =
false;
909 NxLibCommand calibrateWorkspace(cmdCalibrateWorkspace,
serial);
910 calibrateWorkspace.parameters()[itmCameras] =
serial;
911 writePoseToNxLib(patternTransformation, calibrateWorkspace.parameters()[itmPatternPose]);
912 writePoseToNxLib(definedPatternPose, calibrateWorkspace.parameters()[itmDefinedPose]);
914 calibrateWorkspace.execute();
916 if (goal->write_calibration_to_eeprom)
919 NxLibCommand storeCalibration(cmdStoreCalibration, serial);
920 storeCalibration.parameters()[itmCameras] =
serial;
921 storeCalibration.parameters()[itmLink] =
true;
922 storeCalibration.execute();
935 ensenso_camera_msgs::TelecentricProjectionResult result;
937 bool useViewPose =
isValid(goal->view_pose);
938 bool frameGiven = !goal->frame.empty();
942 std::string error =
"You have to define a valid frame, to which to projection will be published. Aborting";
944 result.error.message = error;
950 std::string publishingFrame = useViewPose ?
targetFrame : goal->frame;
954 transform =
fromMsg(goal->view_pose);
961 int pixelScale = goal->pixel_scale != 0. ? goal->pixel_scale : 1;
962 double scaling = goal->scaling != 0. ? goal->scaling : 1.0;
963 int sizeWidth = goal->size_width != 0 ? goal->size_width : 1024;
964 int sizeHeight = goal->size_height != 0. ? goal->size_height : 768;
965 bool useOpenGL = goal->use_opengl == 1;
968 NxLibCommand renderPointMap(cmdRenderPointMap,
serial);
970 for (
int i = 0; i < static_cast<int>(goal->serials.size()); i++)
972 renderPointMap.parameters()[itmCameras][i] = goal->serials[i];
976 renderPointMap.execute();
980 if (!resultPath.exists())
982 std::string error =
"Rendered Point Map does not exist in path: " + resultPath.path;
983 result.error.message = error;
989 if (goal->publish_results || goal->include_results_in_response)
991 if (goal->request_point_cloud || (!goal->request_point_cloud && !goal->request_depth_image))
995 if (goal->publish_results)
999 if (goal->include_results_in_response)
1010 if (goal->request_depth_image)
1014 if (goal->publish_results)
1018 if (goal->include_results_in_response)
1020 result.projected_depth_map = *renderedImage;
1041 ensenso_camera_msgs::TexturedPointCloudResult result;
1043 if (goal->mono_serial.empty())
1045 std::string error =
"In Order to use this action, you have to specify one mono serial";
1047 result.error.message = error;
1052 double farPlane = goal->far_plane ? goal->far_plane : 10000.;
1053 double nearPlane = goal->near_plane ? goal->near_plane : -10000.;
1054 bool useOpenGL = goal->use_opengl == 1;
1055 bool withTexture =
true;
1059 NxLibCommand renderPointMap(cmdRenderPointMap,
serial);
1060 for (
int i = 0; i < static_cast<int>(goal->serials.size()); i++)
1062 renderPointMap.parameters()[itmCameras][i] = goal->serials[i];
1064 renderPointMap.parameters()[itmCamera] = goal->mono_serial;
1067 renderPointMap.execute();
1069 if (goal->publish_results || goal->include_results_in_response)
1072 if (goal->publish_results)
1076 if (goal->include_results_in_response)
1104 if (projectorWasSet)
1114 bool changedParameters =
false;
1123 cameraNode[itmParameters][itmCapture][itmProjector] =
true;
1124 cameraNode[itmParameters][itmCapture][itmFrontLight] =
false;
1128 cameraNode[itmParameters][itmCapture][itmProjector] =
false;
1129 cameraNode[itmParameters][itmCapture][itmFrontLight] =
true;
1131 changedParameters =
true;
1139 if (changedParameters)
1141 NxLibCommand synchronize(cmdSynchronize,
serial);
1142 synchronize.parameters()[itmCameras] =
serial;
1143 synchronize.execute();
1156 catch (
const std::exception &e)
1158 ROS_WARN(
"Unable to update virtual objects. Error: %s", e.what());
1165 capture.parameters()[itmCameras] =
serial;
1172 NxLibItem imageNode =
cameraNode[itmImages][itmRaw];
1173 imageNode = imageNode[itmLeft];
1190 NxLibCommand(cmdDiscardPatterns,
serial).execute();
1194 collectPattern.parameters()[itmCameras] =
serial;
1195 collectPattern.parameters()[itmDecodeData] =
true;
1196 collectPattern.parameters()[itmFilter][itmCameras] =
serial;
1197 bool useModel =
true;
1198 collectPattern.parameters()[itmFilter][itmUseModel] = useModel;
1199 collectPattern.parameters()[itmFilter][itmType] = valStatic;
1200 collectPattern.parameters()[itmFilter][itmValue] =
true;
1203 collectPattern.execute();
1205 catch (NxLibException& e)
1207 if (e.getErrorCode() == NxLibExecutionFailed)
1209 if (collectPattern.result()[itmErrorSymbol] == errPatternNotFound ||
1210 collectPattern.result()[itmErrorSymbol] == errPatternNotDecodable)
1218 if (!collectPattern.result()[itmStereo].exists())
1224 std::vector<StereoCalibrationPattern> result;
1226 for (
int i = 0; i < collectPattern.result()[itmStereo].count(); i++)
1228 result.emplace_back(collectPattern.result()[itmStereo][i]);
1232 NxLibItem pattern = collectPattern.result()[itmPatterns][0][
serial];
1233 if (pattern[itmLeft].count() > 1 || pattern[itmRight].count() > 1)
1240 for (
size_t i = 0; i < result.size(); i++)
1242 for (
int j = 0; j < pattern[itmLeft][i][itmPoints].count(); j++)
1244 NxLibItem pointNode = pattern[itmLeft][i][itmPoints][j];
1246 ensenso_camera_msgs::ImagePoint point;
1247 point.x = pointNode[0].asDouble();
1248 point.y = pointNode[1].asDouble();
1249 result.at(i).leftPoints.push_back(point);
1251 for (
int j = 0; j < pattern[itmRight][i][itmPoints].count(); j++)
1253 NxLibItem pointNode = pattern[itmRight][i][itmPoints][j];
1255 ensenso_camera_msgs::ImagePoint point;
1256 point.x = pointNode[0].asDouble();
1257 point.y = pointNode[1].asDouble();
1258 result.at(i).rightPoints.push_back(point);
1269 NxLibItem monoCalibrationNode =
cameraNode[itmCalibration][itmMonocular][right ? itmRight : itmLeft];
1270 NxLibItem stereoCalibrationNode =
cameraNode[itmCalibration][itmStereo][right ? itmRight : itmLeft];
1280 info->D.resize(5, 0);
1285 for (
int row = 0; row < 3; row++)
1287 for (
int column = 0; column < 3; column++)
1289 info->P[4 * row + column] = stereoCalibrationNode[itmCamera][column][row].asDouble();
1293 info->K[3 * row + column] = 1;
1294 info->R[3 * row + column] = 1;
1308 for (
int row = 0; row < 3; row++)
1310 for (
int column = 0; column < 3; column++)
1312 info->K[3 * row + column] = monoCalibrationNode[itmCamera][column][row].asDouble();
1313 info->P[4 * row + column] = stereoCalibrationNode[itmCamera][column][row].asDouble();
1315 info->R[3 * row + column] = stereoCalibrationNode[itmRotation][column][row].asDouble();
1324 double fx = stereoCalibrationNode[itmCamera][0][0].asDouble();
1325 double baseline =
cameraNode[itmCalibration][itmStereo][itmBaseline].asDouble() / 1000.0;
1326 info->P[3] = -fx * baseline;
1329 int leftTopX =
cameraNode[itmParameters][itmDisparityMap][itmAreaOfInterest][itmLeftTop][0].asInt();
1330 int leftTopY =
cameraNode[itmParameters][itmDisparityMap][itmAreaOfInterest][itmLeftTop][1].asInt();
1331 int rightBottomX =
cameraNode[itmParameters][itmDisparityMap][itmAreaOfInterest][itmRightBottom][0].asInt();
1332 int rightBottomY =
cameraNode[itmParameters][itmDisparityMap][itmAreaOfInterest][itmRightBottom][1].asInt();
1333 info->roi.x_offset = leftTopX;
1334 info->roi.y_offset = leftTopY;
1335 info->roi.width = rightBottomX - leftTopX;
1336 info->roi.height = rightBottomY - leftTopY;
1339 info->roi.do_rectify =
true;
1353 auto message = boost::make_shared<ensenso_camera_msgs::Parameter>();
1356 if (key == ensenso_camera_msgs::Parameter::REGION_OF_INTEREST)
1360 message->region_of_interest_value.lower.x = roi.
minX;
1361 message->region_of_interest_value.lower.y = roi.
minY;
1362 message->region_of_interest_value.lower.z = roi.
minZ;
1363 message->region_of_interest_value.upper.x = roi.
maxX;
1364 message->region_of_interest_value.upper.y = roi.
maxY;
1365 message->region_of_interest_value.upper.z = roi.
maxZ;
1367 else if (key == ensenso_camera_msgs::Parameter::FLEX_VIEW)
1369 NxLibItem flexViewNode =
cameraNode[itmParameters][itmCapture][itmFlexView];
1371 if (!flexViewNode.exists())
1373 message->float_value = -1;
1375 else if (flexViewNode.isNumber())
1377 message->float_value = flexViewNode.asInt();
1381 message->float_value = 0;
1394 if (parameter.key == ensenso_camera_msgs::Parameter::REGION_OF_INTEREST)
1398 roi.
minX = parameter.region_of_interest_value.lower.x;
1399 roi.
minY = parameter.region_of_interest_value.lower.y;
1400 roi.
minZ = parameter.region_of_interest_value.lower.z;
1401 roi.
maxX = parameter.region_of_interest_value.upper.x;
1402 roi.
maxY = parameter.region_of_interest_value.upper.y;
1403 roi.
maxZ = parameter.region_of_interest_value.upper.z;
1407 else if (parameter.key == ensenso_camera_msgs::Parameter::FLEX_VIEW)
1409 NxLibItem flexViewNode =
cameraNode[itmParameters][itmCapture][itmFlexView];
1411 if (!flexViewNode.exists())
1413 ROS_WARN(
"Writing the parameter FlexView, but the camera does not " 1418 int n =
static_cast<int>(std::round(parameter.float_value));
1421 flexViewNode =
false;
std::vector< tf2::Transform > handEyeCalibrationRobotPoses
sensor_msgs::ImagePtr imageFromNxLibNode(NxLibItem const &node, std::string const &frame)
std::string const DEFAULT_PARAMETER_SET
std::unique_ptr< FitPrimitiveServer > fitPrimitiveServer
void writeParameter(ensenso_camera_msgs::Parameter const ¶meter) override
void onFitPrimitive(ensenso_camera_msgs::FitPrimitiveGoalConstPtr const &goal)
std::map< std::string, ParameterSet > parameterSets
void fillDistortionParamsFromNxLib(NxLibItem const &distortionItem, sensor_msgs::CameraInfoPtr const &info)
void writeToNxLib(NxLibItem const &node, bool right=false)
void onProjectPattern(ensenso_camera_msgs::ProjectPatternGoalConstPtr const &goal)
void publish(const sensor_msgs::Image &image, const sensor_msgs::CameraInfo &info) const
void publish(const boost::shared_ptr< M > &message) const
NxLibItem toEnsensoPoint(geometry_msgs::Point32 const &point, bool convertUnits=true)
ros::Time timestampFromNxLibNode(NxLibItem const &node)
sensor_msgs::ImagePtr retrieveRenderedDepthMap(NxLibItem const &cmdResult, VersionInfo const &nxLibVersion, std::string const &frame)
void updateTransformations(tf2::Transform const &targetFrameTransformation) const
image_transport::CameraPublisher leftRectifiedImagePublisher
void onCalibrateWorkspace(ensenso_camera_msgs::CalibrateWorkspaceGoalConstPtr const &goal)
void onTexturedPointCloud(ensenso_camera_msgs::TexturedPointCloudGoalConstPtr const &goal)
void updateGlobalLink(ros::Time time=ros::Time::now(), std::string frame="", bool useCachedTransformation=false) const
StereoCamera(ros::NodeHandle nh, std::string serial, std::string fileCameraPath, bool fixed, std::string cameraFrame, std::string targetFrame, std::string robotFrame, std::string wristFrame, std::string linkFrame, int captureTimeout, std::unique_ptr< ensenso_camera::VirtualObjectHandler > virtualObjectHandler=nullptr)
pcl::PointCloud< pcl::PointNormal >::Ptr pointCloudWithNormalsFromNxLib(NxLibItem const &pointMapNode, NxLibItem const &normalNode, std::string const &frame, PointCloudROI const *roi=nullptr)
pcl::PointCloud< pcl::PointXYZ >::Ptr pointCloudFromNxLib(NxLibItem const &node, std::string const &frame, PointCloudROI const *roi=nullptr)
std::string const TARGET_FRAME_LINK
image_transport::Publisher disparityMapPublisher
tf2::Transform getLatestTransform(tf2_ros::Buffer const &tfBuffer, std::string const &cameraFrame, std::string const &targetFrame)
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout) const
tf2::Transform fromMsg(geometry_msgs::Transform const &transform)
std::unique_ptr< ProjectPatternServer > projectPatternServer
std::unique_ptr< ensenso_camera::VirtualObjectHandler > virtualObjectHandler
image_transport::Publisher projectedImagePublisher
std::string handEyeCalibrationPatternBuffer
virtual std::vector< geometry_msgs::TransformStamped > estimatePatternPoses(ros::Time imageTimestamp=ros::Time::now(), std::string const &targetFrame="") const
std::unique_ptr< CalibrateWorkspaceServer > calibrateWorkspaceServer
void writePoseToNxLib(tf2::Transform const &pose, NxLibItem const &node)
geometry_msgs::Point32 toRosPoint(NxLibItem const &itemArray, bool convertUnits=true)
pcl::PointCloud< pcl::PointXYZRGB > TexturedPointCloud
std::unique_ptr< SetParameterServer > setParameterServer
sensor_msgs::CameraInfoPtr leftCameraInfo
ros::Publisher projectedPointCloudPublisher
ros::Publisher pointCloudPublisherColor
image_transport::CameraPublisher depthImagePublisher
std::unique_ptr< CalibrateHandEyeServer > calibrateHandEyeServer
std::vector< StereoCalibrationPattern > collectPattern(bool clearBuffer=false) const
bool checkNxLibVersion(int major, int minor)
geometry_msgs::Pose poseFromTransform(tf2::Transform const &transform)
void publish(const sensor_msgs::Image &message) const
void startServers() const override
#define ROS_WARN_ONCE(...)
std::unique_ptr< LocatePatternServer > locatePatternServer
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
void publishCurrentLinks(ros::TimerEvent const &timerEvent=ros::TimerEvent())
sensor_msgs::CameraInfoPtr leftRectifiedCameraInfo
const std::string PLUMB_BOB
virtual geometry_msgs::TransformStamped estimatePatternPose(ros::Time imageTimestamp=ros::Time::now(), std::string const &targetFrame="", bool latestPatternOnly=false) const
void loadParameterSet(std::string name, ProjectorState projector=projectorDontCare)
ros::Time capture() const override
virtual void writeParameter(ensenso_camera_msgs::Parameter const ¶meter)
bool isValid(tf2::Transform const &pose)
geometry_msgs::TransformStamped transformFromPose(geometry_msgs::PoseStamped const &pose, std::string const &childFrame)
pcl::PointCloud< pcl::PointXYZ >::Ptr retrieveRenderedPointCloud(NxLibItem const &cmdResult, VersionInfo const &nxLibVersion, std::string const &frame)
ros::Publisher pointCloudPublisher
void onSetParameter(ensenso_camera_msgs::SetParameterGoalConstPtr const &goal) override
std::unique_ptr< RequestDataServer > requestDataServer
std::unique_ptr< TexturedPointCloudServer > texturedPointCloudServer
virtual void startServers() const
sensor_msgs::ImagePtr depthImageFromNxLibNode(NxLibItem const &node, std::string const &frame)
void fillCameraInfoFromNxLib(sensor_msgs::CameraInfoPtr const &info, bool right, bool rectified=false) const
NxLibItem retrieveResultPath(NxLibItem const &cmdResult, VersionInfo const &nxLibVersion)
sensor_msgs::CameraInfoPtr rightRectifiedCameraInfo
void loadParameterSet(std::string name)
void saveParameterSet(std::string name, bool projectorWasSet)
const int conversionFactor
geometry_msgs::PoseStamped stampedPoseFromTransform(geometry_msgs::TransformStamped const &transform)
tf2::Transform poseFromNxLib(NxLibItem const &node)
void onRequestData(ensenso_camera_msgs::RequestDataGoalConstPtr const &goal)
void setRenderParams(NxLibItem const ¶mItem, RenderPointMapParams const *params)
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
#define START_NXLIB_ACTION(ACTION_NAME, ACTION_SERVER)
void onCalibrateHandEye(ensenso_camera_msgs::CalibrateHandEyeGoalConstPtr const &goal)
#define PREEMPT_ACTION_IF_REQUESTED
tf2::Transform fromStampedMessage(geometry_msgs::TransformStamped const &transform)
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
void onLocatePattern(ensenso_camera_msgs::LocatePatternGoalConstPtr const &goal)
void saveParameterSet(std::string name)
image_transport::CameraPublisher leftRawImagePublisher
void fillBasicCameraInfoFromNxLib(sensor_msgs::CameraInfoPtr const &info) const
void updateCameraInfo() override
image_transport::CameraPublisher rightRawImagePublisher
ensenso_camera_msgs::ParameterPtr readParameter(std::string const &key) const override
image_transport::CameraPublisher rightRectifiedImagePublisher
virtual ensenso_camera_msgs::ParameterPtr readParameter(std::string const &key) const
#define FINISH_NXLIB_ACTION(ACTION_NAME)
std::vector< std::pair< sensor_msgs::ImagePtr, sensor_msgs::ImagePtr > > imagePairsFromNxLibNode(NxLibItem const &node, std::string const &frame)
std::string currentParameterSet
sensor_msgs::CameraInfoPtr rightCameraInfo
void onTelecentricProjection(ensenso_camera_msgs::TelecentricProjectionGoalConstPtr const &goal)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr retrieveTexturedPointCloud(NxLibItem const &cmdResult, VersionInfo const &nxLibVersion, std::string const &targetFrame)
std::unique_ptr< TelecentricProjectionServer > telecentricProjectionServer
bool loadSettings(std::string const &jsonFile, bool saveAsDefaultParameters=false)
std::unique_ptr< tf2_ros::TransformBroadcaster > transformBroadcaster