41#include <pcl/pcl_config.h>
44#include <pcl/common/io.h>
45#include <Eigen/Geometry>
46#include <Eigen/StdVector>
48#include <pcl/io/grabber.h>
49#include <pcl/common/synchronizer.h>
68 using PairOfImages = std::pair<pcl::PCLImage, pcl::PCLImage>;
72 using Ptr = shared_ptr<EnsensoGrabber>;
73 using ConstPtr = shared_ptr<const EnsensoGrabber>;
78 using sig_cb_ensenso_images = void(
const shared_ptr<PairOfImages>&);
151 const
bool auto_gain = true,
152 const
int bining = 1,
153 const
float exposure = 0.32,
154 const
bool front_light = false,
156 const
bool gain_boost = false,
157 const
bool hardware_gamma = false,
158 const
bool hdr = false,
159 const
int pixel_clock = 10,
160 const
bool projector = true,
161 const
int target_brightness = 80,
162 const std::
string trigger_mode =
"Software",
163 const
bool use_disparity_map_area_of_interest = false) const;
219 const std::
string setup =
"Moving",
220 const std::
string target =
"Hand",
221 const
Eigen::Affine3d &guess_tf =
Eigen::Affine3d::Identity (),
222 const
bool pretty_format = true) const;
255 Eigen::Vector3d &rotation_axis,
256 const
Eigen::Vector3d &translation,
257 const std::
string target =
"Hand") const;
281 const std::
string target =
"Hand");
346 Eigen::Vector3d &axis,
347 Eigen::Vector3d &translation) const;
359 Eigen::Affine3d &matrix) const;
383 const
bool pretty_format = true) const;
408 const
bool pretty_format = true) const;
421 const
bool pretty_format = true) const;
void stop() override
Stop the data acquisition.
bool isRunning() const override
Check if the data acquisition is still running.
bool closeDevice()
Closes the Ensenso device.
boost::signals2::signal< sig_cb_ensenso_images > * images_signal_
Boost images signal.
bool computeCalibrationMatrix(const std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > &robot_poses, std::string &json, const std::string setup="Moving", const std::string target="Hand", const Eigen::Affine3d &guess_tf=Eigen::Affine3d::Identity(), const bool pretty_format=true) const
Computes the calibration matrix using the collected patterns and the robot poses vector.
bool jsonTransformationToAngleAxis(const std::string json, double &alpha, Eigen::Vector3d &axis, Eigen::Vector3d &translation) const
Get the angle axis parameters corresponding to a JSON string.
bool setExtrinsicCalibration(const double euler_angle, Eigen::Vector3d &rotation_axis, const Eigen::Vector3d &translation, const std::string target="Hand") const
Update Link node in NxLib tree.
bool storeEEPROMExtrinsicCalibration() const
Copy the link defined in the Link node of the nxTree to the EEPROM.
boost::signals2::signal< sig_cb_ensenso_point_cloud > * point_cloud_signal_
Boost point cloud signal.
bool estimateCalibrationPatternPose(Eigen::Affine3d &pattern_pose) const
Estimate the calibration pattern pose.
static std::uint64_t getPCLStamp(const double ensenso_stamp)
Convert an Ensenso time stamp into a PCL/ROS time stamp.
bool angleAxisTransformationToJson(const double x, const double y, const double z, const double rx, const double ry, const double rz, const double alpha, std::string &json, const bool pretty_format=true) const
Get the JSON string corresponding to an angle axis transformation.
NxLibItem camera_
Reference to the camera tree.
bool openDevice(const int device=0)
Opens an Ensenso device.
boost::signals2::signal< sig_cb_ensenso_point_cloud_images > * point_cloud_images_signal_
Boost images + point cloud signal.
int enumDevices() const
Searches for available devices.
bool grabSingleCloud(pcl::PointCloud< pcl::PointXYZ > &cloud) const
Capture a single point cloud and store it.
static std::string getOpenCVType(const int channels, const int bpe, const bool isFlt)
Get OpenCV image type corresponding to the parameters given.
std::string getName() const override
Get class name.
std::string getTreeAsJson(const bool pretty_format=true) const
Returns the full NxLib tree as a JSON string.
bool clearEEPROMExtrinsicCalibration()
Clear the extrinsic calibration stored in the EEPROM by writing an identity matrix.
bool matrixTransformationToJson(const Eigen::Affine3d &matrix, std::string &json, const bool pretty_format=true) const
Get the JSON string corresponding to a 4x4 matrix.
float getFramesPerSecond() const override
Obtain the number of frames per second (FPS)
bool eulerAnglesTransformationToJson(const double x, const double y, const double z, const double w, const double p, const double r, std::string &json, const bool pretty_format=true) const
Get the JSON string corresponding to the Euler angles transformation.
void processGrabbing()
Continuously asks for images and or point clouds data from the device and publishes them if available...
shared_ptr< const NxLibItem > root_
Reference to the NxLib tree root.
bool tcp_open_
Whether an TCP port is opened or not.
std::string getResultAsJson(const bool pretty_format=true) const
Returns the Result node (of the last command) as a JSON string.
~EnsensoGrabber() noexcept override
Destructor inherited from the Grabber interface.
pcl::EventFrequency frequency_
Point cloud capture/processing frequency.
bool isTcpPortOpen() const
Check if a TCP port is opened.
bool jsonTransformationToMatrix(const std::string transformation, Eigen::Affine3d &matrix) const
Get the JSON string corresponding to a 4x4 matrix.
bool closeTcpPort()
Close TCP port program.
bool clearCalibrationPatternBuffer() const
Clear calibration patterns buffer.
bool initExtrinsicCalibration(const int grid_spacing) const
Set up the Ensenso sensor and API to do 3D extrinsic calibration using the Ensenso 2D patterns.
int captureCalibrationPattern() const
Captures a calibration pattern.
std::thread grabber_thread_
Grabber thread.
EnsensoGrabber()
Constructor.
bool openTcpPort(const int port=24000)
Open TCP port to enable access via the nxTreeEdit program.
void start() override
Start the point cloud and or image acquisition.
bool jsonTransformationToEulerAngles(const std::string &json, double &x, double &y, double &z, double &w, double &p, double &r) const
Get the Euler angles corresponding to a JSON string (an angle axis transformation)
std::mutex fps_mutex_
Mutual exclusion for FPS computation.
bool device_open_
Whether an Ensenso device is opened or not.
bool configureCapture(const bool auto_exposure=true, const bool auto_gain=true, const int bining=1, const float exposure=0.32, const bool front_light=false, const int gain=1, const bool gain_boost=false, const bool hardware_gamma=false, const bool hdr=false, const int pixel_clock=10, const bool projector=true, const int target_brightness=80, const std::string trigger_mode="Software", const bool use_disparity_map_area_of_interest=false) const
Configure Ensenso capture settings.
bool running_
Whether an Ensenso device is running or not.
A helper class to measure frequency of a certain event.
Grabber()=default
Default ctor.
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
Define methods for measuring time spent in code blocks.
A point structure representing Euclidean xyz coordinates.