Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add LogicalCameraImage support #698

Merged
merged 11 commits into from
Feb 24, 2025

Conversation

Dyst-0
Copy link
Contributor

@Dyst-0 Dyst-0 commented Feb 23, 2025

🎉 New feature

Closes #697

Summary

ros_gz_bridge now supports gz.msgs.LogicalCamera image <-> ros_gz_interfaces.msg.LogicalCameraImage.

Test it

Test gz to ros conversion

1: Run parameter_bridge for /logical_camera between gz and ros

ros2 run ros_gz_bridge parameter_bridge /logical_camera_image@ros_gz_interfaces/msg/LogicalCameraImage@gz.msgs.LogicalCameraImage

2: In a new terminal, run

ros2 topic echo /logical_camera

3: In another terminal, publish the message from gz

gz topic -t /logical_camera -m gz.msgs.LogicalCameraImage -p 'header: { stamp: { sec: 0, nsec: 0 }, data: [ { key: "frame_id", value: ["logical_camera"] } ] }, pose: { position: { x: 1.0, y: 2.0, z: 3.0 }, orientation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 } }, model: [ { name: "model_1", pose: { position: { x: 4.0, y: 5.0, z: 6.0 }, orientation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 } } },  { name: "model_2", pose: { position: { x: 7.0, y: 8.0, z: 9.0 }, orientation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 } } }]'

In the terminal listening to /logical_camera, the output should be

header:
  stamp:
    sec: 0
    nanosec: 0
  frame_id: logical_camera
pose:
  position:
    x: 1.0
    y: 2.0
    z: 3.0
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0
model:
- name: model_1
  pose:
    position:
      x: 4.0
      y: 5.0
      z: 6.0
    orientation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
- name: model_2
  pose:
    position:
      x: 7.0
      y: 8.0
      z: 9.0
    orientation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
---

Test ros to gz conversion

1: Run parameter_bridge for /logical_camera between gz and ros

ros2 run ros_gz_bridge parameter_bridge /logical_camera_image@ros_gz_interfaces/msg/LogicalCameraImage@gz.msgs.LogicalCameraImage

2: In another terminal, listen to the gz topic /logical_camera

gz topic -e -t /logical_camera

3: Publish the ros message

ros2 topic pub /logical_camera ros_gz_interfaces/msg/LogicalCameraImage \
"{header: {stamp: {sec: 0, nanosec: 0}, frame_id: 'logical_camera'}, \
pose: {position: {x: 1.0, y: 2.0, z: 3.0}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}, \
model: [{name: 'model_1', pose: {position: {x: 4.0, y: 5.0, z: 6.0}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}}, \
{name: 'model_2', pose: {position: {x: 7.0, y: 8.0, z: 9.0}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}}]}" --once

In the terminal listening to /logical_camera, the output should be

header {
  stamp {
  }
  data {
    key: "frame_id"
    value: "logical_camera"
  }
}
pose {
  position {
    x: 1
    y: 2
    z: 3
  }
  orientation {
    w: 1
  }
}
model {
  name: "model_1"
  pose {
    position {
      x: 4
      y: 5
      z: 6
    }
    orientation {
      w: 1
    }
  }
}
model {
  name: "model_2"
  pose {
    position {
      x: 7
      y: 8
      z: 9
    }
    orientation {
      w: 1
    }
  }
}

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@Dyst-0 Dyst-0 requested a review from ahcorde as a code owner February 23, 2025 02:20
@Dyst-0
Copy link
Contributor Author

Dyst-0 commented Feb 23, 2025

Apologies for the commit mess.

@Dyst-0 Dyst-0 force-pushed the add-logical-camera-image-support branch from 46527fe to 1472604 Compare February 23, 2025 14:56
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
Implemented convert_ros_to_gz and convert_gz_to_ros for LogicalCameraImage.

Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
Documented support for bridging LogicalCameraImage

Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
auto* --> auto *

Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
@Dyst-0 Dyst-0 force-pushed the add-logical-camera-image-support branch from f94ab55 to f8484e3 Compare February 23, 2025 15:14
Copy link
Collaborator

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

corrected member name to "model" instead of "models"

Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
@Dyst-0 Dyst-0 force-pushed the add-logical-camera-image-support branch from 95fa986 to bb83151 Compare February 24, 2025 10:56
removed trailing whitespace

Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
changed int to size_t to avoid sign-compare warning

Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
@Dyst-0 Dyst-0 requested a review from ahcorde February 24, 2025 12:33
@ahcorde ahcorde merged commit 16fbab4 into gazebosim:ros2 Feb 24, 2025
4 checks passed
@Dyst-0
Copy link
Contributor Author

Dyst-0 commented Feb 24, 2025

@ahcorde can this be backported to jazzy?

@ahcorde
Copy link
Collaborator

ahcorde commented Feb 24, 2025

https://github.com/Mergifyio backport jazzy

Copy link
Contributor

mergify bot commented Feb 24, 2025

backport jazzy

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Feb 24, 2025
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
(cherry picked from commit 16fbab4)
ahcorde pushed a commit that referenced this pull request Feb 24, 2025
Signed-off-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
(cherry picked from commit 16fbab4)

Co-authored-by: Dyst-0 <69257845+Dyst-0@users.noreply.github.com>
@Dyst-0 Dyst-0 deleted the add-logical-camera-image-support branch February 24, 2025 17:15
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Support bridging gz.msgs.LogicalCameraImage to ROS
2 participants