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 scene rhino8 #23

Merged
merged 7 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Fixed no scene object registered for `RobotModelObject` in context `Rhino`.

### Removed


Expand Down
51 changes: 37 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tool.black]
line-length = 120
# ============================================================================
# Testing
# ============================================================================

[tool.pytest.ini_options]
minversion = "6.0"
Expand All @@ -12,16 +13,38 @@ addopts = "-ra --strict --doctest-modules --doctest-glob=*.rst --tb=short"
doctest_optionflags= "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ALLOW_UNICODE ALLOW_BYTES NUMBER"
filterwarnings = "ignore::DeprecationWarning"

[tool.isort]
line_length = 120
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
force_single_line = true
ensure_newline_before_comments = true
known_first_party = "compas_robots"
default_section = "THIRDPARTY"
forced_separate = "test_compas_robots"
skip = []
# ============================================================================
# Linting and formatting
# ============================================================================

[tool.black]
line-length = 120

[tool.ruff.lint.isort]
force-single-line = true
known-first-party = [
"compas_robots",
]

[tool.ruff]
line-length = 179
indent-width = 4
target-version = "py39"

[tool.ruff.lint]
select = ["E", "F", "I"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["I001"]
"tests/*" = ["I001", "E501"]
"tasks.py" = ["I001"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.pycodestyle]
max-doc-length = 179

[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = "dynamic"
8 changes: 2 additions & 6 deletions requirements-dev.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know enough to review these things. What is the difference from compas_invocation2 from the original one? Does these new tools changes the coding style or is simply a drop-in replacement of the old pep8 tools?

Just so I know if I should do the same for compas_fab...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. ruff is pretty much a drop-in for all these other linting and formatting tools we were previously using.

It's part of a bigger effort to reduce our dependencies and consolidate all these different configuration files (setup.py, setup.conf, .bumpversion.cfg etc.) into a single pyproject.toml file. Take a look at core for example.

Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
attrs >=17.4
autopep8
ruff
black
bump2version >=1.0.1
check-manifest >=0.36
compas_invocations
doc8
flake8
compas_invocations2
invoke >=0.14
isort
pydocstyle
pytest >=3.2
sphinx_compas2_theme
twine
Expand Down
4 changes: 2 additions & 2 deletions src/compas_robots/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from __future__ import division
from __future__ import print_function

from copy import deepcopy

from compas.colors import Color
from compas.geometry import Frame

from compas_robots.files import URDFElement
from compas_robots.files import URDFGenericElement

from copy import deepcopy


def _parse_floats(values):
return [float(i) for i in values.split()]
Expand Down
2 changes: 1 addition & 1 deletion src/compas_robots/resources/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
except ImportError:
from urlparse import urlparse

from .mesh_importer import mesh_import
from .mesh_importer import get_file_format
from .mesh_importer import mesh_import


class AbstractMeshLoader(object):
Expand Down
11 changes: 5 additions & 6 deletions src/compas_robots/rhino/scene/robotmodelobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
import System.Drawing # type: ignore
from compas_rhino.conversions import transformation_to_rhino
from compas_rhino.scene import RhinoSceneObject
from Rhino.DocObjects.ObjectColorSource import ColorFromLayer # type: ignore
from Rhino.DocObjects.ObjectColorSource import ColorFromObject # type: ignore
from Rhino.DocObjects.ObjectMaterialSource import MaterialFromObject # type: ignore
from Rhino.DocObjects import ObjectColorSource # type: ignore
from Rhino.DocObjects import ObjectMaterialSource # type: ignore

from compas_robots.scene import BaseRobotModelObject

Expand Down Expand Up @@ -233,7 +232,7 @@ def _add_mesh_to_doc(self, mesh):
if color:
r, g, b, a = [i * 255 for i in color]
attr.ObjectColor = System.Drawing.Color.FromArgb(a, r, g, b)
attr.ColorSource = ColorFromObject
attr.ColorSource = ObjectColorSource.ColorFromObject

material_name = "robotmodelobject.{:.2f}_{:.2f}_{:.2f}_{:.2f}".format(r, g, b, a)
material_index = sc.doc.Materials.Find(material_name, True)
Expand All @@ -247,9 +246,9 @@ def _add_mesh_to_doc(self, mesh):
material.CommitChanges()

attr.MaterialIndex = material_index
attr.MaterialSource = MaterialFromObject
attr.MaterialSource = ObjectMaterialSource.MaterialFromObject
else:
attr.ColorSource = ColorFromLayer
attr.ColorSource = ObjectColorSource.ColorFromLayer

if name:
attr.Name = name
Expand Down
8 changes: 4 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import os

from compas_invocations import build
from compas_invocations import docs
from compas_invocations import style
from compas_invocations import tests
from compas_invocations2 import build
from compas_invocations2 import docs
from compas_invocations2 import style
from compas_invocations2 import tests
from invoke import Collection

ns = Collection(
Expand Down
Loading