Visualize robot Rhino 8

Hello Compas,

it seems I can’t have this basic example file to run in Rhino 8. I only tested Version 8 SR9 (8.9.24194.18121, 2024-07-12).

Here a list of the exceptions I get for the different installations of compas_fab:

IronPython, installed via conda-forge.

Message: init() takes exactly 2 arguments (4 given)
Traceback:
line 107, in add, “C:\Users\xyz\anaconda3\envs\compas-dev\Lib\site-packages\compas\scene\scene.py”
line 16, in , “C:\Users\xyz\AppData\Local\Temp\TempScript.py”

Cpython, installed with pip from ./rhinocode/py39-rh8

Traceback (most recent call last):
File “file:///C:/Users/xyz/.rhinocode/stage/eo44qpbf.lzk”, line 16, in
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\scene.py”, line 107, in add
sceneobject = SceneObject(item=item, context=self.context, **kwargs) # type: ignore
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\sceneobject.py”, line 88, in new
sceneobject_cls = get_sceneobject_cls(item, **kwargs)
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 152, in get_sceneobject_cls
cls = _get_sceneobject_cls(item, **kwargs)
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 140, in _get_sceneobject_cls
raise SceneObjectNotRegisteredError(“No scene object is registered for this data type: {} in this context: {}”.format(dtype, context_name))
SceneObjectNotRegisteredError: No scene object is registered for this data type: <class ‘compas_robots.model.robot.RobotModel’> in this context: Rhino

Cpython, installed via conda-forge

ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.

Any suggestion on how to approach this?
Or am I missing other official methods for visualizing a .urdf in Rhino8 ?

Thanks,
Marco

Hello Marco,

I can reproduce your problem.
I believe there is a bug in compas_robot, but first, I need to confirm with Gonzalo.

In the meantime, if you want to give it a try. go to the compas_robot installation folder, open the following file : src\compas_robots\rhino\scene\robotmodelobject.py In line 34, it should be
super(RobotModelObject, self).__init__(model=model, **kwargs)
change that to
super(RobotModelObject, self).__init__(item=model, **kwargs)

Then run the demo file in Rhino (Tools → PythonScript → Edit). This worked for me. The second execution method of running the file in cpython outside Rhino will not work if your intention is to visualize that in Rhino.

Hello,

that still produces the following error, from both RhinoScript editor and from Grasshopper Python editor:

Traceback (most recent call last):
File “file:///C:/Users/frist/Desktop/test.py”, line 16, in
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\scene.py”, line 115, in add
sceneobject = SceneObject(item=item, context=self.context, **kwargs) # type: ignore
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\sceneobject.py”, line 88, in new
sceneobject_cls = get_sceneobject_cls(item, **kwargs)
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 152, in get_sceneobject_cls
cls = _get_sceneobject_cls(item, **kwargs)
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 140, in _get_sceneobject_cls
raise SceneObjectNotRegisteredError(“No scene object is registered for this data type: {} in this context: {}”.format(dtype, context_name))
SceneObjectNotRegisteredError: No scene object is registered for this data type: <class ‘compas_robots.model.robot.RobotModel’> in this context: Rhino

Thanks,
Marco

1 Like

Hi!
I am having the same issue (error messages, etc.) with Rhino 7. The fix you, @yck011522, provided unfortunately didn’t resolve it either and I still get the same error messages. Is there anything else I could try to fix it or is there maybe coming an update soon?
Any help would be appreciated!

Thanks in advance,
Alicia

Hi Alicia,

I can smoothly load and visualize a robot in Rhino 7 with Compas_Fab version 0.27.
Maybe you can try that for the time being.

Best,
Marco

1 Like

Hi Alicia, do you mind provide me with a more detailed description of your system config so I can reproduce your problem? Below is a template, see if you can provide me with whatever is relevant for you:

Describe the bug

Add a clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Context [e.g. Rhino 5, Rhino 6, Blender, Grasshopper…]
  2. Sample script
  3. Sample data
  4. See error

Expected behavior

Add a clear and concise description of what you expected to happen.

Screenshots

Add screenshots to help explain your problem (if applicable).

Desktop (please complete the following information):

  • OS: [e.g. Windows 10]
  • Python version [e.g. 3.7]
  • Python package manager [e.g. pip, conda]

Additional context

Add any other context about the problem here.

Hi Viktor,

Thanks for the reply! I am using Rhino 7 on windows 11 and if I try tor run eg. this script in Rhino (Rhino Python Editor) which I found in the compas_fab documentation:

from compas_fab.backends import RosClient
from compas.scene import Scene

