Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions include/rviz_2d_plot_plugin/plot_2d_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ enum class PlotMode
XY,
};

enum class DisplaySurface
{
Overlay,
Panel,
};

enum class XYHistoryMode
{
RollingTimeWindow,
Expand All @@ -61,6 +67,12 @@ enum class XYAxisScaleMode
Equal,
};

enum class SeriesAxis
{
Left,
Right,
};

enum class TimeSource
{
ReceiveTime,
Expand Down Expand Up @@ -170,6 +182,7 @@ struct SeriesColor
struct SeriesConfig
{
bool enabled{true};
SeriesAxis axis{SeriesAxis::Left};
std::string topic;
std::string x_field;
std::string y_field;
Expand Down Expand Up @@ -208,8 +221,10 @@ struct Plot2DConfig
std::vector<SeriesConfig> series{SeriesConfig{}};
std::vector<ReferenceConfig> references;
PlotMode plot_mode{PlotMode::TimeSeries};
DisplaySurface display_surface{DisplaySurface::Panel};
XAxisConfig x_axis;
AxisConfig y_axis;
AxisConfig y_axis_right;
TimeConfig time;
QoSConfig qos;
LayoutConfig layout;
Expand Down
25 changes: 25 additions & 0 deletions include/rviz_2d_plot_plugin/plot_2d_display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "rviz_2d_plot_plugin/plot_2d_renderer.hpp"
#include "rviz_2d_plot_plugin/topic_field_introspection.hpp"

class QSize;

namespace rviz_common
{
class Config;
Expand All @@ -43,6 +45,7 @@ namespace rviz_2d_plot_plugin
{

class OverlayBackend;
class PlotImagePanelWidget;
class Plot2DDisplayTestAccessor;
class Plot2DSubscriptionManager;

Expand All @@ -68,6 +71,7 @@ class Plot2DDisplay : public rviz_common::Display
private Q_SLOTS:
void onConfigPropertyChanged();
void onRenderPropertyChanged();
void onDisplaySurfaceChanged();
void onSeriesAppearancePropertyChanged();
void onReferencePropertyChanged();
void onPlotModeChanged();
Expand Down Expand Up @@ -99,6 +103,7 @@ private Q_SLOTS:
rviz_common::properties::EditableEnumProperty * x_field{nullptr};
rviz_common::properties::EditableEnumProperty * y_field{nullptr};
rviz_common::properties::EditableEnumProperty * field{nullptr};
rviz_common::properties::EnumProperty * axis{nullptr};
rviz_common::properties::StringProperty * label{nullptr};
rviz_common::properties::StringProperty * unit{nullptr};
rviz_common::properties::ColorProperty * color{nullptr};
Expand Down Expand Up @@ -170,15 +175,20 @@ private Q_SLOTS:
RenderSnapshot renderSnapshot_() const;
PlotRenderSettings renderSettingsFromProperties_() const;
PlotRenderSettings renderSettingsFromConfig_(const Plot2DConfig & config) const;
PlotRenderSettings renderSettingsForSurface_(const Plot2DConfig & config) const;
std::vector<RenderableSeries> renderableSeries_() const;
std::vector<RenderableSeries> renderableSeriesFromSnapshot_(
const RenderSnapshot & snapshot) const;
std::vector<RenderableReference> renderableReferences_() const;
std::vector<RenderableReference> renderableReferencesFromConfig_(
const Plot2DConfig & config) const;
void initializeOverlayBackend_();
void initializePanelWidget_();
void synchronizePresentationMode_(const Plot2DConfig & config);
void updatePresentationPropertyVisibility_(const Plot2DConfig & config);
void updateOverlayGeometry_();
void updateOverlayGeometry_(const Plot2DConfig & config);
QSize panelRenderSize_() const;
void renderOverlay_(bool request_rviz_render = true);
void unsubscribe_();
bool shouldRetrySubscriptions_() const;
Expand All @@ -190,6 +200,7 @@ private Q_SLOTS:

rviz_common::properties::BoolProperty * pause_plot_property_{nullptr};
rviz_common::properties::BoolProperty * clear_history_property_{nullptr};
rviz_common::properties::EnumProperty * display_surface_property_{nullptr};
rviz_common::properties::EnumProperty * plot_mode_property_{nullptr};
rviz_common::properties::Property * series_root_property_{nullptr};
rviz_common::properties::IntProperty * series_count_property_{nullptr};
Expand All @@ -214,6 +225,10 @@ private Q_SLOTS:
rviz_common::properties::BoolProperty * auto_scale_property_{nullptr};
rviz_common::properties::FloatProperty * y_min_property_{nullptr};
rviz_common::properties::FloatProperty * y_max_property_{nullptr};
rviz_common::properties::Property * right_y_axis_root_property_{nullptr};
rviz_common::properties::BoolProperty * right_y_auto_scale_property_{nullptr};
rviz_common::properties::FloatProperty * right_y_min_property_{nullptr};
rviz_common::properties::FloatProperty * right_y_max_property_{nullptr};
rviz_common::properties::Property * grid_root_property_{nullptr};
rviz_common::properties::BoolProperty * show_major_grid_property_{nullptr};
rviz_common::properties::BoolProperty * show_minor_grid_property_{nullptr};
Expand All @@ -232,9 +247,17 @@ private Q_SLOTS:
rviz_common::properties::Property * legend_root_property_{nullptr};
rviz_common::properties::BoolProperty * show_legend_property_{nullptr};
rviz_common::properties::BoolProperty * show_latest_values_property_{nullptr};
rviz_common::properties::BoolProperty * legend_field_name_only_property_{nullptr};
rviz_common::properties::EnumProperty * legend_position_property_{nullptr};
rviz_common::properties::IntProperty * legend_x_offset_property_{nullptr};
rviz_common::properties::IntProperty * legend_y_offset_property_{nullptr};
rviz_common::properties::Property * right_legend_root_property_{nullptr};
rviz_common::properties::BoolProperty * show_right_legend_property_{nullptr};
rviz_common::properties::BoolProperty * merge_right_legend_with_left_property_{nullptr};
rviz_common::properties::BoolProperty * show_right_latest_values_property_{nullptr};
rviz_common::properties::EnumProperty * right_legend_position_property_{nullptr};
rviz_common::properties::IntProperty * right_legend_x_offset_property_{nullptr};
rviz_common::properties::IntProperty * right_legend_y_offset_property_{nullptr};
rviz_common::properties::Property * layout_root_property_{nullptr};
rviz_common::properties::IntProperty * width_property_{nullptr};
rviz_common::properties::IntProperty * height_property_{nullptr};
Expand All @@ -251,6 +274,8 @@ private Q_SLOTS:
rviz_common::properties::IntProperty * font_size_property_{nullptr};

std::unique_ptr<OverlayBackend> overlay_backend_;
PlotImagePanelWidget * panel_widget_{nullptr};
bool panel_widget_registered_{false};
std::function<std::unique_ptr<OverlayBackend>(std::string)> overlay_backend_factory_;
rclcpp::Node::SharedPtr node_;
RosGraphOps ros_graph_ops_;
Expand Down
13 changes: 13 additions & 0 deletions include/rviz_2d_plot_plugin/plot_2d_renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct RenderableSeries
QColor color{80, 170, 255};
std::vector<PlotSample> samples;
std::string unit;
std::string field_name;
SeriesAxis axis{SeriesAxis::Left};
bool enabled{true};
double line_width{2.0};
LineStyle line_style{LineStyle::Solid};
Expand Down Expand Up @@ -69,16 +71,27 @@ struct PlotRenderSettings
double fixed_y_min{-1.0};
double fixed_y_max{1.0};
double y_padding_fraction{0.08};
AxisScaleMode right_y_scale_mode{AxisScaleMode::Auto};
double fixed_right_y_min{-1.0};
double fixed_right_y_max{1.0};
double right_y_padding_fraction{0.08};
QColor background_color{0, 0, 0, 190};
QColor axis_color{230, 230, 230, 230};
QColor grid_color{130, 130, 130, 80};
QColor text_color{245, 245, 245, 235};
int font_size{8};
bool show_legend{true};
bool show_latest_values{true};
bool legend_field_name_only{false};
LegendPosition legend_position{LegendPosition::TopLeft};
int legend_x_offset{4};
int legend_y_offset{4};
bool show_right_legend{true};
bool merge_right_legend_with_left{false};
bool show_right_latest_values{true};
LegendPosition right_legend_position{LegendPosition::TopRight};
int right_legend_x_offset{4};
int right_legend_y_offset{4};
bool show_major_grid{true};
bool show_minor_grid{true};
int x_major_tick_count{6};
Expand Down
1 change: 1 addition & 0 deletions src/plot_2d_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void Plot2DConfig::repair()
}

y_axis.repairFixedRange();
y_axis_right.repairFixedRange();
x_axis.repairFixedRange();
time.repair();
qos.repair();
Expand Down
Loading