compas-dev / compas_robots

Basic infrastructure for working with robots in COMPAS.
http://compas.dev/compas_robots/
MIT License
1 stars 4 forks source link

Something wrong with RobotModelObject for Viewer #17

Open yck011522 opened 1 month ago

yck011522 commented 1 month ago

I was trying out the compas_viewer with compas_fab at some point with the following code: Using latest main branch of compas_fab.

from compas_fab.robots import RobotLibrary
from compas_viewer import Viewer

viewer = Viewer()

robot = RobotLibrary.ur5(load_geometry=True)
model = robot.model

viewer.scene.add(model)
viewer.show()

This won't work and I've traced the problem down to a few lines in this file: \src\compas_robots\viewer\scene\robotmodelobject.py

https://github.com/compas-dev/compas_robots/blob/6df39febb487cf88ccc6e05bc75e9de8b4972353/src/compas_robots/viewer/scene/robotmodelobject.py#L128-L154

I had to change the following lines, I think they are typos.:

            linewidth=self.linewidth,
            pointsize=self.pointsize,

            context=self.context,
yck011522 commented 1 month ago

@ZacZhangzhuo Ping. I'm not familiar with this area of the code, I think you created this?

yck011522 commented 1 month ago

Also I find that RobotModelObject.update_joints() does not work, this line throws an error: https://github.com/compas-dev/compas_robots/blob/6df39febb487cf88ccc6e05bc75e9de8b4972353/src/compas_robots/viewer/scene/robotmodelobject.py#L173 Saying that there is no renderer.

My Code:

from compas_fab.robots import RobotLibrary
from compas_viewer import Viewer

viewer = Viewer()

robot = RobotLibrary.ur5(load_geometry=True)
model = robot.model

object = viewer.scene.add(model)
# object.update(robot.random_configuration())

object.update_joints(robot.random_configuration())
viewer.show()
gonzalocasas commented 1 month ago

Adding @tomvanmele and @Licini to the thread

yck011522 commented 1 month ago

@gonzalocasas @tomvanmele @Licini ping