When I reproduced gcs-science-robotics in the latest version of drake and ran prm_comparison.ipynb
, I met this problem.
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_16980/4066659220.py in <module>
----> 1 visualize_trajectory(meshcat, [linear_gcs_traj],
2 show_path=True,
3 robot_configurations=execute_task,
4 transparency=0.3)
~/lhc-gcs-science-robotics/reproduction/prm_comparison/helpers.py in visualize_trajectory(meshcat, trajectories, show_path, robot_configurations, transparency, regions)
246
247 # Set transparency of main arm and gripper.
--> 248 set_transparency_of_models(plant,
249 [iiwa.model_instance, wsg.model_instance],
250 transparency, scene_graph)
~/lhc-gcs-science-robotics/reproduction/prm_comparison/helpers.py in set_transparency_of_models(plant, model_instances, alpha, scene_graph)
122 Role.kIllustration):
123 properties = inspector.GetIllustrationProperties(geometry_id)
--> 124 phong = properties.GetProperty("phong", "diffuse")
125 phong.set(phong.r(), phong.g(), phong.b(), alpha)
126 properties.UpdateProperty("phong", "diffuse", phong)
RuntimeError: GetProperty(): Trying to read property ('phong', 'diffuse'), but the group does not exist.
then I found that properties
group name was '__default__'
.
I want to know that if API changed what should I do to change the transparency of models.
When I reproduced gcs-science-robotics in the latest version of drake and ran prm_comparison.ipynb
, I met this problem.
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_16980/4066659220.py in <module>
----> 1 visualize_trajectory(meshcat, [linear_gcs_traj],
2 show_path=True,
3 robot_configurations=execute_task,
4 transparency=0.3)
~/lhc-gcs-science-robotics/reproduction/prm_comparison/helpers.py in visualize_trajectory(meshcat, trajectories, show_path, robot_configurations, transparency, regions)
246
247 # Set transparency of main arm and gripper.
--> 248 set_transparency_of_models(plant,
249 [iiwa.model_instance, wsg.model_instance],
250 transparency, scene_graph)
~/lhc-gcs-science-robotics/reproduction/prm_comparison/helpers.py in set_transparency_of_models(plant, model_instances, alpha, scene_graph)
122 Role.kIllustration):
123 properties = inspector.GetIllustrationProperties(geometry_id)
--> 124 phong = properties.GetProperty("phong", "diffuse")
125 phong.set(phong.r(), phong.g(), phong.b(), alpha)
126 properties.UpdateProperty("phong", "diffuse", phong)
RuntimeError: GetProperty(): Trying to read property ('phong', 'diffuse'), but the group does not exist.
then I found that properties
group name was '__default__'
.
I want to know that if API changed what should I do to change the transparency of models.
1 Answer
Reset to default 0I believe the error comes from the fact that your plant has geometries with an Illustration
role, but they don't already have the ("phong", "diffuse")
property assigned.
Specifically, set_transparency_of_models()
is assuming that the property has already been assigned (so it simply calls GetProperty()
). When the property doesn't already exist, it blows up as you've observed.
So, there are two ways to resolve this:
Make sure that every geometry in your plant with the
IllustrationRole
has the expected property assigned, and/orModify the code in question so that instead of calling
GetProperty()
it callsGetPropertyOrDefault()
and have the function provide a defaultRgba
to use in the absence of a pre-assigned diffuse color.