Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/daisukes/public-image-desc-serve…
Browse files Browse the repository at this point in the history
…r' into kayukawa/description_request
  • Loading branch information
SeitaKayukawa committed Mar 5, 2025
2 parents 996eece + 30a2586 commit 74c5c31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cabot_ui/cabot_ui/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, node: Node):
self.last_plan_distance = None
self.host = os.environ.get("CABOT_IMAGE_DESCRIPTION_SERVER", "http://localhost:8000")
self.enabled = (os.environ.get("CABOT_IMAGE_DESCRIPTION_ENABLED", "false").lower() == "true")
self.api_key = os.environ.get("CABOT_IMAGE_DESCRIPTION_API_KEY", "")
if self.enabled:
# handle modes (default=surround)
modes = os.environ.get("CABOT_IMAGE_DESCRIPTION_MODE", DescriptionMode.SURROUND.value).split(",")
Expand Down Expand Up @@ -130,8 +131,10 @@ def plan_callback(self, msg):
def request_description(self, global_position):
self._logger.info(F"Request Description at {global_position}")
try:
headers = {'x-api-key': self.api_key}
req = requests.get(
F"{self.host}/{Description.DESCRIPTION_API}?lat={global_position.lat}&lng={global_position.lng}&rotation={global_position.r}&max_distance={self.max_distance}"
F"{self.host}/{Description.DESCRIPTION_API}?lat={global_position.lat}&lng={global_position.lng}&rotation={global_position.r}&max_distance={self.max_distance}",
headers=headers
)
data = json.loads(req.text)
if req.status_code != requests.codes.ok:
Expand Down Expand Up @@ -213,7 +216,10 @@ def request_description_with_images1(self, global_position, length_index=0):

# Send HTTP request with the image data
try:
headers = {'Content-Type': 'application/json'}
headers = {
'Content-Type': 'application/json',
'x-api-key': self.api_key
}
json_data = json.dumps(image_data_list)
self._logger.debug(F"Request data: {image_data_list}")
lat = global_position.lat
Expand Down Expand Up @@ -304,7 +310,10 @@ def request_description_with_images2(self, global_position, mode, length_index=0

# Send HTTP request with the image data
try:
headers = {'Content-Type': 'application/json'}
headers = {
'Content-Type': 'application/json',
'x-api-key': self.api_key
}
json_data = json.dumps(image_data_list)
self._logger.debug(F"Request data: {image_data_list}")
lat = global_position.lat
Expand Down
1 change: 1 addition & 0 deletions docker-compose-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ services:
- CABOT_IMAGE_DESCRIPTION_ROTATE_LEFT
- CABOT_IMAGE_DESCRIPTION_ROTATE_FRONT
- CABOT_IMAGE_DESCRIPTION_ROTATE_RIGHT
- CABOT_IMAGE_DESCRIPTION_API_KEY
- CABOT_HANDLE_BUTTON_MAPPING
# ROS2/DDS
- ROS_LOG_DIR
Expand Down

0 comments on commit 74c5c31

Please sign in to comment.