Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Fixed bug in `compas_viewer` due to import of `RobotModelObject` inside registration function.
* Fixed a double transformation issue with `RobotModelObject` for `compas_viewer>=1.4.0`.

### Removed

Expand Down
23 changes: 13 additions & 10 deletions src/compas_robots/viewer/scene/robotmodelobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def show_visual(self, value: bool):
if value == self._show_visual:
return
self._show_visual = value
parent = self
for i, visual_object in enumerate(self.visual_objects):
if value:
parent = self
if i > 0:
parent = self.visual_objects[i - 1]
# NOTE: This is a workaround to avoid double transformation issue with latest version of `compas_viewer`.
# if i > 0:
# parent = self.visual_objects[i - 1]
self.scene.add(visual_object, parent)
self.scene.instance_colors[visual_object.instance_color.rgb255] = visual_object
else:
Expand All @@ -91,12 +92,13 @@ def show_collision(self):
def show_collision(self, value: bool):
if value == self._show_collision:
return
parent = self
self._show_collision = value
for i, collision_object in enumerate(self.collision_objects):
if value:
parent = self
if i > 0:
parent = self.visual_objects[i - 1]
# NOTE: This is a workaround to avoid double transformation issue with latest version of `compas_viewer`.
# if i > 0:
# parent = self.visual_objects[i - 1]
self.scene.add(collision_object, parent)
self.scene.instance_colors[collision_object.instance_color.rgb255] = collision_object
else:
Expand All @@ -113,8 +115,9 @@ def add_objects(objects, show_flag):
for i, obj in enumerate(objects):
obj.init()
if show_flag:
if i > 0:
parent = objects[i - 1]
# NOTE: This is a workaround to avoid double transformation issue with latest version of `compas_viewer`.
# if i > 0:
# parent = objects[i - 1]
self.viewer.scene.add(obj, parent)
self.viewer.scene.instance_colors[obj.instance_color.rgb255] = obj
Comment on lines +119 to 122
Copy link
Member

Choose a reason for hiding this comment

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

Even though it's (likely) a temporary fix, we should drop a quick comment in here explaining why this is like it is now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I totally forgot about this PR until @chenkasirer reminded me today


Expand Down Expand Up @@ -160,10 +163,10 @@ def update_joints(self, joint_state: Configuration):

if self.show_visual:
for obj in self.visual_objects:
obj._update_matrix()
obj.update()

if self.show_collision:
for obj in self.collision_objects:
obj._update_matrix()
obj.update()

self.viewer.renderer.update()