@@ -130,43 +130,19 @@ def test_1_reached_waypoint(follow_waypoints_proc, launch_context, sim, artefact
130130 """Check that each waypoint is reached"""
131131 # Somehow the test does not seem to be called before the end of the full waypoints navigation, preventing the use of now()
132132
133- # Additional assertion using simulation state - wait for entity to be available
134- print ("Now checking entity state after goal completion..." )
135- robot = sim .get_entity ("sam_bot" )
136-
137- # Test waypoint distance functionality using the new waypoint feature
138- print ("Testing waypoint distance to navigation goal..." )
139- robot_initial_pose = robot .pose ().earliest ()
140- sim .add_transform ("world" , "custom_odom" , robot_initial_pose )
133+ print (datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ))
141134 wp = waypoints ["waypoints" ][waypoint_idx ]
142135 # Create waypoint pose for the navigation goal in custom_odom frame
136+ sim_time = assert_reached_waypoint (follow_waypoints_proc , launch_context , waypoint_idx )
143137 goal_waypoint = Pose (
144138 x = wp ["position" ]["x" ], y = wp ["position" ]["y" ], z = 0.0 ,
145139 qx = wp ["orientation" ]["x" ], qy = wp ["orientation" ]["y" ], qz = wp ["orientation" ]["z" ], qw = wp ["orientation" ]["w" ],
146140 frame = "custom_odom"
147141 )
148- sim_time = 0
149- def validate_goal_output (output ):
150- if not output .strip ():
151- print ("WARNING: follow_waypoints process produced no output!" )
152- text = f"Reached waypoint: { waypoint_idx } "
153- assert text in output , f"process never printed { text } "
154- # the format is f"Reached waypoint: {current_wp} @{sim_time}" we want to extract the sim_time. there could be more lines afterwards
155- nonlocal sim_time
156- sim_state_str = output .split (text )[1 ].splitlines ()[0 ].strip ().lstrip ("@" ).strip ()
157- sim_time = float (sim_state_str )
158-
159- # Get the follow_waypoints process from the launch context
160- print ("Starting to wait for goal completion..." )
161- #await process_tools.assert_output(
162- process_tools .assert_output_sync (
163- launch_context , follow_waypoints_proc , validate_goal_output , timeout = 60
164- )
165-
166- print (datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ))
167142 assert_close_to_waypoint (sim , "sam_bot" , goal_waypoint , sim_time = sim_time , threshold = 0.25 , export_csv = False )
168143
169144@pytest .mark .launch (fixture = launch_description )
170145def test_2_finished_waypoints (follow_waypoints_proc , launch_context , sim , artefacts_metrics ):
171146 """Check that each waypoint is reached"""
172147 assert_nav2_completed (follow_waypoints_proc , launch_context )
148+
0 commit comments