Skip to content

Commit

Permalink
TimePanel port (#599)
Browse files Browse the repository at this point in the history
* Add TimePanel port

* Fix ros time elapsed crash

* Disable time panel temporarily in default configuration

can be added manually over the gui

* Add time panel again

fixed indentation
  • Loading branch information
neumann-nico authored Sep 11, 2020
1 parent 40e3b9a commit 3f6108c
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 442 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ For some displays, the [documentation is updated](docs/FEATURES.md).
| Axes | Move Camera | Orbit | Displays |
| Camera | Focus Camera | XY Orbit | Help |
| Fluid Pressure | Measure | First Person | Selections |
| Grid | Select | Third Person Follower | Tool Properties |
| Grid Cells | 2D Nav Goal | Top Down Orthographic | Views |
| Illuminance | Publish Point |
| Grid | Select | Third Person Follower | Time |
| Grid Cells | 2D Nav Goal | Top Down Orthographic | Tool Properties |
| Illuminance | Publish Point | | Views |
| Image | Initial Pose |
| Interactive Marker | Interact |
| Laser Scan |
Expand All @@ -44,9 +44,9 @@ For some displays, the [documentation is updated](docs/FEATURES.md).
### Not yet ported
These features have not been ported to `ros2/rviz` yet.

| Displays | Panels |
| ------------- | ------ |
| DepthCloud | Time |
| Displays |
| ------------- |
| DepthCloud |
| Effort |

Other features:
Expand Down
2 changes: 2 additions & 0 deletions rviz_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ set(rviz_common_headers_to_moc
include/rviz_common/interaction/selection_manager.hpp
include/rviz_common/interaction/selection_manager_iface.hpp
src/rviz_common/splash_screen.hpp
src/rviz_common/time_panel.hpp
include/rviz_common/tool.hpp
src/rviz_common/tool_manager.hpp
src/rviz_common/tool_properties_panel.hpp
Expand Down Expand Up @@ -199,6 +200,7 @@ set(rviz_common_source_files
src/rviz_common/interaction/selection_renderer.cpp
src/rviz_common/interaction/view_picker.cpp
src/rviz_common/splash_screen.cpp
src/rviz_common/time_panel.cpp
src/rviz_common/transformation/identity_frame_transformer.cpp
src/rviz_common/tool_manager.cpp
src/rviz_common/tool_properties_panel.cpp
Expand Down
10 changes: 5 additions & 5 deletions rviz_common/default.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Panels:
- /Current View1
Name: Views
Splitter Ratio: 0.5
# TODO(wjwwood): restore these panels when ported
# - Class: rviz/Time
# Name: Time
# SyncMode: 0
# SyncSource: ""
- Class: rviz_common/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Visualization Manager:
Class: ""
Displays:
Expand Down
Binary file added rviz_common/icons/classes/Time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions rviz_common/src/rviz_common/panel_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@

#include <string>

// TODO(wjwwood): reenable the remaining panels
#include "./displays_panel.hpp"
#include "./help_panel.hpp"
#include "./selection_panel.hpp"
// #include "./time_panel.hpp"
#include "./time_panel.hpp"
#include "./tool_properties_panel.hpp"
#include "./transformation_panel.hpp"
#include "./views_panel.hpp"
Expand All @@ -49,7 +48,6 @@ namespace rviz_common

static Panel * newHelpPanel() {return new HelpPanel();}
static Panel * newSelectionPanel() {return new SelectionPanel();}
// static Panel * newTimePanel() {return new TimePanel();}
static Panel * newToolPropertiesPanel() {return new ToolPropertiesPanel();}
static Panel * newTransformationPanel() {return new TransformationPanel();}
static Panel * newViewsPanel() {return new ViewsPanel();}
Expand All @@ -71,8 +69,12 @@ PanelFactory::PanelFactory(
addBuiltInClass(
"rviz_common", "Selection",
"Show properties of selected objects", &newSelectionPanel);
// addBuiltInClass("rviz", "Time",
// "Show the current time", &newTimePanel);
addBuiltInClass(
"rviz_common", "Time",
"Show the current time",
[manager]() -> Panel * {
return new TimePanel(manager, nullptr);
});
addBuiltInClass(
"rviz_common", "Tool Properties",
"Show and edit properties of tools", &newToolPropertiesPanel);
Expand Down
31 changes: 17 additions & 14 deletions rviz_common/src/rviz_common/time_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
#include "./visualization_manager.hpp"
#include "frame_manager.hpp"

#include "include/rviz_common/display_group.hpp"
#include "rviz_common/display_group.hpp"

#include "./time_panel.hpp"

namespace rviz
namespace rviz_common
{

TimePanel::TimePanel(QWidget * parent)
: Panel(parent)
TimePanel::TimePanel(VisualizationManager * manager, QWidget * parent)
: Panel(parent), vis_manager_(manager)
{
wall_time_label_ = makeTimeLabel();
wall_elapsed_label_ = makeTimeLabel();
Expand Down Expand Up @@ -121,6 +121,7 @@ void TimePanel::onInitialize()
DisplayGroup * display_group = vis_manager_->getRootDisplayGroup();
onDisplayAdded(display_group);

experimentalToggled(false);
syncModeSelected(0);
pauseToggled(false);
}
Expand Down Expand Up @@ -153,20 +154,20 @@ void TimePanel::onDisplayAdded(Display * display)
DisplayGroup * display_group = qobject_cast<DisplayGroup *>(display);
if (display_group) {
connect(
display_group, SIGNAL(displayAdded(rviz::Display*)), this,
SLOT(onDisplayAdded(rviz::Display*)));
display_group, &DisplayGroup::displayAdded,
this, &TimePanel::onDisplayAdded);
connect(
display_group, SIGNAL(displayRemoved(rviz::Display*)), this,
SLOT(onDisplayRemoved(rviz::Display*)));
display_group, &DisplayGroup::displayRemoved,
this, &TimePanel::onDisplayRemoved);

for (int i = 0; i < display_group->numDisplays(); i++) {
rviz::Display * display = display_group->getDisplayAt(i);
rviz_common::Display * display = display_group->getDisplayAt(i);
onDisplayAdded(display);
}
} else {
// *INDENT-OFF* - uncrustify cannot deal with commas here
connect(display, SIGNAL(timeSignal(rviz::Display *, ros::Time)), this,
SLOT(onTimeSignal(rviz::Display *, ros::Time)));
connect(display, SIGNAL(timeSignal(rviz_common::Display *, rclcpp::Time)), this,
SLOT(onTimeSignal(rviz_common::Display *, rclcpp::Time)));
// *INDENT-ON*
}
}
Expand All @@ -180,7 +181,7 @@ void TimePanel::onDisplayRemoved(Display * display)
}
}

