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

Refactor floorplan grammar #17

Merged
merged 97 commits into from
Oct 18, 2024
Merged

Refactor floorplan grammar #17

merged 97 commits into from
Oct 18, 2024

Conversation

argenos
Copy link
Member

@argenos argenos commented Jul 26, 2024

Most of the changes are documented in docs/v2-motivation.md. As a very short summary, not exhaustive and in no particular order:

  • Renames the python package from exce_floorplan to floorplan_dsl
  • Reorganizes the repository to minimize code duplication and allow for easier code reuse/refactoring. As much as possible, tried to organize v2 by concern: semantics, validation and scoping have their own modules. v1 is still included in this repository until it can be fully deprecated (e.g. Refactor the 3D mesh and occupancy grid generation #11 has also been closed).
  • Redesigns the floor plan grammar and the custom classes from scratch
    • Includes concepts and semantics necessary for the JSON-LD generation
    • Improves the concrete syntax to remove the need to define translations and rotations of zero in locations of various floor plan elements
    • Makes the specification of locations consistent across elements
  • Adds a converter from v1 models to v2 using Jinja templates textx generate models/examples/hbrs.floorplan --target floorplan-v2 -o models/examples --overwrite
  • Reorganizes and redesigns the Jinja templates for the JSON-LD generation to maximize their reuse
  • Updates the Variation DSL to work with v2
  • Adds missing elements to JSON-LD models: features and openings were missing in several models
  • Fixes the prefixes in the JSON-LD context so they no longer point to the metamodels
  • Fixes the coordinates.json to follow the schema in the kinova models
  • Changes the internal representation of angles to RAD instead of DEG
  • Adds an additional argument to generate the JSON-LD coordinate pose angles in degrees instead of radians
  • Moves the README.md and images to the docs folder to allow GH pages to see and use them.
  • Updates the JSON-LD coordinates.json to use the appropriate QUDT units (i.e. DEG instead of degrees)

Note that the blender export won't work any more (it is untested) but will be removed soon from this repository (see #11 )

@argenos argenos force-pushed the refactor-floorplan-grammar branch from 1fda262 to a399203 Compare July 26, 2024 15:05
@argenos argenos force-pushed the refactor-floorplan-grammar branch from a399203 to 8626cd3 Compare July 30, 2024 12:02
@argenos argenos marked this pull request as ready for review August 22, 2024 10:57
@argenos argenos changed the base branch from main to devel August 22, 2024 11:17
Copy link
Member

@minhnh minhnh left a comment

Choose a reason for hiding this comment

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

Looks good in general, I just have some minor comments and questions, but nothing critical.

test.sh Show resolved Hide resolved
self.frame = Frame(self, self.name)


class Feature(FeatureSemantics):
Copy link
Member

Choose a reason for hiding this comment

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

Is the distinction between *Semantics and * classes described somewhere? At least for me, it's not obvious from just reading the code. Maybe something like a class diagram would be helpful if it can be generated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps not in sufficient detail or explicitly, I briefly talk about the design decisions in docs/v2-motivation.md. It's just a distinction between the language syntax and the static semantics of the concepts

self.translation = translation
self.of = of
self.wrt = wrt
self.name = "position-{}-wrt-{}".format(of.name, wrt.name)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you want to override the built-in __str__ method for this using class variables?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because textx instantiates some of the classes dynamically, overriding str creates issues at times. I tried it for a few classes, and it wasn't worth the trouble.


# TODO move this elsewhere
def to_deg(self):
if self.unit == "deg":
Copy link
Member

Choose a reason for hiding this comment

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

Maybe Python enum would be cleaner for this? Unless it's already defined in numpy or some library already in use.

Copy link
Member Author

Choose a reason for hiding this comment

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

Inheritance with the textx dynamic instantiation was a little tricky. enum might work, but I'd rather leave it as is for now since we don't have that many constants.

class VariableReference:
def __init__(self, parent, var_neg, variable) -> None:
self.parent = parent
self.var_neg = var_neg
Copy link
Member

Choose a reason for hiding this comment

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

What does negative mean in this context?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's the sign of the value assignment (whether a minus sign is present or not), e.g. room.width = - default_width

src/floorplan_dsl/utils/transformations.py Show resolved Hide resolved
@argenos argenos merged commit c78feaf into devel Oct 18, 2024
3 checks passed
@argenos argenos deleted the refactor-floorplan-grammar branch October 18, 2024 13:50
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

Successfully merging this pull request may close these issues.

3 participants