-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the acknowledge mechanism in the dummy
Also - Move behavior-related tests into `test_dummy.py`. They make more sense there - Adapt the ROS2 test for checking whether the driver is ready after startup. The driver should be operational after start by acknowledging internal errors.
- Loading branch information
1 parent
80192ba
commit 05817c3
Showing
4 changed files
with
80 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,45 @@ | ||
import pytest | ||
import rclpy | ||
from rclpy.node import Node | ||
from test.conftest import launch_description | ||
from rclpy.action import ActionClient | ||
from schunk_egu_egk_gripper_interfaces.action import ( # type: ignore[attr-defined] | ||
MoveToAbsolutePosition, | ||
) | ||
from schunk_egu_egk_gripper_interfaces.srv import ( # type: ignore[attr-defined] | ||
Acknowledge, | ||
) | ||
from test.helpers import get_current_state | ||
|
||
|
||
@pytest.mark.launch(fixture=launch_description) | ||
def test_driver_starts_in_not_ready_state(launch_context, isolated, gripper_dummy): | ||
assert get_current_state(variable="ready_for_operation") is False | ||
def test_driver_starts_in_ready_state(launch_context, isolated, gripper_dummy): | ||
assert get_current_state(variable="ready_for_operation") is True | ||
|
||
|
||
@pytest.mark.launch(fixture=launch_description) | ||
def test_driver_is_ready_after_acknowledge(launch_context, isolated, gripper_dummy): | ||
node = Node("test") | ||
activate_srv = node.create_client(Acknowledge, "/acknowledge") | ||
while not activate_srv.wait_for_service(1.0): | ||
pass | ||
future = activate_srv.call_async(Acknowledge.Request()) | ||
rclpy.spin_until_future_complete(node, future) | ||
assert future.result().success is True | ||
|
||
|
||
@pytest.mark.launch(fixture=launch_description) | ||
@pytest.mark.skip() | ||
def test_driver_moves_to_absolute_position(launch_context, isolated, gripper_dummy): | ||
node = Node("move_test") | ||
# activate_srv = node.create_client(Acknowledge, "/acknowledge") | ||
# future = activate_srv.call_async(Acknowledge.Request()) | ||
# rclpy.spin_until_future_complete(node, future) | ||
|
||
client = ActionClient(node, MoveToAbsolutePosition, "/move_to_absolute_position") | ||
client.wait_for_server() | ||
goal = MoveToAbsolutePosition.Goal() | ||
future = client.send_goal_async(goal) | ||
rclpy.spin_until_future_complete(node, future) | ||
print("done :)") | ||
assert False |