Skip to content

Commit

Permalink
fix(test): fix race in WorldToAligned test
Browse files Browse the repository at this point in the history
The assert_has_one_new_sample would return a different sample whether
the component had received the cmd from just above, or the one
from the init.

Add a assert_has_one_new_sample as a synchronization point
  • Loading branch information
doudou committed Apr 13, 2022
1 parent 562652c commit 8e54051
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/test_world_to_aligned.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ def generate_cmd(lin = [1, 0, 0], ang = [0, 0, 0])
world_to_aligned.start

pose_sample = generate_rbs
cmd = generate_cmd
pose_samples.write pose_sample

cmd = generate_cmd
cmd_in.write cmd
cmd_out0 = assert_has_one_new_sample cmd_out, 1
assert_equal cmd.time.usec, cmd_out0.time.usec

3.times do
cmd.time = Time.now
cmd_in.write cmd
cmd_out0 = assert_has_one_new_sample cmd_out, 1
assert_equal cmd.time.usec, cmd_out0.time.usec

4.times do
# No more repeated sample here.
assert_has_no_new_sample cmd_out, 0.01
Expand Down

0 comments on commit 8e54051

Please sign in to comment.