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

Feature/robot object #74

Merged
merged 14 commits into from
Mar 1, 2024
Merged

Feature/robot object #74

merged 14 commits into from
Mar 1, 2024

Conversation

ZacZhangzhuo
Copy link
Collaborator

@ZacZhangzhuo ZacZhangzhuo commented Feb 29, 2024

Major Changes

  • Added RobotModelObject and its example in the documentation. the RobotModelObject class is the main focus of this PR.

Minor Changes

  • Documentation images and code correction.
  • Improved typing hints of CollectionObject.

2024-02-02-29-15-58-43

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image update of the documentation.

Copy link
Collaborator Author

@ZacZhangzhuo ZacZhangzhuo Feb 29, 2024

Choose a reason for hiding this comment

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

just the example code correction. not the review focus.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just the example code correction. not the review focus.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file should be the focus of the review. Following the logic of compas_robots, we create the robot being viewed in the viewer. related to @gonzalocasas and compas-dev/compas_robots#2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the example file for the RobotModelObject class.

@ZacZhangzhuo ZacZhangzhuo self-assigned this Feb 29, 2024
@ZacZhangzhuo ZacZhangzhuo added the enhancement New feature or request label Feb 29, 2024

for obj in objs:
if isinstance(obj, CollectionObject):
[sort(item) for item in obj.items]
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you do this, doesn't it mean the objects of the collection are then drawn separately instead of the combined one, hence not benefit from the performance boost of using single combined buffer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need this sorting function to match the category of the object and the corresponding shader. If the CollectionObject contains different objects, i.e. a mesh with a tag, the code will fail if we don't sort them.

Yet, this function is cached by lru_cache, meaning it will not be called every frame if the inputs are the same.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you get my point yet. In the past in view2, the Collection object is not just a group. It was created more for performance reasons. When you have many separated objects, because they all have independent buffers, they are rendered sequentially rather than in parallel in GPU. The reason to have CollectionObject is to join seperate object buffers (points, lines, faces) into a one big buffer. That's what _read_xxx_data in CollectionObject is doing, so they can be feed into GPU in one go. We were also able to combine different object types because almost all objects inherented from BufferObject except TextObject. The way you are using it now is taking the sub-objects out and skipping the buffer combination.


return mesh_object

def update(self, joint_state: Optional[Configuration] = None, update_buffers: bool = False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel a bit strange here to allow to supply a joint_state into the update function. This makes it misaligned from the update of other objects. I would create a separated function and call it update_joints

src/compas_viewer/viewer.py Outdated Show resolved Hide resolved
@ZacZhangzhuo ZacZhangzhuo mentioned this pull request Mar 1, 2024
@ZacZhangzhuo ZacZhangzhuo mentioned this pull request Mar 1, 2024
@ZacZhangzhuo
Copy link
Collaborator Author

Since @tomvanmele suggested we put the robotmodelobject in the compas_robots repo, I have migrated the pr into compas-dev/compas_robots#13 for review.

there are still some very small changes in this pr so I will just go ahead and merge it. #77 and #76 are created separately for future improvement.

@ZacZhangzhuo ZacZhangzhuo reopened this Mar 1, 2024
@ZacZhangzhuo ZacZhangzhuo merged commit f8dd7e8 into main Mar 1, 2024
12 of 13 checks passed
@ZacZhangzhuo ZacZhangzhuo deleted the feature/robot-object branch March 1, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants