Skip to content

Commit 8f2e17e

Browse files
authored
Added DepthCloud default plugin (#996)
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
1 parent 9599dd4 commit 8f2e17e

File tree

18 files changed

+1885
-27
lines changed

18 files changed

+1885
-27
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ For some displays, the [documentation is updated](docs/FEATURES.md).
1616
| --------------------- | ------------- | --------------------- | --------------- |
1717
| Axes | Move Camera | Orbit | Displays |
1818
| Camera | Focus Camera | XY Orbit | Help |
19-
| Effort | Measure | First Person | Selections |
20-
| Fluid | Select | Third Person Follower | Time |
21-
| Grid | 2D Nav Goal | Top Down Orthographic | Tool Properties |
22-
| Grid Cells | Publish Point | | Views |
23-
| Illuminance | Initial Pose |
24-
| Image | Interact |
19+
| DepthCloud | Measure | First Person | Selections |
20+
| Effort | Select | Third Person Follower | Time |
21+
| Fluid | 2D Nav Goal | Top Down Orthographic | Tool Properties |
22+
| Grid | Publish Point | | Views |
23+
| Grid Cells | Initial Pose |
24+
| Illuminance | Interact |
25+
| Image |
2526
| Interactive Marker |
2627
| Laser Scan |
2728
| Map |
@@ -43,12 +44,6 @@ For some displays, the [documentation is updated](docs/FEATURES.md).
4344

4445

4546
### Not yet ported
46-
These features have not been ported to `ros2/rviz` yet.
47-
48-
| Displays |
49-
| ------------- |
50-
| DepthCloud |
51-
5247
Other features:
5348
- Stereo
5449

rviz_common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ set(rviz_common_source_files
138138
src/rviz_common/add_display_dialog.cpp
139139
src/rviz_common/bit_allocator.cpp
140140
src/rviz_common/config.cpp
141+
src/rviz_common/depth_cloud_mld.cpp
141142
src/rviz_common/display_factory.cpp
142143
src/rviz_common/display_group.cpp
143144
src/rviz_common/display.cpp
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/*
2+
* Copyright (c) 2012, Willow Garage, Inc.
3+
* Copyright (c) 2023, Open Source Robotics Foundation, Inc.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* * Neither the name of the Willow Garage, Inc. nor the names of its
15+
* contributors may be used to endorse or promote products derived from
16+
* this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
#ifndef RVIZ_COMMON__DEPTH_CLOUD_MLD_HPP_
32+
#define RVIZ_COMMON__DEPTH_CLOUD_MLD_HPP_
33+
34+
#include <cmath>
35+
#include <cstdint>
36+
#include <stdexcept>
37+
#include <exception>
38+
#include <memory>
39+
#include <mutex>
40+
#include <string>
41+
#include <vector>
42+
43+
#include <sensor_msgs/msg/image.hpp>
44+
#include <sensor_msgs/msg/camera_info.hpp>
45+
#include <sensor_msgs/msg/point_cloud2.hpp>
46+
47+
#include <rclcpp/rclcpp.hpp>
48+
49+
#include "rviz_common/ros_integration/ros_node_abstraction_iface.hpp"
50+
#include "rviz_common/visibility_control.hpp"
51+
52+
// This is necessary because of using stl types here. It is completely safe, because
53+
// a) the member is not accessible from the outside
54+
// b) there are no inline functions.
55+
#ifdef _WIN32
56+
# pragma warning(push)
57+
# pragma warning(disable:4251)
58+
#endif
59+
60+
namespace rviz_common
61+
{
62+
class MultiLayerDepthException : public std::exception
63+
{
64+
public:
65+
RVIZ_COMMON_PUBLIC
66+
explicit MultiLayerDepthException(const std::string & error_msg)
67+
: std::exception(), error_msg_(error_msg)
68+
{
69+
}
70+
~MultiLayerDepthException() throw() override
71+
{
72+
}
73+
74+
RVIZ_COMMON_PUBLIC
75+
const char * what() const throw() override
76+
{
77+
return error_msg_.c_str();
78+
}
79+
80+
protected:
81+
std::string error_msg_;
82+
};
83+
84+
class RVIZ_COMMON_PUBLIC MultiLayerDepth final
85+
{
86+
public:
87+
MultiLayerDepth()
88+
: shadow_time_out_(30.0), shadow_distance_(0.01f) {}
89+
90+
virtual ~MultiLayerDepth()
91+
{
92+
}
93+
94+
void setShadowTimeOut(double time_out);
95+
96+
void enableOcclusionCompensation(bool occlusion_compensation);
97+
98+
sensor_msgs::msg::PointCloud2::SharedPtr
99+
generatePointCloudFromDepth(
100+
const sensor_msgs::msg::Image::ConstSharedPtr & depth_msg,
101+
const sensor_msgs::msg::Image::ConstSharedPtr & color_msg,
102+
sensor_msgs::msg::CameraInfo::ConstSharedPtr camera_info_msg,
103+
ros_integration::RosNodeAbstractionIface::WeakPtr rviz_ros_node);
104+
105+
void reset();
106+
107+
private:
108+
/** @brief Precompute projection matrix, initialize buffers */
109+
void initializeConversion(
110+
const sensor_msgs::msg::Image::ConstSharedPtr & depth_msg,
111+
sensor_msgs::msg::CameraInfo::ConstSharedPtr & camera_info_msg);
112+
113+
/** @brief Convert color data to RGBA format */
114+
template<typename T>
115+
void convertColor(
116+
const sensor_msgs::msg::Image::ConstSharedPtr & color_msg,
117+
std::vector<uint32_t> & rgba_color_raw);
118+
119+
/** @brief Generate single-layered depth cloud (depth only) */
120+
template<typename T>
121+
sensor_msgs::msg::PointCloud2::SharedPtr generatePointCloudSL(
122+
const sensor_msgs::msg::Image::ConstSharedPtr & depth_msg,
123+
std::vector<uint32_t> & rgba_color_raw);
124+
125+
/** @brief Generate multi-layered depth cloud (depth+shadow) */
126+
template<typename T>
127+
sensor_msgs::msg::PointCloud2::SharedPtr generatePointCloudML(
128+
const sensor_msgs::msg::Image::ConstSharedPtr & depth_msg,
129+
std::vector<uint32_t> & rgba_color_raw,
130+
ros_integration::RosNodeAbstractionIface::WeakPtr rviz_ros_node);
131+
132+
// Helpers to generate pointcloud2 message
133+
sensor_msgs::msg::PointCloud2::SharedPtr initPointCloud();
134+
void finalizePointCloud(
135+
sensor_msgs::msg::PointCloud2::SharedPtr & point_cloud,
136+
std::size_t size);
137+
138+
std::vector<float> projection_map_x_;
139+
std::vector<float> projection_map_y_;
140+
141+
// shadow buffers
142+
std::vector<float> shadow_depth_;
143+
std::vector<double> shadow_timestamp_;
144+
std::vector<uint8_t> shadow_buffer_;
145+
146+
// configuration
147+
bool occlusion_compensation_;
148+
double shadow_time_out_;
149+
float shadow_distance_;
150+
};
151+
} // namespace rviz_common
152+
153+
#ifdef _WIN32
154+
# pragma warning(pop)
155+
#endif
156+
157+
#endif // RVIZ_COMMON__DEPTH_CLOUD_MLD_HPP_

rviz_common/include/rviz_common/properties/ros_topic_property.hpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,35 @@ protected Q_SLOTS:
7878
QString message_type_;
7979
};
8080

81-
} // end namespace properties
81+
class RVIZ_COMMON_PUBLIC RosFilteredTopicProperty
82+
: public rviz_common::properties::RosTopicProperty
83+
{
84+
Q_OBJECT
85+
86+
public:
87+
RosFilteredTopicProperty(
88+
const QString & name = QString(),
89+
const QString & default_value = QString(),
90+
const QString & message_type = QString(),
91+
const QString & description = QString(),
92+
const QRegExp & filter = QRegExp(),
93+
Property * parent = 0,
94+
const char * changed_slot = 0,
95+
QObject * receiver = 0);
8296

97+
void enableFilter(bool enabled);
98+
99+
QRegExp filter() const;
100+
101+
protected Q_SLOTS:
102+
void fillTopicList() override;
103+
104+
private:
105+
QRegExp filter_;
106+
bool filter_enabled_;
107+
};
108+
109+
} // end namespace properties
83110
} // end namespace rviz_common
84111

85112
#endif // RVIZ_COMMON__PROPERTIES__ROS_TOPIC_PROPERTY_HPP_

0 commit comments

Comments
 (0)