Skip to content

Commit

Permalink
refactor: make QueryImage a ServiceState.
Browse files Browse the repository at this point in the history
  • Loading branch information
jws-1 committed Apr 18, 2024
1 parent 412df05 commit 5fd70fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions skills/src/lasr_skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
from .receive_object import ReceiveObject
from .handover_object import HandoverObject
from .ask_and_listen import AskAndListen
from .clip_vqa import QueryImage
29 changes: 19 additions & 10 deletions skills/src/lasr_skills/clip_vqa.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import smach_ros
from lasr_vision_clip.srv import Vqa
from lasr_vision_msgs.srv import Vqa, VqaRequest

from typing import List, Union


class QueryImage(smach_ros.ServiceState):

def __init__(
self,
):
super(smach_ros.ServiceState, self).__init__(
"/clip_vqa/query_service",
Vqa,
request_slots=["answers"],
response_slots=["answer", "similarity_score"],
)
def __init__(self, possible_answers: Union[None, List[str]] = None):

if possible_answers is not None:
super(QueryImage, self).__init__(
"/clip_vqa/query_service",
Vqa,
request=VqaRequest(possible_answers=possible_answers),
response_slots=["answer", "similarity"],
)
else:
super(QueryImage, self).__init__(
"/clip_vqa/query_service",
Vqa,
request_slots=["possible_answers"],
response_slots=["answer", "similarity"],
)

0 comments on commit 5fd70fe

Please sign in to comment.