Skip to content

Commit

Permalink
add environment variables for image description function
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Sato <[email protected]>
  • Loading branch information
daisukes committed Nov 22, 2024
1 parent fcaefdd commit e27aa6f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
CABOT_SIDE # left: user stands on the right, right: user stands on the left
CYCLONEDDS_NETWORK_INTERFACE_NAME # to specify network interface name for Cyclone DDS
```
- Options for image description (hold down right button for 1-3 seconds)
```
CABOT_IMAGE_DESCRIPTION_SERVER # image description server (default=http://localhost:8000)
CABOT_IMAGE_DESCRIPTION_ENABLED # enable image description (default=false)
CABOT_IMAGE_DESCRIPTION_ROTATE_LEFT # rotate left image (default=false)
CABOT_IMAGE_DESCRIPTION_ROTATE_FRONT # rotate front image (default=false)
CABOT_IMAGE_DESCRIPTION_ROTATE_RIGHT # rotate right image (default=false)
```
- Options for debug/test
```
CABOT_GAMEPAD # (default=gamepad) gamepad type for remote controll (ex. PS4 controller)
Expand Down
14 changes: 10 additions & 4 deletions cabot_ui/cabot_ui/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(self, node: Node):
self.max_distance = node.declare_parameter("description_max_distance", 100).value
self.last_images = {'left': None, 'front': None, 'right': None}
self.last_plan_distance = None
self.host = os.environ.get("CABOT_DESCRIPTION_SERVER", "http://localhost:8000")
self.host = os.environ.get("CABOT_IMAGE_DESCRIPTION_SERVER", "http://localhost:8000")
self.enabled = os.environ.get("CABOT_IMAGE_DESCRIPTION_ENABLED", False)
self._logger = rclpy.logging.get_logger("cabot_ui_manager.description")

self.subscriptions = {
Expand All @@ -67,10 +68,13 @@ def __init__(self, node: Node):
}

# rotate modes
rotate_left = os.environ.get("CABOT_IMAGE_DESCRIPTION_ROTATE_LEFT", False)
rotate_front = os.environ.get("CABOT_IMAGE_DESCRIPTION_ROTATE_FRONT", False)
rotate_right = os.environ.get("CABOT_IMAGE_DESCRIPTION_ROTATE_RIGHT", False)
self.image_rotate_modes = {
'left': cv2.ROTATE_180,
'front': cv2.ROTATE_180,
'right': None
'left': cv2.ROTATE_180 if rotate_left else None,
'front': cv2.ROTATE_180 if rotate_front else None,
'right': cv2.ROTATE_180 if rotate_right else None,
}

self.plan_sub = self.node.create_subscription(Path, '/plan', self.plan_callback, 10)
Expand Down Expand Up @@ -110,6 +114,8 @@ def request_description(self, gp):
self._logger.error(F"Request Error {error=}")

def request_description_with_images(self, gp, length_index=0):
if not self.enabled:
return None
self._logger.info(F"Request Description with images at {gp}")
image_data_list = []
distance_to_travel = 100
Expand Down
2 changes: 1 addition & 1 deletion cabot_ui/scripts/cabot_ui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def _process_navigation_event(self, event):
self._interface.set_pause_control(True)
self._navigation.set_pause_control(True)

if event.subtype == "description":
if event.subtype == "description" and self._description.enabled:
# TODO: needs to reset last_plan_distance when arrived/paused
self._logger.info(F"Request Description duration={event.param}")
if self._interface.last_pose:
Expand Down
6 changes: 5 additions & 1 deletion docker-compose-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ services:
- CABOT_INITZ
- CABOT_INITA
- CABOT_SPEED_POI_PARAMS
- CABOT_DESCRIPTION_SERVER
- CABOT_IMAGE_DESCRIPTION_SERVER
- CABOT_IMAGE_DESCRIPTION_ENABLED
- CABOT_IMAGE_DESCRIPTION_ROTATE_LEFT
- CABOT_IMAGE_DESCRIPTION_ROTATE_FRONT
- CABOT_IMAGE_DESCRIPTION_ROTATE_RIGHT
# ROS2/DDS
- ROS_LOG_DIR
- RMW_IMPLEMENTATION
Expand Down

0 comments on commit e27aa6f

Please sign in to comment.