Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dimos/agents2/test_mock_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from dimos.msgs.foxglove_msgs import ImageAnnotations
from dimos.msgs.geometry_msgs import PoseStamped, Quaternion, Transform, Vector3
from dimos.msgs.sensor_msgs import Image
from dimos.perception.detection2d import Detect2DModule, Detection2DArrayFix
from dimos.msgs.vision_msgs import Detection2DArray
from dimos.perception.detection2d import Detect2DModule
from dimos.protocol.skill.test_coordinator import SkillContainerTest
from dimos.robot.unitree_webrtc.modular.connection_module import ConnectionModule
from dimos.robot.unitree_webrtc.type.lidar import LidarMessage
Expand Down Expand Up @@ -166,7 +167,7 @@ async def test_tool_call_implicit_detections():
robot_connection.start()

detect2d = dimos.deploy(Detect2DModule)
detect2d.detections.transport = LCMTransport("/detections", Detection2DArrayFix)
detect2d.detections.transport = LCMTransport("/detections", Detection2DArray)
detect2d.annotations.transport = LCMTransport("/annotations", ImageAnnotations)
detect2d.image.connect(robot_connection.video)
detect2d.start()
Expand Down
3 changes: 1 addition & 2 deletions dimos/manipulation/visual_servoing/detection3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@

