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

[viewer] Enable changing color for list visual mesh #283

Merged
merged 1 commit into from
Oct 31, 2023
Merged

[viewer] Enable changing color for list visual mesh #283

merged 1 commit into from
Oct 31, 2023

Conversation

iory
Copy link
Owner

@iory iory commented Jan 11, 2023

Since visual_mesh is a list, it does not change even if you change the color of mesh, so I changed it to change.

from skrobot.viewers import TrimeshSceneViewer
from skrobot.models import PR2
import numpy as np



v = TrimeshSceneViewer()
r = PR2()
v.add(r)
v.show()

color = [255, 0, 0, 200]
for link in r.find_link_path(r.rarm_root_link, r.r_gripper_l_finger_tip_link) + r.find_link_path(r.rarm_root_link, r.r_gripper_r_finger_tip_link):
    if hasattr(link, '_visual_mesh') and isinstance(link._visual_mesh, list):
        if len(link._visual_mesh) == 0:
            continue
        m = link._visual_mesh[0]
    else:
        continue
    n_facet = len(m.visual.face_colors)
    m.visual.face_colors =  np.array([color] * n_facet)

image

@iory iory merged commit fa467e7 into master Oct 31, 2023
6 checks passed
@iory iory deleted the viewer branch October 31, 2023 15:45
@iory
Copy link
Owner Author

iory commented Jan 7, 2024

Please use set_color method to change link color
#338

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.

1 participant