Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Point cloud integration, removed multiple .launch
  • Loading branch information
nesnes committed Feb 26, 2016
commit 3841ffb758fd7e7466f6dcdca10f74fff9a57d5d
16 changes: 7 additions & 9 deletions src/zed_wrapper_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ void publishPointCloud(float* p_cloud, int width, int height, ros::Publisher &pu
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

continue is not ok here - you've now left one of the entries in point_cloud.points with unitialized memory, which is impossible for anything downsteam to detect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what we can think, but when you read the std::vector::resize documentation, you see that if no default object is given to the resize as second arg, the default constructor is use the create the new objects. So the continue is possible because all the points in the cloud are initialized by the resize.

http://www.cplusplus.com/reference/vector/vector/resize/

Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably the default constructor for this type is zero-filled? Isn't NaN more desirable for a missing data point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a logic that should be handled by the PointCloud object itself and it will be a bad idea to try to overwrite it. You can see in rviz that the "missing" points aren't displayed, so the information is already in the message.

}
pcl::PointXYZRGB point;
point.y = -p_cloud[index4++];
point.z = -p_cloud[index4++];
point.x = p_cloud[index4++];
point.y = -p_cloud[index4++] * 0.001;
point.z = -p_cloud[index4++] * 0.001;
point.x = p_cloud[index4++] * 0.001;
color = p_cloud[index4++];
uint32_t color_uint = *(uint32_t*) & color; // Convert the color
unsigned char* color_uchar = (unsigned char*) &color_uint;
Expand Down Expand Up @@ -314,7 +314,6 @@ int main(int argc, char **argv) {
ROS_INFO_STREAM(errcode2str(err));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
}
zed->setBaselineRatio(0.001); // convert the ZED values in meters

//ERRCODE display
dynamic_reconfigure::Server<zed_ros_wrapper::ZedConfig> server;
Expand Down Expand Up @@ -425,7 +424,6 @@ int main(int argc, char **argv) {
ROS_INFO_STREAM(errcode2str(err));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
}
zed->setBaselineRatio(0.001); // convert the ZED values in meters
}
continue;
}
Expand All @@ -434,8 +432,8 @@ int main(int argc, char **argv) {

// Publish the left == rgb image if someone has subscribed to
if(left_SubNumber>0 || rgb_SubNumber>0) {
slMat2cvMat(zed->retrieveImage(sl::zed::SIDE::LEFT)).copyTo(leftImRGBA);// Retrieve RGBA Left image
cv::cvtColor(leftImRGBA, leftImRGB, CV_RGBA2RGB); // Convert to RGB
// Retrieve RGBA Left image
cv::cvtColor(slMat2cvMat(zed->retrieveImage(sl::zed::SIDE::LEFT)), leftImRGB, CV_RGBA2RGB); // Convert to RGB
if(left_SubNumber>0) {
publishCamInfo(left_cam_info_msg, pub_left_cam_info, t);
publishImage(leftImRGB, pub_left, left_frame_id, t);
Expand All @@ -448,8 +446,8 @@ int main(int argc, char **argv) {

// Publish the right image if someone has subscribed to
if(right_SubNumber>0) {
slMat2cvMat(zed->retrieveImage(sl::zed::SIDE::RIGHT)).copyTo(rightImRGBA);// Retrieve RGBA Right image
cv::cvtColor(rightImRGBA, rightImRGB, CV_RGBA2RGB); // Convert to RGB
// Retrieve RGBA Right image
cv::cvtColor(slMat2cvMat(zed->retrieveImage(sl::zed::SIDE::RIGHT)), rightImRGB, CV_RGBA2RGB); // Convert to RGB
publishCamInfo(right_cam_info_msg, pub_right_cam_info, t);
publishImage(rightImRGB, pub_right, right_frame_id, t);
}
Expand Down