with RosClient() as ros:
    # Load complete model from ROS
    robot = ros.load_robot(load_geometry=True, precision=12)

    # Visualize robot
    scene = Scene()
    scene_object = scene.add(robot.model)
    scene.draw()

I get the following error:

Message: init() takes exactly 2 arguments (4 given)

Traceback:
line 116, in add, “C:\Users\alici\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\scene\scene.py”
line 10, in , “C:\Users\alici\AppData\Local\Temp\TempScript.py”

I am guessing there is some issue with the robotmodelobject, because the add function in the scene class doesn’t work with the robot.model. I tried with eg. a box and the visualization worked, just not with the robot.
Also thank you @Marco_Palma, I tried with the compas_fab version 0.27.0 and the visualization worked!

If you, @yck011522 need any more info, please let me know.

thanks for your help,
Alicia

Hi Viktor,

here a better description of my issue, with the latest Rhino and Compas_Fab installations:

Bug
Error visualizing a RobotModel in Rhino

To Reproduce

  1. Rhino 8 SR11 (8.11.24254.15001, 2024-09-10)
  2. Sample script
  3. Error:
Traceback (most recent call last):
  File "file:///C:/Users/frist/.rhinocode/stage/newwjb1i.yqv", line 16, in <module>
  File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\scene.py", line 115, in add
    sceneobject = SceneObject(item=item, context=self.context, **kwargs)  # type: ignore
  File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\sceneobject.py", line 88, in __new__
    sceneobject_cls = get_sceneobject_cls(item, **kwargs)
  File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py", line 152, in get_sceneobject_cls
    cls = _get_sceneobject_cls(item, **kwargs)
  File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py", line 140, in _get_sceneobject_cls
    raise SceneObjectNotRegisteredError("No scene object is registered for this data type: {} in this context: {}".format(dtype, context_name))
SceneObjectNotRegisteredError: No scene object is registered for this data type: <class 'compas_robots.model.robot.RobotModel'> in this context: Rhino

GH Robot Object registered.

Expected behavior
Visualize a RobotModel in Rhino 8.

Note
The same error triggers when replacing line 34 in src\compas_robots\rhino\scene\robotmodelobject.py, as per your above suggestion.

Desktop

  • Windows 11 Pro Education version 22H2
  • Python version 3.9.10
  • pip .rhinocode

Thanks,
Marco

Hi Alicia and Marco,

Thanks for your description. Regarding the problem of adding RobotModel to the scene, it is related to a recent change in the Scene, I’m not fully aware of the change but it appears to me that some parameter names may have been changed.

I’m afraid we need to wait a few more days before this gets resolved. If the older version worked for you, that is great for now. I only have Rhino 7 on my computer, and we need to wait for another developer who can test things on Rhino 8. However, I think this problem is not specific to the Rhino version.

Victor

1 Like

Hi Victor,

thanks for your feedback.
I’ll wait for some updates then!

Best,
Marco

Hello Alicia and Marco,

I did some more investigation. The errors the two of you are seeing comes from a different origin. I’ve identified the problem for the Rhino 7 case and submitted a PR for it here:

The problem with Rhino 8 seems to be related to some failure in registering the RobotModelObject as a SceneObject for the Rhino context. This problem appears to be only affecting Rhino 8. I’ll wait for this PR to be merged first before starting that issue. I’m not familiar with the plugin system for registering scene objects.

2 Likes

Hi Victor,

I could successfully visualize a RobotModel in Rhino 8 with Compas v. 0.27.
That confirms your findings that is not a Rhino 8 issue, but of latest Compas versions (the ones which introduced the Scene class).

Best!
Marco

Hi Marco,

We’ve indeed been having issues with support for CPython Rhino 8 Grasshopper.
Hopefully I was able to resolve some of these with some recent PRs.

This required changes in both COMPAS core as well as COMPAS Robots. I’m now able to run the code example with the changes from the following two PRs:

Once these are merged this issues should be fixed.

Feel free to try these out and reach out to me if you have any questions.

Thanks for your patience!
Chen

Hi Chen,

thanks a lot for your fedback.
I’ll wait for the merging to update and give it a try!

Best,
Marco

@Marco_Palma @yck011522

Regarding the visualization in the Rhino8 ScriptEditor (not Grashopper), there was in-fact a separate issue that is fixed with:

Robot scene rhino8 by chenkasirer · Pull Request #23 · compas-dev/compas_robots · GitHub.

This one is independent of the visualization failing in Grasshopper Rhino 8 CPython.

Chen

This issue is now fixed in compas==2.4.3 and compas_robots==0.6.0.

1 Like