Skip to content
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

Add frame visualization to Meshcat visualizer #2098

Merged
merged 7 commits into from
Nov 26, 2023

Conversation

sea-bass
Copy link
Contributor

@sea-bass sea-bass commented Nov 25, 2023

This PR adds frame visualization to the Meshcat visualizer -- the use case here is for some educational content I'm making where I will start with a pure model that has no visual or collision models, and I still want the frames to show up. But I also think it would generally be useful to have this available.

Frame visualization is False by default to not change behavior for users.

The repro case for the animation below looks roughly like this right now:

viz = MeshcatVisualizer(model, collision_model, visual_model, data=data)
viz.initViewer(open=True)
viz.loadViewerModel()
viz.displayFrames(True)  # Default args
viz.displayFrames(True, frame_ids=[10, 11, 12], axis_length=0.2, axis_width=2)  # Optional args
# You can also call viz.initializeFrames() with the same keyword args as above if you want to
# reinitialize frame visualizations with new options, without toggling visibility.

q = pinocchio.randomConfiguration(model)
v = np.zeros_like(q)
tau = np.zeros_like(q)

for i in range(100):
    a1 = pinocchio.aba(model, data, q, v, tau)
    vnext = v + dt * a1
    qnext = pinocchio.integrate(model, q, dt * vnext)

    viz.display(qnext)

    q = qnext
    v = vnext
    time.sleep(dt)
2023-11-25.12-29-47.mp4

@hrp2-14
Copy link

hrp2-14 commented Nov 25, 2023

Hi ! This project doesn't usually accept pull requests on the main branch.
If this wasn't intentionnal, you can change the base branch of this PR to devel
(No need to close it for that). Best, a bot.

@sea-bass sea-bass changed the base branch from master to devel November 25, 2023 17:40
@sea-bass sea-bass requested a review from nim65s November 25, 2023 19:27
nim65s
nim65s previously approved these changes Nov 26, 2023
Copy link
Contributor

@nim65s nim65s left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for adding this useful feature !

I guess we could add parameters in loadViewerModel to let the user define if they want to display collisions, visuals, and/or frames or not, but this is out of the scope of this PR, and would better be consistently applied on all viewers.

jcarpent
jcarpent previously approved these changes Nov 26, 2023
@jcarpent jcarpent dismissed stale reviews from nim65s and themself via a109f14 November 26, 2023 11:03
jcarpent
jcarpent previously approved these changes Nov 26, 2023
Copy link
Contributor

@jcarpent jcarpent left a comment

Choose a reason for hiding this comment

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

Thanks @sea-bass for this very helpful contribution.

@jcarpent jcarpent merged commit fb0cd56 into stack-of-tasks:devel Nov 26, 2023
12 checks passed
nim65s added a commit to nim65s/robotpkg that referenced this pull request Dec 1, 2023
    ## [2.6.21] - 2023-11-27

    ### Added

    - Add inverse dynamics (`rnea`) Python and C++ example ([2083](stack-of-tasks/pinocchio#2083))
    - Add visualization of Frames in MeshCat viewer ([2098](stack-of-tasks/pinocchio#2098))

    ### Fixed

    - Re-initialize `Ycrb[0]` in `crbaMinimal` ([2040](stack-of-tasks/pinocchio#2040))
    - Fix custom scalar use in `log` function ([2047](stack-of-tasks/pinocchio#2047))
    - Raise exception on wrong input size in `XYZQUATToSE3` Python binding function ([2073](stack-of-tasks/pinocchio#2073))
    - Remove memory leak in `buildGeomFromUrdf` and `buildGeomFromUrdfString` Python binding functions ([2082]()stack-of-tasks/pinocchio#2082)
    - Fix Panda3D viewer examples ([2087](stack-of-tasks/pinocchio#2087))
    - Fix centroidal dynamics derivatives with respect to time ([2094](stack-of-tasks/pinocchio#2094)))

    ### Changed

    - Rename freeflyer_joint to root_joint in `humanoid` sample model ([2043](stack-of-tasks/pinocchio#2043))
    - CMake minimal version is now 3.10 ([2055](stack-of-tasks/pinocchio#2055))
    - Split headers and sources in different directories to have a more standard C++ project ([2070](stack-of-tasks/pinocchio#2070))

    ### Removed

    - Remove support to `hpp-fcl` < v2.0.0 ([2086](stack-of-tasks/pinocchio#2086))

    ## Packaging changes

    - removed patches ad, ae: fixed upstream 🎉
    - updated patches af, ah, an
    - added patch ao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants