|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | # -*- coding: utf-8 -*- |
3 | | - |
| 3 | +# Test client for DesignatorResolveStart action |
4 | 4 |
|
5 | 5 | import rospy |
6 | 6 | import actionlib |
7 | | -from knowrob_designator.msg import LogDesignatorAction, LogDesignatorGoal |
| 7 | +from knowrob_designator.msg import DesignatorResolutionStartAction, DesignatorResolutionStartGoal |
| 8 | +from time import time |
8 | 9 |
|
9 | | -rospy.init_node('designator_test_client') |
10 | | -client = actionlib.SimpleActionClient('/knowrob_designator/log', LogDesignatorAction) |
11 | | -client.wait_for_server() |
| 10 | +def main(): |
| 11 | + rospy.init_node('designator_resolve_test_client') |
12 | 12 |
|
13 | | -goal = LogDesignatorGoal() |
14 | | -goal.json_designator = """ |
15 | | -{ |
16 | | - "anAction": { |
17 | | - "type": "Transporting", |
18 | | - "objectActedOn": { |
19 | | - "anObject": { |
20 | | - "type": "Milk" |
21 | | - } |
22 | | - }, |
23 | | - "target": { |
24 | | - "theLocation": { |
25 | | - "goal": { |
26 | | - "theObject": { |
27 | | - "name": "Table1" |
| 13 | + client = actionlib.SimpleActionClient('/knowrob/designator_resolving_started', DesignatorResolutionStartAction) |
| 14 | + rospy.loginfo("Waiting for action server...") |
| 15 | + client.wait_for_server() |
| 16 | + |
| 17 | + goal = DesignatorResolutionStartGoal() |
| 18 | + goal.designator_id = "desig_001" |
| 19 | + goal.json_designator = """ |
| 20 | + { |
| 21 | + "anAction": { |
| 22 | + "type": "Transporting", |
| 23 | + "objectActedOn": { |
| 24 | + "anObject": { |
| 25 | + "type": "Milk" |
| 26 | + } |
| 27 | + }, |
| 28 | + "target": { |
| 29 | + "theLocation": { |
| 30 | + "goal": { |
| 31 | + "theObject": { |
| 32 | + "name": "Table1" |
| 33 | + } |
| 34 | + } |
28 | 35 | } |
29 | 36 | } |
30 | 37 | } |
31 | 38 | } |
32 | | - } |
33 | | -} |
34 | | -""" |
| 39 | + """ |
| 40 | + goal.stamp = rospy.Time.now() |
| 41 | + |
| 42 | + rospy.loginfo("Sending goal...") |
| 43 | + client.send_goal(goal) |
| 44 | + client.wait_for_result() |
| 45 | + |
| 46 | + result = client.get_result() |
| 47 | + rospy.loginfo(f"Result: success={result.success}, message='{result.message}'") |
35 | 48 |
|
36 | | -client.send_goal(goal) |
37 | | -client.wait_for_result() |
38 | | -print(client.get_result()) |
| 49 | +if __name__ == '__main__': |
| 50 | + main() |
0 commit comments