Skip to content

Commit c7de3df

Browse files
Deprecates update(float, float) methods and provides update(std::chrono::duration, std::chrono::duration) replacements. (#1533)
Signed-off-by: Mark Johnson <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]>
1 parent af656e3 commit c7de3df

File tree

12 files changed

+83
-19
lines changed

12 files changed

+83
-19
lines changed

rviz_common/include/rviz_common/display.hpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,21 @@ class RVIZ_COMMON_PUBLIC Display : public rviz_common::properties::BoolProperty
151151

152152
/// Called periodically by the visualization manager.
153153
/**
154-
* \param wall_dt Wall-clock time, in seconds, since the last time the update list was run through.
155-
* \param ros_dt ROS time, in seconds, since the last time the update list was run through.
154+
* \param wall_dt Wall-clock time since the last time the update list was run through.
155+
* \param ros_dt ROS time since the last time the update list was run through.
156156
*/
157157
virtual
158158
void
159+
update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt);
160+
161+
/// Called periodically by the visualization manager.
162+
/**
163+
* \param wall_dt Wall-clock time, in nanoseconds, since the last time the update list was run through.
164+
* \param ros_dt ROS time, in nanoseconds, since the last time the update list was run through.
165+
*/
166+
[[deprecated("Use update(std::chrono::nanoseconds, std::chrono::nanoseconds)")]]
167+
virtual
168+
void
159169
update(float wall_dt, float ros_dt);
160170

161171
/// Called to tell the display to clear its state.

rviz_common/include/rviz_common/display_group.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ class RVIZ_COMMON_PUBLIC DisplayGroup : public Display
146146
virtual DisplayGroup * getGroupAt(int index) const;
147147

148148
/// Call update() on all child Displays.
149+
void update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt) override;
150+
151+
/// Call update() on all child Displays.
152+
[[deprecated("Use update(std::chrono::nanoseconds, std::chrono::nanoseconds)")]]
149153
void update(float wall_dt, float ros_dt) override;
150154

151155
/// Reset this and all child Displays.

rviz_common/include/rviz_common/tool.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ class RVIZ_COMMON_PUBLIC Tool : public QObject
102102
virtual void deactivate() = 0;
103103

104104
/// Called periodically, typically at 30Hz.
105+
/**
106+
* \param wall_dt Wall-clock time since the last time the update list was run through.
107+
* \param ros_dt ROS time since the last time the update list was run through.
108+
*/
109+
virtual void update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt);
110+
111+
/// Called periodically, typically at 30Hz.
112+
/**
113+
* \param wall_dt Wall-clock time, in nanoseconds, since the last time the update list was run through.
114+
* \param ros_dt ROS time, in nanoseconds, since the last time the update list was run through.
115+
*/
116+
[[deprecated("Use update(std::chrono::nanoseconds, std::chrono::nanoseconds)")]]
105117
virtual void update(float wall_dt, float ros_dt);
106118

107119
enum

rviz_common/include/rviz_common/view_controller.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ class RVIZ_COMMON_PUBLIC ViewController : public properties::Property
127127
/**
128128
* Override with code that needs to run repeatedly.
129129
*/
130+
virtual void update(std::chrono::nanoseconds dt, std::chrono::nanoseconds ros_dt);
131+
132+
/// Called at 30Hz by ViewManager::update() while this view is active.
133+
/**
134+
* Override with code that needs to run repeatedly.
135+
*/
136+
[[deprecated("Use update(std::chrono::nanoseconds, std::chrono::nanoseconds)")]]
130137
virtual void update(float dt, float ros_dt);
131138

132139
/// Called when mouse events are fired.

rviz_common/include/rviz_common/view_manager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class RVIZ_COMMON_PUBLIC ViewManager : public QObject
7171

7272
void initialize();
7373

74+
void update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt);
75+
76+
[[deprecated("Use update(std::chrono::nanoseconds, std::chrono::nanoseconds)")]]
7477
void update(float wall_dt, float ros_dt);
7578

7679
/// Return the current ViewController in use for the main RenderWindow.

rviz_common/include/rviz_common/visualization_manager.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#ifndef RVIZ_COMMON__VISUALIZATION_MANAGER_HPP_
3333
#define RVIZ_COMMON__VISUALIZATION_MANAGER_HPP_
3434

35-
#include <chrono>
3635
#include <deque>
3736
#include <memory>
3837

@@ -372,8 +371,8 @@ protected Q_SLOTS:
372371

373372
rviz_common::properties::ColorProperty * background_color_property_;
374373

375-
float time_update_timer_;
376-
float frame_update_timer_;
374+
std::chrono::nanoseconds time_update_timer_;
375+
std::chrono::nanoseconds frame_update_timer_;
377376

378377
std::shared_ptr<rviz_common::interaction::HandlerManagerIface> handler_manager_;
379378
std::shared_ptr<rviz_common::interaction::SelectionManagerIface> selection_manager_;

rviz_common/src/rviz_common/display.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ void Display::setTopic(const QString & topic, const QString & datatype)
183183
(void) datatype;
184184
}
185185

186+
void Display::update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt)
187+
{
188+
update(wall_dt.count(), ros_dt.count());
189+
}
190+
186191
void Display::update(float wall_dt, float ros_dt)
187192
{
188193
(void) wall_dt;

rviz_common/src/rviz_common/display_group.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void DisplayGroup::fixedFrameChanged()
224224
}
225225
}
226226

227-
void DisplayGroup::update(float wall_dt, float ros_dt)
227+
void DisplayGroup::update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt)
228228
{
229229
int num_children = displays_.size();
230230
for (int i = 0; i < num_children; i++) {
@@ -235,6 +235,12 @@ void DisplayGroup::update(float wall_dt, float ros_dt)
235235
}
236236
}
237237

238+
void DisplayGroup::update(float wall_dt, float ros_dt)
239+
{
240+
this->update(std::chrono::nanoseconds(std::lround(wall_dt)),
241+
std::chrono::nanoseconds(std::lround(ros_dt)));
242+
}
243+
238244
void DisplayGroup::reset()
239245
{
240246
Display::reset();

rviz_common/src/rviz_common/tool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ bool Tool::accessAllKeys() const
7979
return access_all_keys_;
8080
}
8181

82+
void Tool::update(std::chrono::nanoseconds wall_dt, std::chrono::nanoseconds ros_dt)
83+
{
84+
update(wall_dt.count(), ros_dt.count());
85+
}
86+
8287
void Tool::update(float wall_dt, float ros_dt)
8388
{
8489
(void) wall_dt;

rviz_common/src/rviz_common/view_controller.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ void ViewController::activate()
192192
onActivate();
193193
}
194194

195+
void ViewController::update(std::chrono::nanoseconds dt, std::chrono::nanoseconds ros_dt)
196+
{
197+
update(dt.count(), ros_dt.count());
198+
}
199+
195200
void ViewController::update(float dt, float ros_dt)
196201
{
197202
(void) dt;

0 commit comments

Comments
 (0)