-
Notifications
You must be signed in to change notification settings - Fork 168
Modules navigate object bbox #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f34eab9
Fixed navigate to object reference in navigation.py to use module not…
spomichter 1831d52
Removed non-module navigate to object impl, created new Bbox navigati…
spomichter ea30202
Added dotenv to envrc
spomichter a9078cc
Fix detection2d bug in decoding of message when subscribed
spomichter 5b31e95
Fully working minimal 2d object tracker
spomichter ab3b1e7
WIP: tracking stream still not working in foxglove. Changed tracked o…
spomichter 71b648b
Fully removed depth module from unitree go2
spomichter 4429190
Added stuck detection for 2d object tracker, fix frame copy bug over …
spomichter df14537
Added back multi step navigatewithtext
spomichter 86cdde9
Fix navigation tests
spomichter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # 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.core import Module, In, Out, rpc | ||
| from dimos.msgs.vision_msgs import Detection2DArray | ||
| from dimos.msgs.geometry_msgs import PoseStamped, Vector3, Quaternion | ||
| from dimos_lcm.sensor_msgs import CameraInfo | ||
| from dimos.utils.logging_config import setup_logger | ||
| import logging | ||
|
|
||
| logger = setup_logger(__name__, level=logging.DEBUG) | ||
|
|
||
|
|
||
| class BBoxNavigationModule(Module): | ||
| """Minimal module that converts 2D bbox center to navigation goals.""" | ||
|
|
||
| detection2d: In[Detection2DArray] = None | ||
| camera_info: In[CameraInfo] = None | ||
| goal_request: Out[PoseStamped] = None | ||
|
|
||
| def __init__(self, goal_distance: float = 1.0): | ||
| super().__init__() | ||
| self.goal_distance = goal_distance | ||
| self.camera_intrinsics = None | ||
|
|
||
| @rpc | ||
| def start(self): | ||
| self.camera_info.subscribe( | ||
| lambda msg: setattr(self, "camera_intrinsics", [msg.K[0], msg.K[4], msg.K[2], msg.K[5]]) | ||
| ) | ||
| self.detection2d.subscribe(self._on_detection) | ||
|
|
||
| def _on_detection(self, det: Detection2DArray): | ||
| if det.detections_length == 0 or not self.camera_intrinsics: | ||
| return | ||
| fx, fy, cx, cy = self.camera_intrinsics | ||
| center_x, center_y = ( | ||
| det.detections[0].bbox.center.position.x, | ||
| det.detections[0].bbox.center.position.y, | ||
| ) | ||
| x, y, z = ( | ||
| (center_x - cx) / fx * self.goal_distance, | ||
| (center_y - cy) / fy * self.goal_distance, | ||
| self.goal_distance, | ||
| ) | ||
| goal = PoseStamped( | ||
| position=Vector3(z, -x, -y), | ||
| orientation=Quaternion(0, 0, 0, 1), | ||
| frame_id=det.header.frame_id, | ||
| ) | ||
| logger.debug( | ||
| f"BBox center: ({center_x:.1f}, {center_y:.1f}) → " | ||
| f"Goal pose: ({z:.2f}, {-x:.2f}, {-y:.2f}) in frame '{det.header.frame_id}'" | ||
| ) | ||
| self.goal_request.publish(goal) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just going towards the target for self.goal_distance m. It is not using any sort of distance estimate of the target, this is a todo right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we need clean modules that are composable. This only vectors toward a bounding box
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The distance estimation is handled on @leshy side since he has ground truth object locations via his localization