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

Robot Object for compas_viewer #2

Open
ZacZhangzhuo opened this issue Jan 7, 2024 · 2 comments
Open

Robot Object for compas_viewer #2

ZacZhangzhuo opened this issue Jan 7, 2024 · 2 comments

Comments

@ZacZhangzhuo
Copy link
Contributor

ZacZhangzhuo commented Jan 7, 2024

compas_viewer is ready to connect compas_robots for visualizing the robot.

Since I saw the main updates are in the refactor_2.0 branch and not merged into main, I thought it would be great to create an issue to discuss first before it is prepared.

The template would be like;

from compas_viewer.scene.meshobject import MeshObject

class RobotObject(??MeshObject??):
    """Object for displaying COMPAS RobotModel.    """

    def __init__(self, robot, **kwargs):

    def _read_points_data(self) -> Optional[DataType]:
        """Read points data from the object."""
        pass


    def _read_lines_data(self) -> Optional[DataType]:
        """Read lines data from the object."""
        pass

    def _read_frontfaces_data(self) -> Optional[DataType]:
        """Read frontfaces data from the object."""
        pass

    def _read_backfaces_data(self) -> Optional[DataType]:
        """Read backfaces data from the object."""
        pass

Would also be great if you could point out where is the entry that I should connect :)

@gonzalocasas
Copy link
Member

gonzalocasas commented Jan 7, 2024

Good idea, the robot model objects to support Scene are relatively simple to create. Most of the heavy lifting is done in a base class that works independent of CAD (the compas_robots.scene.BaseRobotModelObject), it handles all the things transforming the links of the robot to match the configuration, and so on, so, to add support for a new viewer or CAD, there are only a couple of methods needed that are defined by AbstractRobotModelObject:

class AbstractRobotModelObject(object):
    def transform(self, geometry, transformation):
        raise NotImplementedError

    def create_geometry(self, geometry, name=None, color=None):
        raise NotImplementedError

so, we just need to have a method to create native geometry in the target visualization tool, and one to natively transform geometry.

The RobotModelObject for ghpython is a good example of this because it is simple to understand.

In the end, due to the methods inherited from the base class, the robot model scene objects end up having the following relevant methods (related to your template): draw_visual, draw_collision, draw_attached_meshes.

@yck011522
Copy link
Contributor

@ZacZhangzhuo Is this issue already been resolved? It seems the PR is merged

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

3 participants