34 #include <arpa/inet.h> 36 #include <turbojpeg.h> 38 #include <Eigen/Geometry> 39 #include <opencv2/opencv.hpp> 46 #include <multisense_lib/MultiSenseChannel.hh> 48 #include <multisense_ros/RawCamConfig.h> 49 #include <multisense_ros/RawCamCal.h> 50 #include <multisense_ros/DeviceInfo.h> 51 #include <multisense_ros/Histogram.h> 94 {
reinterpret_cast<Camera*
>(userDataP)->monoCallback(header); }
96 {
reinterpret_cast<Camera*
>(userDataP)->rectCallback(header); }
98 {
reinterpret_cast<Camera*
>(userDataP)->depthCallback(header); }
100 {
reinterpret_cast<Camera*
>(userDataP)->pointCloudCallback(header); }
102 {
reinterpret_cast<Camera*
>(userDataP)->rawCamDataCallback(header); }
104 {
reinterpret_cast<Camera*
>(userDataP)->colorImageCallback(header); }
106 {
reinterpret_cast<Camera*
>(userDataP)->disparityImageCallback(header); }
108 {
reinterpret_cast<Camera*
>(userDataP)->jpegImageCallback(header); }
110 {
reinterpret_cast<Camera*
>(userDataP)->histogramCallback(header); }
111 void colorizeCB(
const image::Header& header,
void* userDataP)
112 {
reinterpret_cast<Camera*
>(userDataP)->colorizeCallback(header); }
114 bool isValidReprojectedPoint(
const Eigen::Vector3f& pt,
double squared_max_range)
116 return pt[2] > 0.0f && std::isfinite(pt[2]) && pt.squaredNorm() < squared_max_range;
119 void writePoint(sensor_msgs::PointCloud2 &pointcloud,
size_t index,
const Eigen::Vector3f &point, uint32_t color)
121 float* cloudP =
reinterpret_cast<float*
>(&(pointcloud.data[index * pointcloud.point_step]));
122 cloudP[0] = point[0];
123 cloudP[1] = point[1];
124 cloudP[2] = point[2];
126 uint32_t* colorP =
reinterpret_cast<uint32_t*
>(&(cloudP[3]));
130 void writePoint(sensor_msgs::PointCloud2 &pointcloud,
131 size_t pointcloud_index,
132 const Eigen::Vector3f &point,
140 const uint32_t luma =
static_cast<uint32_t
>(
reinterpret_cast<const uint8_t*
>(image.
imageDataP)[image_index]);
141 return writePoint(pointcloud, pointcloud_index, point, luma);
145 const uint32_t luma =
static_cast<uint32_t
>(
reinterpret_cast<const uint16_t*
>(image.
imageDataP)[image_index]);
146 return writePoint(pointcloud, pointcloud_index, point, luma);
150 const uint32_t luma =
reinterpret_cast<const uint32_t*
>(image.
imageDataP)[image_index];
151 return writePoint(pointcloud, pointcloud_index, point, luma);
156 bool clipPoint(
const BorderClip& borderClipType,
157 double borderClipValue,
163 switch (borderClipType)
165 case BorderClip::NONE:
169 case BorderClip::RECTANGULAR:
171 return !( u >= borderClipValue && u <= width - borderClipValue &&
172 v >= borderClipValue && v <= height - borderClipValue);
174 case BorderClip::CIRCULAR:
176 const double halfWidth =
static_cast<double>(width)/2.0;
177 const double halfHeight =
static_cast<double>(height)/2.0;
179 const double radius =
sqrt( halfWidth * halfWidth + halfHeight * halfHeight ) - borderClipValue;
181 return !(Eigen::Vector2d{halfWidth - u, halfHeight - v}.norm() < radius);
185 ROS_WARN(
"Camera: Unknown border clip type.");
193 cv::Vec3b u_interpolate_color(
double u,
double v,
const cv::Mat &image)
195 const double width = image.cols;
200 const size_t min_u =
static_cast<size_t>(std::min(std::max(std::floor(u), 0.), width - 1.));
201 const size_t max_u =
static_cast<size_t>(std::min(std::max(std::ceil(u), 0.), width - 1.));
203 const cv::Vec3d element0 = image.at<cv::Vec3b>(width * v + min_u);
204 const cv::Vec3d element1 = image.at<cv::Vec3b>(width * v + max_u);
206 const size_t delta_u = max_u - min_u;
208 const double u_ratio = delta_u == 0 ? 1. : (
static_cast<double>(max_u) - u) /
static_cast<double>(delta_u);
210 const cv::Vec3b result = (element0 * u_ratio + element1 * (1. - u_ratio));
220 constexpr
char Camera::LEFT[];
221 constexpr
char Camera::RIGHT[];
222 constexpr
char Camera::AUX[];
223 constexpr
char Camera::CALIBRATION[];
225 constexpr
char Camera::LEFT_CAMERA_FRAME[];
226 constexpr
char Camera::RIGHT_CAMERA_FRAME[];
227 constexpr
char Camera::LEFT_RECTIFIED_FRAME[];
228 constexpr
char Camera::RIGHT_RECTIFIED_FRAME[];
229 constexpr
char Camera::AUX_CAMERA_FRAME[];
230 constexpr
char Camera::AUX_RECTIFIED_FRAME[];
232 constexpr
char Camera::DEVICE_INFO_TOPIC[];
233 constexpr
char Camera::RAW_CAM_CAL_TOPIC[];
234 constexpr
char Camera::RAW_CAM_CONFIG_TOPIC[];
235 constexpr
char Camera::RAW_CAM_DATA_TOPIC[];
236 constexpr
char Camera::HISTOGRAM_TOPIC[];
237 constexpr
char Camera::MONO_TOPIC[];
238 constexpr
char Camera::RECT_TOPIC[];
239 constexpr
char Camera::DISPARITY_TOPIC[];
240 constexpr
char Camera::DISPARITY_IMAGE_TOPIC[];
241 constexpr
char Camera::DEPTH_TOPIC[];
242 constexpr
char Camera::OPENNI_DEPTH_TOPIC[];
243 constexpr
char Camera::COST_TOPIC[];
244 constexpr
char Camera::COLOR_TOPIC[];
245 constexpr
char Camera::RECT_COLOR_TOPIC[];
246 constexpr
char Camera::POINTCLOUD_TOPIC[];
247 constexpr
char Camera::COLOR_POINTCLOUD_TOPIC[];
248 constexpr
char Camera::ORGANIZED_POINTCLOUD_TOPIC[];
249 constexpr
char Camera::COLOR_ORGANIZED_POINTCLOUD_TOPIC[];
250 constexpr
char Camera::MONO_CAMERA_INFO_TOPIC[];
251 constexpr
char Camera::RECT_CAMERA_INFO_TOPIC[];
252 constexpr
char Camera::COLOR_CAMERA_INFO_TOPIC[];
253 constexpr
char Camera::RECT_COLOR_CAMERA_INFO_TOPIC[];
254 constexpr
char Camera::DEPTH_CAMERA_INFO_TOPIC[];
255 constexpr
char Camera::DISPARITY_CAMERA_INFO_TOPIC[];
256 constexpr
char Camera::COST_CAMERA_INFO_TOPIC[];
258 Camera::Camera(
Channel* driver,
const std::string& tf_prefix) :
261 left_nh_(device_nh_, LEFT),
262 right_nh_(device_nh_, RIGHT),
263 aux_nh_(device_nh_, AUX),
264 calibration_nh_(device_nh_, CALIBRATION),
265 left_mono_transport_(left_nh_),
266 right_mono_transport_(right_nh_),
267 left_rect_transport_(left_nh_),
268 right_rect_transport_(right_nh_),
269 left_rgb_transport_(left_nh_),
270 left_rgb_rect_transport_(left_nh_),
271 depth_transport_(device_nh_),
272 ni_depth_transport_(device_nh_),
273 disparity_left_transport_(left_nh_),
274 disparity_right_transport_(right_nh_),
275 disparity_cost_transport_(left_nh_),
276 aux_mono_transport_(aux_nh_),
277 aux_rgb_transport_(aux_nh_),
278 aux_rect_transport_(aux_nh_),
279 aux_rgb_rect_transport_(aux_nh_),
280 frame_id_left_(tf_prefix + LEFT_CAMERA_FRAME),
281 frame_id_right_(tf_prefix + RIGHT_CAMERA_FRAME),
282 frame_id_aux_(tf_prefix + AUX_CAMERA_FRAME),
283 frame_id_rectified_left_(tf_prefix + LEFT_RECTIFIED_FRAME),
284 frame_id_rectified_right_(tf_prefix + RIGHT_RECTIFIED_FRAME),
285 frame_id_rectified_aux_(tf_prefix + AUX_RECTIFIED_FRAME),
286 static_tf_broadcaster_(),
287 pointcloud_max_range_(15.0),
290 border_clip_value_(0.0)
296 if (Status_Ok != status) {
297 ROS_ERROR(
"Camera: failed to query version info: %s", Channel::statusString(status));
302 if (Status_Ok != status) {
303 ROS_ERROR(
"Camera: failed to query device info: %s", Channel::statusString(status));
312 if (Status_Ok != status) {
313 ROS_ERROR(
"Camera: failed to query sensor configuration: %s", Channel::statusString(status));
440 const auto point_cloud_color_topics =
has_aux_camera_ ? Source_Luma_Rectified_Aux | Source_Chroma_Rectified_Aux :
441 Source_Luma_Left | Source_Chroma_Left;
445 Source_Disparity | point_cloud_color_topics),
447 Source_Disparity | point_cloud_color_topics));
450 Source_Disparity | point_cloud_color_topics),
452 Source_Disparity | point_cloud_color_topics));
512 multisense_ros::DeviceInfo msg;
521 msg.pcbSerialNumbers.push_back(pcb.revision);
522 msg.pcbNames.push_back(pcb.name);
561 if (Status_Ok != status) {
562 ROS_ERROR(
"Camera: failed to query image calibration: %s",
563 Channel::statusString(status));
567 multisense_ros::RawCamCal cal;
570 cP =
reinterpret_cast<const float *
>(&(image_calibration.
left.
M[0][0]));
571 for(uint32_t i=0; i<9; i++) cal.left_M[i] = cP[i];
572 cP = reinterpret_cast<const float *>(&(image_calibration.
left.
D[0]));
573 for(uint32_t i=0; i<8; i++) cal.left_D[i] = cP[i];
574 cP = reinterpret_cast<const float *>(&(image_calibration.
left.
R[0][0]));
575 for(uint32_t i=0; i<9; i++) cal.left_R[i] = cP[i];
576 cP = reinterpret_cast<const float *>(&(image_calibration.
left.
P[0][0]));
577 for(uint32_t i=0; i<12; i++) cal.left_P[i] = cP[i];
579 cP = reinterpret_cast<const float *>(&(image_calibration.
right.
M[0][0]));
580 for(uint32_t i=0; i<9; i++) cal.right_M[i] = cP[i];
581 cP = reinterpret_cast<const float *>(&(image_calibration.
right.
D[0]));
582 for(uint32_t i=0; i<8; i++) cal.right_D[i] = cP[i];
583 cP = reinterpret_cast<const float *>(&(image_calibration.
right.
R[0][0]));
584 for(uint32_t i=0; i<9; i++) cal.right_R[i] = cP[i];
585 cP = reinterpret_cast<const float *>(&(image_calibration.
right.
P[0][0]));
586 for(uint32_t i=0; i<12; i++) cal.right_P[i] = cP[i];
588 raw_cam_cal_pub_.publish(cal);
594 ROS_WARN(
"Camera: invalid aux camera calibration");
603 std::vector<geometry_msgs::TransformStamped> stamped_transforms(3 + (has_aux_extrinsics ? 2 : 0));
605 tf2::Transform rectified_left_T_left{toRotation(image_calibration.left.R), tf2::Vector3{0., 0., 0.}};
609 stamped_transforms[0].transform =
tf2::toMsg(rectified_left_T_left);
616 stamped_transforms[1].transform =
tf2::toMsg(rectified_right_T_rectified_left.inverse());
618 tf2::Transform rectified_right_T_right{toRotation(image_calibration.right.R), tf2::Vector3{0., 0., 0.}};
622 stamped_transforms[2].transform =
tf2::toMsg(rectified_right_T_right);
624 if (has_aux_extrinsics)
631 stamped_transforms[3].transform =
tf2::toMsg(rectified_aux_T_rectified_left.inverse());
633 tf2::Transform rectified_aux_T_aux{toRotation(image_calibration.aux.R), tf2::Vector3{0., 0., 0.}};
637 stamped_transforms[4].transform =
tf2::toMsg(rectified_aux_T_aux);
670 Source_Luma_Left | Source_Chroma_Left | Source_Luma_Rectified_Left,
this);
672 driver_->
addIsolatedCallback(rectCB, Source_Luma_Rectified_Left | Source_Luma_Rectified_Right | Source_Luma_Rectified_Aux,
this);
688 const char *pcColorFrameSyncEnvStringP = getenv(
"MULTISENSE_ROS_PC_COLOR_FRAME_SYNC_OFF");
689 if (NULL != pcColorFrameSyncEnvStringP) {
690 ROS_INFO(
"color point cloud frame sync is disabled");
738 multisense_ros::Histogram rh;
742 if (Status_Ok == status) {
743 rh.frame_count = header.
frameId;
746 rh.width = header.
width;
747 rh.height = header.
height;
749 case Source_Chroma_Left:
750 case Source_Chroma_Right:
756 rh.gain = header.
gain;
768 if (Source_Jpeg_Left != header.
source) {
774 const uint32_t height = header.
height;
775 const uint32_t width = header.
width;
776 const uint32_t rgbLength = height * width * 3;
788 tjhandle jpegDecompressor = tjInitDecompress();
789 tjDecompress2(jpegDecompressor,
790 reinterpret_cast<unsigned char*>(const_cast<void*>(header.
imageDataP)),
793 width, 0, height, TJPF_RGB, 0);
794 tjDestroy(jpegDecompressor);
807 const cv::Mat rgb_image(height, width, CV_8UC3, &(
left_rgb_image_.data[0]));
812 cv::remap(rgb_image, rect_rgb_image, left_remap->map1, left_remap->map2, cv::INTER_LINEAR);
828 if (!((Source_Disparity == header.
source &&
830 (Source_Disparity_Right == header.
source &&
832 (Source_Disparity_Cost == header.
source &&
834 (Source_Disparity == header.
source &&
836 (Source_Disparity_Right == header.
source &&
845 case Source_Disparity:
846 case Source_Disparity_Right:
848 sensor_msgs::Image *imageP = NULL;
850 sensor_msgs::CameraInfo camInfo;
853 stereo_msgs::DisparityImage *stereoDisparityImageP = NULL;
856 if (Source_Disparity == header.
source) {
878 imageP->data.resize(imageSize);
879 memcpy(&imageP->data[0], header.
imageDataP, imageSize);
881 imageP->header.stamp = t;
882 imageP->height = header.
height;
883 imageP->width = header.
width;
884 imageP->is_bigendian = (htonl(1) == 1);
889 imageP->step = header.
width;
893 imageP->step = header.
width * 2;
907 if (camInfo.P[0] != camInfo.P[5])
909 std::stringstream warning;
910 warning <<
"Current camera configuration has non-square pixels (fx != fy).";
911 warning <<
"The stereo_msgs/DisparityImage does not account for";
912 warning <<
" this. Be careful when reprojecting to a pointcloud.";
913 ROS_WARN(
"%s", warning.str().c_str());
920 uint32_t floatingPointImageSize = header.
width * header.
height * 4;
921 stereoDisparityImageP->image.data.resize(floatingPointImageSize);
923 stereoDisparityImageP->header.stamp = t;
925 stereoDisparityImageP->image.height = header.
height;
926 stereoDisparityImageP->image.width = header.
width;
927 stereoDisparityImageP->image.is_bigendian = (htonl(1) == 1);
928 stereoDisparityImageP->image.header.stamp = t;
929 stereoDisparityImageP->image.header.frame_id = stereoDisparityImageP->header.frame_id;
931 stereoDisparityImageP->image.step = 4 * header.
width;
937 stereoDisparityImageP->f = camInfo.P[0];
944 stereoDisparityImageP->min_disparity = 0;
946 stereoDisparityImageP->delta_d = 1./16.;
954 cv::Mat_<uint16_t> tmpImage(header.
height,
956 reinterpret_cast<uint16_t*>(
962 cv::Mat_<float> floatingPointImage(header.
height,
964 reinterpret_cast<float*>(&stereoDisparityImageP->image.data[0]));
970 floatingPointImage = tmpImage / 16.0;
972 stereoDisparityPubP->
publish(*stereoDisparityImageP);
979 case Source_Disparity_Cost:
1003 if (Source_Luma_Left != header.
source &&
1004 Source_Luma_Right != header.
source &&
1005 Source_Luma_Aux != header.
source) {
1007 ROS_ERROR(
"Camera: unexpected mono image source: 0x%x", header.
source);
1014 case Source_Luma_Left:
1046 case Source_Luma_Right:
1076 case Source_Luma_Aux:
1111 if (Source_Luma_Rectified_Left != header.
source &&
1112 Source_Luma_Rectified_Right != header.
source &&
1113 Source_Luma_Rectified_Aux != header.
source) {
1115 ROS_ERROR(
"Camera: unexpected rectified image source: 0x%x", header.
source);
1122 case Source_Luma_Rectified_Left:
1160 case Source_Luma_Rectified_Right:
1196 case Source_Luma_Rectified_Aux:
1237 if (Source_Disparity != header.
source) {
1239 ROS_ERROR(
"Camera: unexpected depth image source: 0x%x", header.
source);
1246 if (0 == niDepthSubscribers && 0 == depthSubscribers)
1253 const float bad_point = std::numeric_limits<float>::quiet_NaN();
1254 const uint32_t depthSize = header.
height * header.
width *
sizeof(float);
1255 const uint32_t niDepthSize = header.
height * header.
width *
sizeof(uint16_t);
1256 const uint32_t imageSize = header.
width * header.
height;
1275 float *depthImageP =
reinterpret_cast<float*
>(&
depth_image_.data[0]);
1276 uint16_t *niDepthImageP =
reinterpret_cast<uint16_t*
>(&
ni_depth_image_.data[0]);
1278 const uint16_t min_ni_depth = std::numeric_limits<uint16_t>::lowest();
1279 const uint16_t max_ni_depth = std::numeric_limits<uint16_t>::max();
1297 const float *disparityImageP =
reinterpret_cast<const float*
>(header.
imageDataP);
1299 for (uint32_t i = 0 ; i < imageSize ; ++i)
1301 if (0.0 >= disparityImageP[i])
1303 depthImageP[i] = bad_point;
1304 niDepthImageP[i] = 0;
1308 depthImageP[i] = scale / disparityImageP[i];
1309 niDepthImageP[i] =
static_cast<uint16_t
>(std::min(static_cast<float>(max_ni_depth),
1310 std::max(static_cast<float>(min_ni_depth),
1311 depthImageP[i] * 1000)));
1333 const uint16_t *disparityImageP =
reinterpret_cast<const uint16_t*
>(header.
imageDataP);
1335 for (uint32_t i = 0 ; i < imageSize ; ++i)
1337 if (0 == disparityImageP[i])
1339 depthImageP[i] = bad_point;
1340 niDepthImageP[i] = 0;
1344 depthImageP[i] = scale / disparityImageP[i];
1345 niDepthImageP[i] =
static_cast<uint16_t
>(std::min(static_cast<float>(max_ni_depth),
1346 std::max(static_cast<float>(min_ni_depth),
1347 depthImageP[i] * 1000)));
1356 if (0 != niDepthSubscribers)
1361 if (0 != depthSubscribers)
1371 if (Source_Disparity != header.
source) {
1373 ROS_ERROR(
"Camera: unexpected pointcloud image source: 0x%x", header.
source);
1380 std::shared_ptr<BufferWrapper<image::Header>> left_luma_rect =
nullptr;
1381 std::shared_ptr<BufferWrapper<image::Header>> left_luma =
nullptr;
1382 std::shared_ptr<BufferWrapper<image::Header>> left_chroma =
nullptr;
1383 std::shared_ptr<BufferWrapper<image::Header>> aux_luma_rectified =
nullptr;
1384 std::shared_ptr<BufferWrapper<image::Header>> aux_chroma_rectified =
nullptr;
1386 const auto left_rect_image =
image_buffers_.find(Source_Luma_Rectified_Left);
1387 if (left_rect_image != std::end(
image_buffers_) && left_rect_image->second->data().frameId == header.
frameId) {
1388 left_luma_rect = left_rect_image->second;
1391 const auto left_luma_image =
image_buffers_.find(Source_Luma_Left);
1392 if (left_luma_image != std::end(
image_buffers_) && left_luma_image->second->data().frameId == header.
frameId) {
1393 left_luma = left_luma_image->second;
1396 const auto chroma_image =
image_buffers_.find(Source_Chroma_Left);
1397 if (chroma_image != std::end(
image_buffers_) && chroma_image->second->data().frameId == header.
frameId) {
1398 left_chroma = chroma_image->second;
1401 const auto aux_luma_rectified_image =
image_buffers_.find(Source_Luma_Rectified_Aux);
1402 if (aux_luma_rectified_image != std::end(
image_buffers_) && aux_luma_rectified_image->second->data().frameId == header.
frameId) {
1403 aux_luma_rectified = aux_luma_rectified_image->second;
1406 const auto aux_chroma_rectified_image =
image_buffers_.find(Source_Chroma_Rectified_Aux);
1407 if (aux_chroma_rectified_image != std::end(
image_buffers_) && aux_chroma_rectified_image->second->data().frameId == header.
frameId) {
1408 aux_chroma_rectified = aux_chroma_rectified_image->second;
1419 if (!(pub_pointcloud || pub_color_pointcloud || pub_organized_pointcloud || pub_color_organized_pointcloud))
1435 if (pub_color_pointcloud)
1441 if (pub_organized_pointcloud)
1450 if (pub_color_organized_pointcloud)
1461 const Eigen::Vector3f invalid_point(std::numeric_limits<float>::quiet_NaN(),
1462 std::numeric_limits<float>::quiet_NaN(),
1463 std::numeric_limits<float>::quiet_NaN());
1468 cv::Mat rectified_color;
1469 if (!
has_aux_camera_ && (pub_color_pointcloud || pub_color_organized_pointcloud))
1471 const auto &luma = left_luma->data();
1482 cv::remap(rgb_image, rect_rgb_image, left_remap->map1, left_remap->map2, cv::INTER_LINEAR);
1484 rectified_color = std::move(rect_rgb_image);
1486 else if(
has_aux_camera_ && (pub_color_pointcloud || pub_color_organized_pointcloud))
1488 const auto &luma = aux_luma_rectified->data();
1496 rectified_color = std::move(rect_rgb_image);
1502 uint32_t packed_color = 0;
1509 size_t valid_points = 0;
1510 for (
size_t y = 0 ; y < header.
height ; ++y)
1512 for (
size_t x = 0 ; x < header.
width ; ++x)
1514 const size_t index = y * header.
width + x;
1516 double disparity = 0.0f;
1521 disparity =
static_cast<double>(
reinterpret_cast<const uint16_t*
>(header.
imageDataP)[index]) / 16.0f;
1526 disparity =
static_cast<double>(
reinterpret_cast<const float*
>(header.
imageDataP)[index]);
1540 if (!rectified_color.empty())
1544 const double color_d =
has_aux_camera_ ? (disparity * aux_T) / T : 0.0;
1546 const auto color_pixel =
has_aux_camera_ ? u_interpolate_color(std::max(x - color_d, 0.), y, rectified_color) :
1547 rectified_color.at<cv::Vec3b>(y, x);
1549 packed_color |= color_pixel[2] << 16 | color_pixel[1] << 8 | color_pixel[0];
1558 if (pub_organized_pointcloud)
1563 if (pub_color_organized_pointcloud)
1571 const Eigen::Vector3f point = ((Q * Eigen::Vector4d(static_cast<double>(x),
1572 static_cast<double>(y),
1574 1.0)).hnormalized()).cast<float>();
1577 const bool valid = isValidReprojectedPoint(point, squared_max_range);
1579 if (pub_pointcloud && valid)
1581 writePoint(
luma_point_cloud_, valid_points, point, index, left_luma_rect->data());
1584 if(pub_color_pointcloud && valid)
1589 if (pub_organized_pointcloud)
1594 if (pub_color_organized_pointcloud)
1615 if(pub_color_pointcloud)
1624 if (pub_organized_pointcloud)
1629 if (pub_color_organized_pointcloud)
1642 if(Source_Disparity == header.
source)
1644 const auto image =
image_buffers_.find(Source_Luma_Rectified_Left);
1647 const auto luma_ptr = image->second;
1648 const auto &left_luma_rect = luma_ptr->data();
1650 const uint32_t left_luma_image_size = left_luma_rect.width * left_luma_rect.height;
1652 raw_cam_data_.gray_scale_image.resize(left_luma_image_size);
1654 left_luma_rect.imageDataP,
1655 left_luma_image_size *
sizeof(uint8_t));
1657 raw_cam_data_.frames_per_second = left_luma_rect.framesPerSecond;
1661 raw_cam_data_.time_stamp =
ros::Time(left_luma_rect.timeSeconds, 1000 * left_luma_rect.timeMicroSeconds);
1665 const uint32_t disparity_size = header.
width * header.
height;
1670 disparity_size * header.
bitsPerPixel == 16 ?
sizeof(uint16_t) :
sizeof(uint32_t));
1682 if (Source_Chroma_Left != header.
source &&
1683 Source_Chroma_Rectified_Aux != header.
source &&
1684 Source_Chroma_Aux != header.
source)
1686 ROS_WARN(
"Camera: unexpected color image source: 0x%x", header.
source);
1694 case Source_Chroma_Left:
1700 if (color_subscribers == 0 && color_rect_subscribers == 0)
1710 const auto luma_ptr = left_luma->second;
1712 if (header.
frameId == luma_ptr->data().frameId) {
1714 const uint32_t height = luma_ptr->data().height;
1715 const uint32_t width = luma_ptr->data().width;
1716 const uint32_t imageSize = 3 * height * width;
1736 if (color_subscribers != 0) {
1742 if (color_rect_subscribers > 0) {
1749 const cv::Mat rgb_image(height, width, CV_8UC3, &(
left_rgb_image_.data[0]));
1752 cv::remap(rgb_image, rect_rgb_image, remaps->map1, remaps->map2, cv::INTER_LINEAR);
1771 case Source_Chroma_Rectified_Aux:
1777 const auto aux_luma =
image_buffers_.find(Source_Luma_Rectified_Aux);
1782 const auto luma_ptr = aux_luma->second;
1784 if (header.
frameId == luma_ptr->data().frameId) {
1786 const uint32_t height = luma_ptr->data().height;
1787 const uint32_t width = luma_ptr->data().width;
1788 const uint32_t imageSize = 3 * height * width;
1815 case Source_Chroma_Aux:
1826 const auto luma_ptr = aux_luma->second;
1828 if (header.
frameId == luma_ptr->data().frameId) {
1829 const uint32_t height = luma_ptr->data().height;
1830 const uint32_t width = luma_ptr->data().width;
1831 const uint32_t imageSize = 3 * height * width;
1863 if (Source_Luma_Rectified_Aux != header.
source &&
1864 Source_Chroma_Rectified_Aux != header.
source &&
1865 Source_Luma_Aux != header.
source &&
1866 Source_Luma_Left != header.
source &&
1867 Source_Chroma_Left != header.
source &&
1868 Source_Luma_Rectified_Left != header.
source) {
1869 ROS_WARN(
"Camera: unexpected colorized image source: 0x%x", header.
source);
1884 multisense_ros::RawCamConfig cfg;
1886 cfg.width = config.
width();
1887 cfg.height = config.
height();
1888 cfg.frames_per_second = config.
fps();
1889 cfg.gain = config.
gain();
1890 cfg.exposure_time = config.
exposure();
1892 cfg.fx = config.
fx();
1893 cfg.fy = config.
fy();
1894 cfg.cx = config.
cx();
1895 cfg.cy = config.
cy();
1896 cfg.tx = config.
tx();
1897 cfg.ty = config.
ty();
1898 cfg.tz = config.
tz();
1899 cfg.roll = config.
roll();
1900 cfg.pitch = config.
pitch();
1901 cfg.yaw = config.
yaw();
1980 if (Status_Ok != status)
1981 ROS_ERROR(
"Camera: failed to stop all streams: %s",
1982 Channel::statusString(status));
1991 for(uint32_t i=0; i<32; i++)
1992 if ((1<<i) & enableMask && 0 ==
stream_map_[(1<<i)]++)
1993 notStarted |= (1<<i);
1995 if (0 != notStarted) {
1998 if (Status_Ok != status)
1999 ROS_ERROR(
"Camera: failed to start streams 0x%x: %s",
2000 notStarted, Channel::statusString(status));
2010 for(uint32_t i=0; i<32; i++)
2011 if ((1<<i) & disableMask && 0 == --
stream_map_[(1<<i)])
2012 notStopped |= (1<<i);
2014 if (0 != notStopped) {
2016 if (Status_Ok != status)
2017 ROS_ERROR(
"Camera: failed to stop streams 0x%x: %s\n",
2018 notStopped, Channel::statusString(status));
virtual Status startStreams(DataSource mask)=0
ros::Publisher left_rgb_cam_info_pub_
const std::string frame_id_rectified_right_
static CRL_CONSTEXPR DataSource Source_Disparity_Cost
image_transport::Publisher right_disparity_pub_
static constexpr char RECT_CAMERA_INFO_TOPIC[]
void maxPointCloudRangeChanged(double range)
ros::Publisher luma_organized_point_cloud_pub_
static CRL_CONSTEXPR DataSource Source_Luma_Aux
void pointCloudCallback(const crl::multisense::image::Header &header)
void rawCamDataCallback(const crl::multisense::image::Header &header)
image_transport::ImageTransport disparity_cost_transport_
image_transport::Publisher left_mono_cam_pub_
std::vector< PcbInfo > pcbs
static const Matrix3x3 & getIdentity()
static constexpr char RAW_CAM_DATA_TOPIC[]
sensor_msgs::Image right_rect_image_
static constexpr char COLOR_CAMERA_INFO_TOPIC[]
void publish(const sensor_msgs::Image &image, const sensor_msgs::CameraInfo &info) const
void disparityImageCallback(const crl::multisense::image::Header &header)
ros::NodeHandle device_nh_
static CRL_CONSTEXPR DataSource Source_Disparity_Right
tf2_ros::StaticTransformBroadcaster static_tf_broadcaster_
static constexpr char DEPTH_TOPIC[]
ros::Publisher right_stereo_disparity_pub_
static constexpr char MONO_TOPIC[]
ros::Publisher right_rect_cam_info_pub_
void colorImageCallback(const crl::multisense::image::Header &header)
static constexpr char DISPARITY_CAMERA_INFO_TOPIC[]
void publish(const boost::shared_ptr< M > &message) const
static CRL_CONSTEXPR DataSource Source_Jpeg_Left
static constexpr char COST_CAMERA_INFO_TOPIC[]
image_transport::ImageTransport left_rect_transport_
sensor_msgs::Image ni_depth_image_
static CRL_CONSTEXPR DataSource Source_Disparity
sensor_msgs::PointCloud2 luma_organized_point_cloud_
sensor_msgs::PointCloud2 luma_point_cloud_
void monoCallback(const crl::multisense::image::Header &header)
image_transport::Publisher left_disparity_cost_pub_
sensor_msgs::PointCloud2 color_point_cloud_
ros::Publisher left_stereo_disparity_pub_
ros::Publisher luma_point_cloud_pub_
static CRL_CONSTEXPR DataSource Source_Chroma_Left
ros::Publisher depth_cam_info_pub_
virtual Status stopStreams(DataSource mask)=0
ros::Publisher histogram_pub_
uint32_t getNumSubscribers() const
ros::Publisher left_mono_cam_info_pub_
uint64_t sensorHardwareMagic
const std::string frame_id_left_
static constexpr char ORGANIZED_POINTCLOUD_TOPIC[]
sensor_msgs::Image right_disparity_image_
Publisher advertise(const std::string &base_topic, uint32_t queue_size, bool latch=false)
std::unordered_map< crl::multisense::DataSource, std::shared_ptr< BufferWrapper< crl::multisense::image::Header > > > image_buffers_
virtual Status getImageHistogram(int64_t frameId, image::Histogram &histogram)=0
static constexpr char DEVICE_INFO_TOPIC[]
static constexpr char RECT_TOPIC[]
double border_clip_value_
sensor_msgs::Image depth_image_
image_transport::ImageTransport aux_rgb_transport_
void disconnectStream(crl::multisense::DataSource disableMask)
static constexpr char DISPARITY_IMAGE_TOPIC[]
image_transport::Publisher aux_mono_cam_pub_
static CRL_CONSTEXPR DataSource Source_Luma_Left
void depthCallback(const crl::multisense::image::Header &header)
std::string sensorFirmwareBuildDate
void connectStream(crl::multisense::DataSource enableMask)
ros::Publisher raw_cam_config_pub_
static constexpr char COST_TOPIC[]
sensor_msgs::Image left_disparity_cost_image_
virtual Status getVersionInfo(system::VersionInfo &v)=0
geometry_msgs::TransformStamped t
image_transport::ImageTransport right_mono_transport_
image_transport::ImageTransport left_rgb_transport_
uint32_t getNumSubscribers() const
void colorizeCallback(const crl::multisense::image::Header &header)
ros::Publisher right_mono_cam_info_pub_
const std::string frame_id_right_
stereo_msgs::DisparityImage left_stereo_disparity_
image_transport::ImageTransport aux_mono_transport_
ros::Publisher aux_rgb_cam_info_pub_
std::vector< uint32_t > data
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Aux
image_transport::Publisher right_mono_cam_pub_
void borderClipChanged(const BorderClip &borderClipType, double borderClipValue)
StreamMapType stream_map_
crl::multisense::system::DeviceInfo device_info_
CameraPublisher advertiseCamera(const std::string &base_topic, uint32_t queue_size, bool latch=false)
image_transport::CameraPublisher aux_rgb_rect_cam_pub_
static CRL_CONSTEXPR DataSource Source_Luma_Right
ros::Publisher aux_rect_cam_info_pub_
sensor_msgs::Image left_mono_image_
image_transport::Publisher ni_depth_cam_pub_
void rectCallback(const crl::multisense::image::Header &header)
virtual Status removeIsolatedCallback(image::Callback callback)=0
virtual Status addIsolatedCallback(image::Callback callback, DataSource imageSourceMask, void *userDataP=NULL)=0
image_transport::ImageTransport aux_rgb_rect_transport_
const std::string frame_id_rectified_left_
void updateConfig(const crl::multisense::image::Config &config)
image_transport::Publisher left_disparity_pub_
ros::Publisher raw_cam_data_pub_
image_transport::CameraPublisher left_rgb_rect_cam_pub_
ros::Publisher left_disp_cam_info_pub_
image_transport::Publisher depth_cam_pub_
void publish(const sensor_msgs::Image &message) const
BorderClip border_clip_type_
constexpr Eigen::Matrix< T, 3, 1 > ycbcrToBgr(const crl::multisense::image::Header &luma, const crl::multisense::image::Header &chroma, size_t u, size_t v)
image_transport::ImageTransport aux_rect_transport_
virtual Status getImageCalibration(image::Calibration &c)=0
const std::string TYPE_32FC1
ros::NodeHandle right_nh_
image_transport::CameraPublisher right_rect_cam_pub_
image_transport::ImageTransport left_mono_transport_
uint32_t hardwareRevision
image_transport::CameraPublisher aux_rect_cam_pub_
ros::Publisher raw_cam_cal_pub_
image_transport::CameraPublisher left_rect_cam_pub_
static CRL_CONSTEXPR DataSource Source_Chroma_Aux
sensor_msgs::Image left_rect_image_
ros::Publisher right_disp_cam_info_pub_
crl::multisense::Channel * driver_
std::shared_ptr< StereoCalibrationManger > stereo_calibration_manager_
ros::Publisher device_info_pub_
static constexpr char RAW_CAM_CAL_TOPIC[]
image_transport::Publisher left_rgb_cam_pub_
const std::string frame_id_rectified_aux_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
static constexpr char RECT_COLOR_CAMERA_INFO_TOPIC[]
static constexpr char COLOR_POINTCLOUD_TOPIC[]
static constexpr char OPENNI_DEPTH_TOPIC[]
static constexpr char COLOR_TOPIC[]
image_transport::ImageTransport left_rgb_rect_transport_
ros::NodeHandle calibration_nh_
ros::Publisher aux_rgb_rect_cam_info_pub_
sensor_msgs::Image aux_rgb_image_
sensor_msgs::Image left_rgb_image_
sensor_msgs::Image right_mono_image_
image_transport::ImageTransport depth_transport_
ros::Publisher left_rgb_rect_cam_info_pub_
void histogramCallback(const crl::multisense::image::Header &header)
uint32_t exposure() const
stereo_msgs::DisparityImage right_stereo_disparity_
VersionType sensorFirmwareVersion
static constexpr char RECT_COLOR_TOPIC[]
double pointcloud_max_range_
image_transport::ImageTransport right_rect_transport_
uint32_t getNumSubscribers() const
static CRL_CONSTEXPR DataSource Source_Chroma_Rectified_Aux
ros::Publisher left_cost_cam_info_pub_
static constexpr char DEPTH_CAMERA_INFO_TOPIC[]
static constexpr char HISTOGRAM_TOPIC[]
image_transport::Publisher aux_rgb_cam_pub_
float nominalRelativeAperture
image_transport::ImageTransport ni_depth_transport_
image_transport::ImageTransport disparity_right_transport_
static constexpr char POINTCLOUD_TOPIC[]
sensor_msgs::Image aux_mono_image_
ros::Publisher left_rect_cam_info_pub_
std::vector< uint8_t > pointcloud_rect_color_buffer_
virtual Status getDeviceInfo(system::DeviceInfo &info)=0
void jpegImageCallback(const crl::multisense::image::Header &header)
sensor_msgs::Image left_disparity_image_
ros::Publisher color_organized_point_cloud_pub_
sensor_msgs::Image aux_rgb_rect_image_
static constexpr char MONO_CAMERA_INFO_TOPIC[]
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Right
image_transport::ImageTransport disparity_left_transport_
sensor_msgs::PointCloud2 color_organized_point_cloud_
crl::multisense::system::VersionInfo version_info_
static constexpr char COLOR_ORGANIZED_POINTCLOUD_TOPIC[]
sensor_msgs::Image left_rgb_rect_image_
const std::string frame_id_aux_
void publishAllCameraInfo()
ros::Publisher aux_mono_cam_info_pub_
multisense_ros::RawCamData raw_cam_data_
uint64_t sensorHardwareVersion
ros::Publisher color_point_cloud_pub_
virtual Status getImageConfig(image::Config &c)=0
sensor_msgs::Image aux_rect_image_
std::vector< uint8_t > pointcloud_color_buffer_
static constexpr char DISPARITY_TOPIC[]
static constexpr char RAW_CAM_CONFIG_TOPIC[]
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Left