Skip to content

Commit 8bb79cd

Browse files
author
Sascha Jongebloed
committed
Created First Version of ROS Action Services
1 parent edd1bf5 commit 8bb79cd

13 files changed

+249
-112
lines changed

CMakeLists.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
cmake_minimum_required(VERSION 3.0.2)
22
project(knowrob_designator)
33

4+
## Find catkin and required components
45
find_package(catkin REQUIRED COMPONENTS
5-
actionlib
6-
actionlib_msgs
76
rospy
87
std_msgs
8+
actionlib
9+
actionlib_msgs
910
message_generation
10-
knowrob_ros # for KnowRobRosLib
1111
)
1212

13+
catkin_python_setup()
14+
15+
## Declare ROS actions
1316
add_action_files(
1417
DIRECTORY action
15-
FILES LogDesignator.action
18+
FILES
19+
DesignatorInit.action
20+
DesignatorResolutionStart.action
21+
DesignatorResolutionFinished.action
22+
DesignatorExecutionStart.action
23+
DesignatorExecutionFinished.action
1624
)
1725

26+
## Generate messages from actions
1827
generate_messages(
19-
DEPENDENCIES actionlib_msgs std_msgs
28+
DEPENDENCIES
29+
std_msgs
30+
actionlib_msgs
2031
)
2132

33+
## Declare catkin package
2234
catkin_package(
23-
CATKIN_DEPENDS actionlib actionlib_msgs rospy std_msgs message_runtime knowrob_ros
35+
CATKIN_DEPENDS rospy std_msgs actionlib actionlib_msgs message_runtime
36+
)
37+
38+
# list all executable python and shell scripts for installation
39+
install(PROGRAMS
40+
scripts/*
41+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
2442
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Logs that the designator has finished executing.
2+
# - `designator_id`: Unique ID of this designator
3+
# - `json_designator`: Final JSON (if different from last state)
4+
# - `timestamp`: Time of completion
5+
string designator_id
6+
string json_designator
7+
time stamp
8+
---
9+
bool success
10+
string message
11+
---
12+
string status
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Logs an update during the execution of a designator.
2+
# - `designator_id`: Unique ID of this designator
3+
# - `json_designator`: Updated JSON (if different from previous log)
4+
# - `timestamp`: Time of update
5+
string designator_id
6+
string json_designator
7+
time stamp
8+
---
9+
bool success
10+
string message
11+
---
12+
string status

action/DesignatorInit.action

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Logs a root or nested designator being created.
2+
# - `designator_id`: Unique ID of this designator
3+
# - `parent_id`: ID of parent designator (or empty for root)
4+
# - `json_designator`: Full JSON structure of the designator
5+
# - `timestamp`: Time of logging
6+
string designator_id
7+
string parent_id
8+
string json_designator
9+
time stamp
10+
---
11+
bool success
12+
string message
13+
---
14+
string status
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Logs that a new designator was resolved from another.
2+
# - `designator_id`: Unique ID of resolved designator
3+
# - `resolved_from_id`: ID of the designator it was resolved from
4+
# - `json_designator`: Full JSON structure of the resolved designator
5+
# - `timestamp`: Time of resolution
6+
string designator_id
7+
string resolved_from_id
8+
string json_designator
9+
time stamp
10+
---
11+
bool success
12+
string message
13+
---
14+
string status
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Logs that a designator is now being executed.
2+
# - `designator_id`: Unique ID of this designator
3+
# - `json_designator`: Current JSON content (could be updated)
4+
# - `timestamp`: Time of execution logging
5+
string designator_id
6+
string json_designator
7+
time stamp
8+
---
9+
bool success
10+
string message
11+
---
12+
string status

action/LogDesignator.action

Lines changed: 0 additions & 9 deletions
This file was deleted.

action/ObjectDesignator

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Add or modify and object
2+
string json_designator
3+
time start
4+
time end
5+
---
6+
bool success
7+
string message
8+
---
9+
string status
Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,50 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
3+
# Test client for DesignatorResolveStart action
44

55
import rospy
66
import actionlib
7-
from knowrob_designator.msg import LogDesignatorAction, LogDesignatorGoal
7+
from knowrob_designator.msg import DesignatorResolutionStartAction, DesignatorResolutionStartGoal
8+
from time import time
89

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')
1212

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+
}
2835
}
2936
}
3037
}
3138
}
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}'")
3548

36-
client.send_goal(goal)
37-
client.wait_for_result()
38-
print(client.get_result())
49+
if __name__ == '__main__':
50+
main()

0 commit comments

Comments
 (0)