void TimePanel::onTimeSignal(Display * display, ros::Time time)
void TimePanel::onTimeSignal(Display * display, rclcpp::Time time)
{
QString name = display->getName();
int index = sync_source_selector_->findData(QVariant( (qulonglong)display) );
Expand Down Expand Up @@ -246,16 +247,18 @@ void TimePanel::experimentalToggled(bool checked)

void TimePanel::syncSourceSelected(int index)
{
Q_UNUSED(index);

// clear whatever was loaded from the config
config_sync_source_.clear();
vis_manager_->notifyConfigChanged();
}

void TimePanel::syncModeSelected(int mode)
{
vis_manager_->getFrameManager()->setSyncMode( (FrameManager::SyncMode)mode);
vis_manager_->getFrameManager()->setSyncMode(FrameManager::SyncMode(mode) );
sync_source_selector_->setEnabled(mode != FrameManager::SyncOff);
vis_manager_->notifyConfigChanged();
}

} // namespace rviz
} // namespace rviz_common
20 changes: 12 additions & 8 deletions rviz_common/src/rviz_common/time_panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#ifndef RVIZ_COMMON__TIME_PANEL_HPP_
#define RVIZ_COMMON__TIME_PANEL_HPP_

#include "rviz_rendering/panel.hpp"
#include "ros/time.h"
#include "rviz_common/panel.hpp"
#include "rclcpp/rclcpp.hpp"

class QLineEdit;
class QComboBox;
Expand All @@ -40,7 +40,7 @@ class QPushButton;
class QHBoxLayout;
class QWidget;

namespace rviz
namespace rviz_common
{

class VisualizationManager;
Expand All @@ -55,7 +55,9 @@ class TimePanel : public Panel
Q_OBJECT

public:
explicit TimePanel(QWidget * parent = 0);
explicit TimePanel(
VisualizationManager * manager,
QWidget * parent = nullptr);

virtual void onInitialize();

Expand All @@ -68,10 +70,10 @@ protected Q_SLOTS:
/** Read time values from VisualizationManager and update displays. */
void update();

void onDisplayAdded(rviz::Display * display);
void onDisplayRemoved(rviz::Display * display);
void onDisplayAdded(rviz_common::Display * display);
void onDisplayRemoved(rviz_common::Display * display);

void onTimeSignal(rviz::Display * display, ros::Time time);
void onTimeSignal(rviz_common::Display * display, rclcpp::Time time);

virtual void load(const Config & config);
virtual void save(Config config) const;
Expand All @@ -98,8 +100,10 @@ protected Q_SLOTS:
QLineEdit * ros_elapsed_label_;
QLineEdit * wall_time_label_;
QLineEdit * wall_elapsed_label_;

VisualizationManager * vis_manager_;
};

} // namespace rviz
} // namespace rviz_common

#endif // RVIZ_COMMON__TIME_PANEL_HPP_
5 changes: 1 addition & 4 deletions rviz_common/src/rviz_common/visualization_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,7 @@ double VisualizationManager::getWallClockElapsed()

double VisualizationManager::getROSTimeElapsed()
{
// TODO(wjwwood): why does this function return now - begin, whereas the getWallClockElapsed
// returns a pre-calculated elapsed value?
// figure out how this function is being used and make these consistent
return (frame_manager_->getTime() - ros_time_begin_).nanoseconds() / 1e9;
return static_cast<double>(ros_time_elapsed_) / 1e9;
}

void VisualizationManager::updateBackgroundColor()
Expand Down
Loading

0 comments on commit 3f6108c

Please sign in to comment.