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

Interface with external visualizer #11

Closed
diegoferigo opened this issue Sep 20, 2022 · 3 comments
Closed

Interface with external visualizer #11

diegoferigo opened this issue Sep 20, 2022 · 3 comments
Assignees

Comments

@diegoferigo
Copy link
Member

JAXsim for the time being does not include any GUI nor visualizer to show the simulated models. While prototyping, I used gazebosim/gz-gui part of Gazebo Sim, but I think it's a dependency too large that would make deployment quite challenging.

It would be quite interesting using gazebosim/gz-gui as standalone visualizer, but I never saw anything based on it.

Alternatively, rdeits/meshcat-python could be a valid and slim alternative, but in the past I couldn't manage to obtain acceptable performance in real-time usage. The problem is that all nodes (link poses) had to be refreshed individually. However, few months ago, duburcqa/jiminy#543 implemented a method to update all nodes together, and it's worth a try.

@diegoferigo
Copy link
Member Author

I created ami-iit/meshcat-viz-python to play with MeshCat, hoping to achieve better real-time performance by optimizing the client/server protocol that streams link transforms.

It would be also useful (but with much lower priority) being able to tweak the control menu of the web interface. I opened meshcat-dev/meshcat-python#128 for asking implementation details.

@flferretti
Copy link
Collaborator

As discussed F2F, the code relative to the visualization loop that allows to visualize the contact forces using meshcat-viz can be found in ami-iit/element_rl-for-codesign/.../hopper.py:

Visualization Loop
for t in range(len(x_t.base_position[0]))[::downsampling]:
    for env_id in range(len(model_names)):
        world.update_model(
            model_name=model_names[env_id],
            joint_names=model.joint_names(),
            joint_positions=x_t.joint_positions[env_id][t],
            base_position=x_t.base_position[env_id][t],
            base_quaternion=x_t.base_quaternion[env_id][t],
        )

        # Compute the forces expressed in the right frame for visualization
        CL_fc_ext = world_to_viz_contact_forces(
            model,
            x_t.base_position[env_id][t],
            x_t.base_quaternion[env_id][t],
            x_t.joint_positions[env_id][t],
            time_history[model.name()].aux["t0"]["contact_forces_points"][env_id][t],
        )[:, 0:3]

        # Update the visualized contact forces
        for idx, (CL_fc, name) in enumerate(zip(CL_fc_ext, parent_link_name)):
            contacts[env_id][f"{name}_{idx}"].force.set(force=np.array(CL_fc))

        rate.sleep()

@diegoferigo
Copy link
Member Author

I guess that we eventually converged towards the usage of the passive Mujoco viewer in #83. Closing.

@diegoferigo diegoferigo self-assigned this Mar 11, 2024
flferretti added a commit that referenced this issue Sep 11, 2024
…ock file (#11)

* Update `pixi` lockfile in CI

* Use uniquely named branches when opening PRs

* Install `pixi-diff-to-markdown` via `pixi`

* Fix TOML parse error in `pyproject.toml`

* Remove `--no-install` as incompatible with PyPI deps
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

No branches or pull requests

2 participants