from dimos.msgs.geometry_msgs import Pose, Vector3, Quaternion
from dimos.msgs.std_msgs import Header
from dimos.msgs.vision_msgs import Detection2DArray, Detection3DArray
from dimos_lcm.vision_msgs import (
Detection3D,
Detection3DArray,
BoundingBox3D,
ObjectHypothesisWithPose,
ObjectHypothesis,
Detection2D,
Detection2DArray,
BoundingBox2D,
Pose2D,
Point2D,
Expand Down
2 changes: 1 addition & 1 deletion dimos/manipulation/visual_servoing/manipulation_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from dimos.core import Module, In, Out, rpc
from dimos.msgs.sensor_msgs import Image
from dimos.msgs.geometry_msgs import Vector3, Pose, Quaternion
from dimos.msgs.vision_msgs import Detection2DArray, Detection3DArray
from dimos_lcm.sensor_msgs import CameraInfo
from dimos_lcm.vision_msgs import Detection3DArray, Detection2DArray

from dimos.hardware.piper_arm import PiperArm
from dimos.manipulation.visual_servoing.detection3d import Detection3DProcessor
Expand Down
3 changes: 2 additions & 1 deletion dimos/manipulation/visual_servoing/pbvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from collections import deque
from scipy.spatial.transform import Rotation as R
from dimos.msgs.geometry_msgs import Pose, Vector3, Quaternion
from dimos_lcm.vision_msgs import Detection3D, Detection3DArray
from dimos.msgs.vision_msgs import Detection3DArray
from dimos_lcm.vision_msgs import Detection3D
from dimos.utils.logging_config import setup_logger
from dimos.manipulation.visual_servoing.utils import (
update_target_grasp_pose,
Expand Down
19 changes: 19 additions & 0 deletions dimos/msgs/vision_msgs/BoundingBox2DArray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dimos_lcm.vision_msgs.BoundingBox2DArray import BoundingBox2DArray as LCMBoundingBox2DArray


class BoundingBox2DArray(LCMBoundingBox2DArray):
msg_name = "vision_msgs.BoundingBox2DArray"
19 changes: 19 additions & 0 deletions dimos/msgs/vision_msgs/BoundingBox3DArray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dimos_lcm.vision_msgs.BoundingBox3DArray import BoundingBox3DArray as LCMBoundingBox3DArray


class BoundingBox3DArray(LCMBoundingBox3DArray):
msg_name = "vision_msgs.BoundingBox3DArray"
19 changes: 19 additions & 0 deletions dimos/msgs/vision_msgs/Detection2DArray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dimos_lcm.vision_msgs.Detection2DArray import Detection2DArray as LCMDetection2DArray


class Detection2DArray(LCMDetection2DArray):
msg_name = "vision_msgs.Detection2DArray"
19 changes: 19 additions & 0 deletions dimos/msgs/vision_msgs/Detection3DArray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Dimensional Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dimos_lcm.vision_msgs.Detection3DArray import Detection3DArray as LCMDetection3DArray


class Detection3DArray(LCMDetection3DArray):
msg_name = "vision_msgs.Detection3DArray"
6 changes: 6 additions & 0 deletions dimos/msgs/vision_msgs/__init__.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do relative paths work? is this a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I modeled it after dimos/msgs/std_msgs/__init__.py

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .BoundingBox2DArray import BoundingBox2DArray
from .BoundingBox3DArray import BoundingBox3DArray
from .Detection2DArray import Detection2DArray
from .Detection3DArray import Detection3DArray

__all__ = ["BoundingBox2DArray", "BoundingBox3DArray", "Detection2DArray", "Detection3DArray"]
2 changes: 1 addition & 1 deletion dimos/perception/detection2d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from dimos.perception.detection2d.module import Detect2DModule, Detection2DArrayFix
from dimos.perception.detection2d.module import Detect2DModule
from dimos.perception.detection2d.utils import *
from dimos.perception.detection2d.yolo_2d_det import *
14 changes: 5 additions & 9 deletions dimos/perception/detection2d/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
)
from dimos_lcm.foxglove_msgs.Color import Color
from dimos_lcm.foxglove_msgs.Point2 import Point2
from dimos.msgs.vision_msgs import Detection2DArray
from dimos_lcm.vision_msgs import (
BoundingBox2D,
Detection2D,
Detection2DArray,
ObjectHypothesis,
ObjectHypothesisWithPose,
Point2D,
Expand All @@ -43,10 +43,6 @@
from dimos.types.timestamped import to_ros_stamp


class Detection2DArrayFix(Detection2DArray):
msg_name = "vision_msgs.Detection2DArray"


Bbox = Tuple[float, float, float, float]
CenteredBbox = Tuple[float, float, float, float]
# yolo and detic have bad output formats
Expand Down Expand Up @@ -98,9 +94,9 @@ def build_detection2d(image, detection) -> Detection2D:
)


def build_detection2d_array(imageDetections: ImageDetections) -> Detection2DArrayFix:
def build_detection2d_array(imageDetections: ImageDetections) -> Detection2DArray:
[image, detections] = imageDetections
return Detection2DArrayFix(
return Detection2DArray(
detections_length=len(detections),
header=Header(image.ts, "camera_link"),
detections=list(
Expand Down Expand Up @@ -191,7 +187,7 @@ def flatten(xss):

class Detect2DModule(Module):
image: In[Image] = None
detections: Out[Detection2DArrayFix] = None
detections: Out[Detection2DArray] = None
annotations: Out[ImageAnnotations] = None

# _initDetector = Detic2DDetector
Expand All @@ -212,7 +208,7 @@ def start(self):
self.annotation_stream().subscribe(self.annotations.publish)

@functools.cache
def detection2d_stream(self) -> Observable[Detection2DArrayFix]:
def detection2d_stream(self) -> Observable[Detection2DArray]:
return self.image.observable().pipe(ops.map(self.detect), ops.map(build_detection2d_array))

@functools.cache
Expand Down
3 changes: 1 addition & 2 deletions dimos/perception/object_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
from dimos.core import In, Out, Module, rpc
from dimos.msgs.std_msgs import Header
from dimos.msgs.sensor_msgs import Image, ImageFormat
from dimos.msgs.vision_msgs import Detection2DArray, Detection3DArray
from dimos.msgs.geometry_msgs import Vector3, Quaternion, Transform, Pose, PoseStamped
from dimos.protocol.tf import TF
from dimos.utils.logging_config import setup_logger

# Import LCM messages
from dimos_lcm.vision_msgs import (
Detection2D,
Detection2DArray,
Detection3D,
Detection3DArray,
ObjectHypothesisWithPose,
)
from dimos_lcm.sensor_msgs import CameraInfo
Expand Down
5 changes: 3 additions & 2 deletions dimos/robot/unitree_webrtc/modular/ivan_unitree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
from dimos.msgs.geometry_msgs import PoseStamped, Quaternion, Transform, Twist, Vector3
from dimos.msgs.nav_msgs import OccupancyGrid, Path
from dimos.msgs.sensor_msgs import Image
from dimos.msgs.vision_msgs import Detection2DArray
from dimos.navigation.bt_navigator.navigator import BehaviorTreeNavigator, NavigatorState
from dimos.navigation.frontier_exploration import WavefrontFrontierExplorer
from dimos.navigation.global_planner import AstarPlanner
from dimos.navigation.local_planner.holonomic_local_planner import HolonomicLocalPlanner
from dimos.perception.detection2d import Detect2DModule, Detection2DArrayFix
from dimos.perception.detection2d import Detect2DModule
from dimos.protocol.pubsub import lcm
from dimos.robot.foxglove_bridge import FoxgloveBridge
from dimos.robot.unitree_webrtc.modular.connection_module import ConnectionModule
Expand Down Expand Up @@ -133,7 +134,7 @@ def __init__(

detection = dimos.deploy(Detect2DModule)
detection.image.connect(connection.video)
detection.detections.transport = LCMTransport("/detections", Detection2DArrayFix)
detection.detections.transport = LCMTransport("/detections", Detection2DArray)
detection.annotations.transport = LCMTransport("/annotations", ImageAnnotations)
detection.start()

Expand Down
21 changes: 6 additions & 15 deletions dimos/robot/unitree_webrtc/unitree_go2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from dimos.msgs.geometry_msgs import PoseStamped, Transform, Twist, Vector3, Quaternion
from dimos.msgs.nav_msgs import OccupancyGrid, Path
from dimos.msgs.sensor_msgs import Image
from dimos.msgs.vision_msgs import Detection2DArray, Detection3DArray
from dimos_lcm.std_msgs import String
from dimos_lcm.sensor_msgs import CameraInfo
from dimos_lcm.vision_msgs import Detection2DArray, Detection3DArray
from dimos.perception.spatial_perception import SpatialMemory
from dimos.perception.common.utils import (
extract_pose_from_detection3d,
Expand Down Expand Up @@ -401,9 +401,7 @@ def _deploy_connection(self):

self.connection.lidar.transport = core.LCMTransport("/lidar", LidarMessage)
self.connection.odom.transport = core.LCMTransport("/odom", PoseStamped)
self.connection.video.transport = core.pSHMTransport(
"/go2/color_image", default_capacity=DEFAULT_CAPACITY_COLOR_IMAGE
)
self.connection.video.transport = core.LCMTransport("/go2/color_image", Image)
self.connection.movecmd.transport = core.LCMTransport("/cmd_vel", Twist)
self.connection.camera_info.transport = core.LCMTransport("/go2/camera_info", CameraInfo)
self.connection.camera_pose.transport = core.LCMTransport("/go2/camera_pose", PoseStamped)
Expand Down Expand Up @@ -478,7 +476,7 @@ def _deploy_visualization(self):
self.websocket_vis.path.connect(self.global_planner.path)
self.websocket_vis.global_costmap.connect(self.mapper.global_costmap)

self.foxglove_bridge = FoxgloveBridge(shm_channels=["/go2/color_image#sensor_msgs.Image"])
self.foxglove_bridge = FoxgloveBridge()

def _deploy_perception(self):
"""Deploy and configure perception modules."""
Expand All @@ -491,10 +489,7 @@ def _deploy_perception(self):
output_dir=self.spatial_memory_dir,
)

color_image_default_capacity = 1920 * 1080 * 4
self.spatial_memory_module.video.transport = core.pSHMTransport(
"/go2/color_image", default_capacity=DEFAULT_CAPACITY_COLOR_IMAGE
)
self.spatial_memory_module.video.transport = core.LCMTransport("/go2/color_image", Image)
self.spatial_memory_module.odom.transport = core.LCMTransport(
"/go2/camera_pose", PoseStamped
)
Expand Down Expand Up @@ -526,12 +521,8 @@ def _deploy_camera(self):
self.depth_module = self.dimos.deploy(DepthModule, gt_depth_scale=gt_depth_scale)

# Set up transports
self.depth_module.color_image.transport = core.pSHMTransport(
"/go2/color_image", default_capacity=DEFAULT_CAPACITY_COLOR_IMAGE
)
self.depth_module.depth_image.transport = core.pSHMTransport(
"/go2/depth_image", default_capacity=DEFAULT_CAPACITY_DEPTH_IMAGE
)
self.depth_module.color_image.transport = core.LCMTransport("/go2/color_image", Image)
self.depth_module.depth_image.transport = core.LCMTransport("/go2/depth_image", Image)
self.depth_module.camera_info.transport = core.LCMTransport("/go2/camera_info", CameraInfo)

logger.info("Camera module deployed and connected")
Expand Down
Loading