Skip to content

Commit 1411ad7

Browse files
committed
fix(ros): skip use_sim_time warning when sim clock disabled; drop redundant slow-sim warning
Addresses review feedback: the use_sim_time=true warning no longer fires when disable_sim_time_clock_ is set, since the node isn't the /clock source in that case. Also removes the now-redundant "run_simulation() took ... CPU" throttled warning, superseded by the achieved real-time factor already shown in the GUI status overlay.
1 parent 07de119 commit 1411ad7

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

mvsim_node_src/mvsim_node.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ MVSimNode::MVSimNode(rclcpp::Node::SharedPtr& n)
154154
// mvsim is the ROS *time source*: it publishes "/clock" and stamps all
155155
// outgoing messages with simulation time. The mvsim node itself therefore
156156
// normally runs with use_sim_time:=false (it drives the clock); it is the
157-
// downstream nodes that should set use_sim_time:=true.
158-
if (true == n_.param("use_sim_time", false))
157+
// downstream nodes that should set use_sim_time:=true. This does not apply
158+
// when disable_sim_time_clock_ is set, since the node no longer drives the
159+
// clock in that case.
160+
if (!disable_sim_time_clock_ && true == n_.param("use_sim_time", false))
159161
{
160162
ROS_WARN(
161163
"use_sim_time=true was set on the mvsim node itself. mvsim is the "
@@ -209,11 +211,13 @@ MVSimNode::MVSimNode(rclcpp::Node::SharedPtr& n)
209211
// mvsim is the ROS *time source*: it publishes "/clock" and stamps all
210212
// outgoing messages with simulation time. The mvsim node itself therefore
211213
// normally runs with use_sim_time:=false (it drives the clock); it is the
212-
// downstream nodes that should set use_sim_time:=true.
214+
// downstream nodes that should set use_sim_time:=true. This does not apply
215+
// when disable_sim_time_clock_ is set, since the node no longer drives the
216+
// clock in that case.
213217
{
214218
bool use_sim_time = false;
215219
n_->get_parameter_or("use_sim_time", use_sim_time, false);
216-
if (use_sim_time)
220+
if (!disable_sim_time_clock_ && use_sim_time)
217221
{
218222
RCLCPP_WARN(
219223
n_->get_logger(),
@@ -400,19 +404,7 @@ void MVSimNode::spin()
400404
}
401405

402406
// Simulate:
403-
const double t_cpu_0 = realtime_tictac_.Tac();
404407
mvsim_world_->run_simulation(incr_time);
405-
const double sim_cpu = realtime_tictac_.Tac() - t_cpu_0;
406-
407-
// Instrumentation: warn (throttled) when a single simulation call itself
408-
// took longer in wall time than the sim time it advanced -- i.e. this spin
409-
// ran slower than real time, the root symptom of the burst stalls above.
410-
if (sim_cpu > incr_time && incr_time >= mvsim_world_->get_simul_timestep())
411-
{
412-
ROS12_WARN_THROTTLE(
413-
2000, "run_simulation() took %.3f s CPU to advance %.3f s of sim time.", sim_cpu,
414-
incr_time);
415-
}
416408

417409
// t_old_simul = world.get_simul_time();
418410
t_old_ = t_new;

0 commit comments

Comments
 (0)