8000 Add 3d visualization for Frame3d by pascalzauberzeug · Pull Request #268 · zauberzeug/rosys · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add 3d visualization for Frame3d #268

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 4 commits into from
Mar 28, 2025
Merged

Add 3d visualization for Frame3d #268

merged 4 commits into from
Mar 28, 2025

Conversation

pascalzauberzeug
Copy link
Contributor

I want to share Frame3dSceneObject that I built for easier debugging of 3d frames. You only need nicegui's 3d scene and a Frame3d, nothing else is needed and they update their positions themselves.

Here I modified the camera arm example

Screen.Recording.2025-03-25.at.19.13.49.mov

I replaced the given page function

8000
def page():
def update_scene():
chassis.move(*odometer.prediction_frame.resolve().translation)
chassis.rotate_R(odometer.prediction_frame.resolve().rotation.R)
segment1.move(*arm1.base.resolve().translation)
segment1.rotate_R(arm1.base.resolve().rotation.R)
segment2.move(*arm2.base.resolve().translation)
segment2.rotate_R(arm2.base.resolve().rotation.R)
camera_box.move(*cam.pose.resolve().translation)
camera_box.rotate_R(cam.pose.resolve().rotation.R)
ui.timer(config.ui_update_interval, update_scene)
keyboard_control(steerer)
with ui.row():
with ui.scene() as scene:
with scene.group() as chassis:
scene.box(width=1.0, height=0.5, depth=0.3).move(z=0.15).material(color='gray')
with scene.group() as segment1:
scene.box(width=0.1, height=0.1, depth=arm1.length).move(z=arm1.length / 2)
with scene.group() as segment2:
scene.box(width=0.1, height=0.1, depth=arm2.length).move(z=arm2.length / 2)
with scene.group() as camera_box:
scene.box(width=0.1, height=0.1, depth=0.1).material(color='SteelBlue')
scene.move_camera(y=-2, z=2)
with ui.column():
joystick(steerer, size=50, color='blue')
ui.slider(min=-math.pi / 2, max=math.pi / 2, step=0.01, value=0, on_change=lambda e: arm1.pitch(e.value))
ui.slider(min=-math.pi / 2, max=math.pi / 2, step=0.01, value=0, on_change=lambda e: arm2.pitch(e.value))
ui.slider(min=-math.pi / 4, max=math.pi / 4, step=0.01, value=0, on_change=lambda e: cam.pitch(e.value))

with this:

def page():
    keyboard_control(steerer)
    with ui.row():
        with ui.scene() as scene:
            scene.move_camera(y=-2, z=2)
            frame_3d_object(anchor_frame)
            frame_3d_object(arm1.base, name='Arm 1 Base')
            frame_3d_object(arm2.base, name='Arm 2 Base')
            frame_3d_object(cam.pose, name='Camera')

        with ui.column():
            joystick(steerer, size=50, color='blue')
            ui.slider(min=-math.pi / 2, max=math.pi / 2, step=0.01, value=0, on_change=lambda e: arm1.pitch(e.value))
            ui.slider(min=-math.pi / 2, max=math.pi / 2, step=0.01, value=0, on_change=lambda e: arm2.pitch(e.value))
            ui.slider(min=-math.pi / 4, max=math.pi / 4, step=0.01, value=0, on_change=lambda e: cam.pitch(e.value))

@pascalzauberzeug pascalzauberzeug added the enhancement New feature or request label Mar 25, 2025
@pascalzauberzeug pascalzauberzeug added this to the 0.23.0 milestone Mar 25, 2025
@pascalzauberzeug pascalzauberzeug self-assigned this Mar 25, 2025
@NiklasNeugebauer
Copy link
Contributor

I like that this derives from group, makes it versatile to be use with custom models.

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a 3D visualization component for debugging frame positions. It adds a new Frame3dSceneObject class that leverages nicegui's 3D scene capabilities and registers an update loop, and re-exports it as frame_3d_object for simpler usage in the UI.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rosys/geometry/pose3d.py Added Frame3dSceneObject to display 3D axes and update its position in real-time.
rosys/geometry/init.py Re-exported Frame3dSceneObject as frame_3d_object for easy access.

@falkoschindler falkoschindler self-requested a 8000 review March 27, 2025 12:26
- update "camera arm" example to use new frame object
- rename class for consistency with exported name
- add docstring
- slightly reformat code for symmetry
Copy link
Contributor
@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

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

@pascalzauberzeug I just reviewed your code and just made a few minor changes and added the new object to the "camera arm" example. In my point of view, there are only two open questions:

  • Is there a better name than Frame3dObject? I could imagine naming it AxesObject or CoordinateAxes.
  • The default length of 0.15 seems a bit arbitrary. I tend to set a default of 1.0 and adjust it in user code if needed.

What do you think?

@pascalzauberzeug
Copy link
Contributor Author

@falkoschindler to throw a third one in, how about FrameAxes? I don't like the "Object" names, but they are used throughout the code and clearly show that it is an object for the 3d scene. So we probably should stick to it.

Well, it is arbitrary but perhaps more fitting for visualizing real world 3d objects than 1.0m. If you use your hands, it should be more like 0.1m. But from a code perspective, it should be 1.0m, yes

@NiklasNeugebauer
Copy link
Contributor
NiklasNeugebauer commented Mar 28, 2025

Regarding the name:
I saw this also as an option to simply pin a 3D representation of an object to a frame.
In the robot arm example we could replace the update step entirely with this.

In this case Frame3dObject would work well.
Maybe, this is not the best API for this kind of usage though and so keeping it named for the intended use is better.

@falkoschindler falkoschindler merged commit 5be6452 into main Mar 28, 2025
5 checks passed
@falkoschindler falkoschindler deleted the frame_3d_object branch March 28, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0