Pixel to world - #504
Open
yfshaikh wants to merge 12 commits into
Open
Conversation
yfshaikh
marked this pull request as draft
July 14, 2026 12:30
…improve argument handling. Update main function to reflect changes in request parameters and enhance usage instructions.
…ansformation. Added methods to retrieve camera info and store the latest LiDAR cloud. Updated transformation logic to handle new parameters and improve error handling.
yfshaikh
marked this pull request as ready for review
July 17, 2026 23:08
Resolve launch_node_definitions.py by keeping keyboard_controller and dev's new launch node definitions. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
pixel_to_worldtoframe_tf_service(srv flag + client + optional pixel overlay).world_to_pixel(correct camera-frame projection, TF handling, and float64 serialization).(u, v)alone is underdetermined: with camera pose it defines a ray, so we need depth.map.Conventions
Camera optical frame:
+Xright,+Ydown,+Zforward.Intrinsics from
CameraInfo.k:fx, fy, cx, cy.Algorithm —
pixel_to_worldmap.z_c <= 0/ off-image projections.u = fx·x_c/z_c + cx,v = fy·y_c/z_c + cy.(u,v)withinMAX_PIXEL_RADIUS(tie-break by smallerz_c).float64bytes), ortf_success=falseif none.Note: this returns a measured LiDAR point near the query pixel (nearby-ray association), not an exact intersection of the query ray with a surface.
Algorithm —
world_to_pixelCameraInfoforcamera_name; useheader.frame_idas the camera frame.p_cam = R · P_map + t(lookup_transform(camera, map, …)).z_c <= 0).u = fx·x_c/z_c + cx,v = fy·y_c/z_c + cy.(u, v)asfloat64bytes, ortf_success=falseon failure.Fixes vs the starter code: one TF lookup (no hang loop), project
p_cam(not raw map XYZ),Rm.apply(...)for the rigid transform, stamp0/0→ latest TF, andnp.asarray([u,v], float64).tobytes()instead ofbytes(coords).Camera name → RViz image topic (this stack)
camera_namergb_front/cameras/camera0rgb_right/cameras/camera1rgb_back/cameras/camera2rgb_left/cameras/camera3rgb_centermay have 0 publishers — usergb_frontfor the main camera.Test plan —
pixel_to_worldRequires CARLA +
carla_interface/ bridge + navigator (launch.carla.py), sameROS_DOMAIN_ID.1. Build
2. Confirm sensors
3. Start service and wait for data
# terminal A ros2 run frame_tf_service serviceWait until logs show CameraInfo + LiDAR ready (status should move off
NO). Do not call the client before that.Sensor subscriptions use Best Effort (and Reliable fallback); without matching QoS the node stays at
No CameraInfo yet.4. Basic client checks
Client args:
cam_to_world cam_to_pixel world_to_pixel pixel_to_world camera_name x y zFor
pixel_to_world,x,y=u,v.5. Visual check (overlay + map marker)
# mark the query pixel on the camera image ros2 run frame_tf_client overlay 400 350 rgb_frontIn RViz:
/pixel_query_overlay(red crosshair = queried pixel)map/lidar(Reliability: Best Effort if the display shows 0 msgs)Drop the returned XYZ as a marker:
Add → Marker, topic
/pixel_to_world_debug.Pass criteria: crosshair sits on a surface in the image (e.g. road); red sphere sits on that same surface in the map/LiDAR view. The sphere is 3D — it will not appear on the image.
6. Other cameras
ros2 run frame_tf_client overlay 400 350 rgb_left ros2 run frame_tf_client client 0 0 0 1 rgb_left 400.0 350.0 0.0 # optional: new marker with id: 1Side cameras may return
falsemore often (fewer LiDAR hits in view).Checklist
/lidar+/carla/hero/rgb_front/camera_infopublishingtf_success: truetf_success: falsergb_left/rgb_right/rgb_backTest plan —
world_to_pixelIdea
Given a map XYZ known to be in front of the camera, project it to image pixels and confirm
(u, v)land on the expected feature.Smoke checks
Client args:
cam_to_world cam_to_pixel world_to_pixel pixel_to_world camera_name x y zFor
world_to_pixel,x,y,z= map XYZ.Behind-camera / bad TF should return
tf_success: falsewithout hanging.Checklist
world_to_pixelreturns without hangingtf_success: trueand two floats(u, v)tf_success: falseTest plan — consistency (
pixel_to_world↔world_to_pixel)These two services are inverses in intent but not bit-exact inverses:
pixel_to_worldreturns a nearby LiDAR return, not the exact ray–surface intersection. A few pixels of round-trip error is expected and OK.Round-trip: pixel → world → pixel
world_to_pixel.(u', v')to the original(u, v).Pass criteria
tf_success: trueboth ways).|u'−u|and|v'−v|are small (typically within a few pixels; association radius / depth discreteness set the floor).(u', v')sits on the same scene feature as the original query (e.g. same road patch).Optional: world → pixel → world (sanity)
If you start from a known map point that is a LiDAR return visible in the camera,
world_to_pixelthenpixel_to_worldshould land near that same 3D location (meters, not necessarily exact — NN association again).Checklist
pixel_to_world(u,v)→ map XYZ succeedsworld_to_pixel(XYZ)→(u',v')succeeds(u',v')within a few px of(u,v)(u',v')matches the same image feature as(u,v)