Using functions in ROSPlan

46 views
Skip to first unread message

Stephen Balakirsky

unread,
Aug 30, 2019, 1:48:32 PM8/30/19
to ROSPlan
Hi,
I have a simple function in my PDDL file that can be reduced to:
(:functions
   (ordering_constraint ?o - object)
)

The function allows for constraints such as
(= (ordering_constraint object_1) 1)
(= (ordering_constraint object_2) 2)

I would like to be able to set these functions in ROSPlan with  a service call. It appears to me that this should be possible to the knowledgebase update service. However, I have been unable to either find an example or get this working on my own. Has anyone utilized functions with ROSPlan? Thanks.

Stephen

Stephen Balakirsky

unread,
Aug 30, 2019, 5:20:40 PM8/30/19
to ROSPlan
I think that I got it...

rosservice call /rosplan_knowledge_base/update "update_type: 0
knowledge:
  knowledge_type: 2
  initial_time: {secs: 0, nsecs: 0}
  is_negative: false
  instance_type: ''
  instance_name: ''
  attribute_name: 'ordering_constraint'
  values:
  - {key: 's', value: 'object_1'}
  function_value: 2.0
  optimization: ''
  expr:
    tokens:
    - expr_type: 0
      constant: 0.0
      function:
        name: ''
        typed_parameters:
        - {key: '', value: ''}
      op: 0
      special_type: 0
  ineq:
    comparison_type: 0
    LHS:
      tokens:
      - expr_type: 0
        constant: 0.0
        function:
          name: ''
          typed_parameters:
          - {key: '', value: ''}
        op: 0
        special_type: 0
    RHS:
      tokens:
      - expr_type: 0
        constant: 0.0
        function:
          name: ''"

Michael Cashmore

unread,
Sep 2, 2019, 4:02:18 AM9/2/19
to ROSPlan
You got it.

There is some more information here:
https://kcl-planning.github.io/ROSPlan//tutorials/tutorial_08

The function value can also be set in a PDDL problem file loaded into the KB, and the function call can be made from code. Python and bash examples below.
```python
ki = KnowledgeItem()
ki.attribute_name = "ordering_constraint"
ki.knowledge_type = ki.FUNCTION
kv = KeyValue()
kv.key = "o"
kv.value = "object_1"
ki.values.append(kv)
ki.function_value = 2.0
```

```
#!bin/bash
rosservice call /rosplan_knowledge_base/update "update_type: 0
knowledge:
  knowledge_type: 2
  attribute_name: 'ordering_constraint'
  values:
  - {key: 's', value: 'object_1'}"
  function_value: 2.0
```

Michael
Reply all
Reply to author
Forward
0 new messages