Skip to content

removing goals from KB #325

@Ogusch

Description

@Ogusch

Hello,

I have written a coordinator that checks the KB predicates. Depending on the state, the target should be changed. However, I am not able to remove the current targets. E.g.

Initial Problem.pddl

(:goal (and
    (= (n_drinks tableb1) 2)
    (= (n_drinks tableb2) 1)
))

I want followig:

(:goal (and
))

Snippet of function, which should remove goals:

    print("___main_executor___: remove_goal")
    
    sps = rospy.ServiceProxy('/rosplan_knowledge_base/state/goals', GetAttributeService)
    goals = {}
    
    gas = GetAttributeServiceRequest()
    gas.predicate_name = 'n_drinks'
    facts = sps(gas)
    for k in facts.attributes:
        table = k.ineq.LHS.tokens[0].function.typed_parameters[0].value
        amount = k.ineq.RHS.tokens[0].constant
        goals[table] = amount
        
    
    kus = KnowledgeUpdateServiceRequest()
    # REMOVE_GOAL=3 https://kcl-planning.github.io/ROSPlan//tutorials/tutorial_08
    kus.update_type = 3

    kus.knowledge.knowledge_type = 2
    kus.knowledge.attribute_name = 'n_drinks'
    
    for key,value in goals.items():
        kv = KeyValue()
        kv.key = key
        kv.value = value
        string_goal = "(= (n_drinks " + kv.key + ") " + str(int(kv.value)) +")"
        print("___main_executor___: remove_goal: remove goal " + string_goal)
        kus.knowledge.values.append(kv)
        kus.knowledge.values.append(string_goal)
        kuc = rospy.ServiceProxy('/rosplan_knowledge_base/update', KnowledgeUpdateService)

The problem instance is getting overwritten. Only the goal does not change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions