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

Cura 10475 engineplugin #15563

Merged
merged 120 commits into from
Sep 11, 2023
Merged

Cura 10475 engineplugin #15563

merged 120 commits into from
Sep 11, 2023

Conversation

jellespijker
Copy link
Member

@jellespijker jellespijker commented May 19, 2023

plugin system for CuraEngine

gRPC definitions:
CuraEngine_grpc_defintions: https://github.com/Ultimaker/CuraEngine_grpc_defintions
example plugins:
CuraEngine_example_plugin_cpp: https://github.com/Ultimaker/CuraEngine_example_plugin_cpp
CuraEngine_example_plugin_rust https://github.com/Ultimaker/CuraEngine_example_plugin_rust
CuraEngine_example_plugin_python: https://github.com/Ultimaker/CuraEngine_example_plugin_python
PullRequests on existing repo's:
Ultimaker/CuraEngine#1878
#15563
Ultimaker/libArcus#150
Ultimaker/pyArcus#5

The Engine Plugin System uses Protobuf https://protobuf.dev/ and gRPC https://grpc.io/

Suggested Architecture

ComponentEnginePlugin_v5

Cura container

Cura is responsible for starting the engine plugin service before the engine. In the local variant, this is done with a bash command adding the appropriate arguments (such as IP localhost and port number) these arguments are send along to the engine backend plugin which is responsible for starting engine, providing the settings, mesh and engine plugin (IP and port) data.

Engine plugin container

The engine plugin container can be written in any language, provided that it can handle Protobuf messages. The engine plugin service is started and will listen to any message on the specified socket. It should be able to respond to the following message types:

Identity: This should return at the very least the version and maybe in the future possible an authentication response, to ensure that we hook in to a valid plugin.

Process(data, args…): This is a request to process the data, with some additional arguments and return the modified data in the agreed upon format, if an error occurs it should respond with an error message instead.

Shutdown: This should stop listening and exit the program

CuraEngine container

CuraEngine is to be extended with a PluginRegistry, which will take care of the book keeping, coupling a slot, (which is a hook, defined by an certain operation, version range and call signature) with a PluginProxy (which provides an uniform API for the remote plugin service and acts like a regular C++ function object, with a default fallback behaviour if no valid plugin services is running.

Since we now have to take into account that the update cycle for engine plugins might differ from that of Cura and therefor CuraEngine, and that a user might still run an older version of a engine plugin, we also need to validate if a plugin is compatible; This is done with the PluginValidator which is a type that specifies the semver range. This validator can be extended in the future with additional checks, such as an authentication scheme, which would allows use to only run UltiMaker approved plugins (@remco Burema will look into this further)

Because the data transfer between a plugin and the engine is defined as a “generic” Protobuf message the engine also needs a way to convert that Protobuf type to CuraEngine native types. This is done with a Converter which maps the protobuf type to the native types (e.q. Polygons etc.). The converter throws a runtime error when it receives an error response from the plugin.

A slot is defined by a PluginValidator, a specialisation of the Converter<proto::Request, proto::Response> and a SlotID (e.q. POSTPROCESS, SIMPLIFY, etc.).

Proto definitions container

The common types between a plugin and the engine are the Protobuf messages. These messages should live as a single source of truth in their own repository (with a very loose license e.q. MIT).

The Protobuf definitions are:

SlotID (e.q. POSTPROCESS, SIMPLIFY, etc.), these describe the specific functionality of the plugin

Identity_Request request detailed information from a plugin

Identity_Response provides the version of the plugin, can be extended in the future with additional verification methods

Error_Response provides an error message if the plugin encounters an error

Each type of slot should have a corresponding Request and Response message in the definition file, e.q. Simplify_Request , Simplify_Response

Sequence diagram

SequenceEnginePlugin_v4

To use the plugins from the front-end for now use environmental variables as below, while running this Cura branch:

  • SIMPLIFY_ENABLE: default disabled, setting this to any value will enable the plugin
  • SIMPLIFY_ADDRESS: defaults to localhost
  • SIMPLIFY_PORT: defaults to 33700
  • POSTPROCESS_ENABLE: default disabled, setting this to any value will enable the plugin
  • POSTPROCESS_ADDRESS: defaults to localhost
  • POSTPROCESS_PORT: defaults to 33701

jellespijker and others added 5 commits May 19, 2023 09:04
This would then default to default behaviour of slots

Contributes to CURA-10475
This can currently be done by setting the environment variables:
- SIMPLIFY_ENABLE: default disabled, setting this to any value will enable the plugin
- SIMPLIFY_ADDRESS: defaults to localhost
- SIMPLIFY_PORT: defaults to 33700
- POSTPROCESS_ENABLE: default disabled, setting this to any value will enable the plugin
- POSTPROCESS_ADDRESS: defaults to localhost
- POSTPROCESS_PORT: defaults to 33701

Hacky for now

Contributes to CURA-10475
# Conflicts:
#	conanfile.py
#	resources/i18n/cs_CZ/cura.po
#	resources/i18n/cura.pot
#	resources/i18n/de_DE/cura.po
#	resources/i18n/es_ES/cura.po
#	resources/i18n/fi_FI/cura.po
#	resources/i18n/fr_FR/cura.po
#	resources/i18n/hu_HU/cura.po
#	resources/i18n/it_IT/cura.po
#	resources/i18n/ja_JP/cura.po
#	resources/i18n/ko_KR/cura.po
#	resources/i18n/nl_NL/cura.po
#	resources/i18n/pl_PL/cura.po
#	resources/i18n/pt_BR/cura.po
#	resources/i18n/pt_PT/cura.po
#	resources/i18n/ru_RU/cura.po
#	resources/i18n/tr_TR/cura.po
#	resources/i18n/zh_CN/cura.po
#	resources/i18n/zh_TW/cura.po
jellespijker and others added 22 commits July 5, 2023 11:58
I was running into abstraction issues when it was defined in Uranium.
Instead of trying to fight those, it's just easier to move it to Cura

CURA-10717
It's easier to understand what is going on if the signal definitions are not spread out

CURA-10717
…ration' into CURA-10475_engineplugin

# Conflicts:
#	plugins/CuraEngineBackend/Cura.proto
#	plugins/CuraEngineBackend/StartSliceJob.py
Solve version conflict with libnest2d
These are appended to project metadata. A warning can now be shown to the user when trying to load a project file while the correct plugins are not installed. These missing plugins can concequently be downloaded from the marketplace. To show the warning and install missing package dialog the same system we use to install missing materials is used.

CURA-10719
Now more then just materials can be installed. Update copy to reflect this.

CURA-10719
jellespijker and others added 25 commits August 30, 2023 16:51
# Conflicts:
#	.github/workflows/linux.yml
Although not a direct dependency of Cura, still need to define it here,
such that we can set it as shared for all dependencies.
Needed to overcome the issues with glibc and static compiling of the
gradual flow plugin on ubuntu 20.04 with gcc-13

Contributes to CURA-10951
fixes incompatible mismatch in versions between pyarcus and protobuf

Contributes to CURA-10951
This commit simplifies the deploy method in conanfile.py by reducing the number of lines of code and refactor the
handling of the Gradualflow plugin in the deploy method. In conandata.yml, the paths for the Gradualflow plugin
resources have been adjusted for correct deployment. This update aims to fix the pyinstaller deployment failures
associated with the Gradualflow plugin. It resolves the CURA-10951 tracking issue.

Contributes CURA-10951
Added the configuration file `AppImageBuilder.yml.jinja`, the Python script `create_appimage.py`, and the shell script
`entrypoint.sh.jinja` for AppImage building and packaging. These additions would enable the Cura application to be built
into a single, standalone, executables file for Linux users, improving software deployment and distribution.

Contributes CURA-10951
still ship other executables

Contributes to CURA-10951
Issue before was the following: when placing objects within a grid cell there is a margin around the object. This margin comes from both the integer rounding of the cell and the defined min distance between objects. When trying to place object near the buildplate border we marked any cell that is not fully within the buildplate area as an invalid cell to place objects in. This was however too strict; there is the aforementioned margin around the object, and if only this margin would be outside the buildplate it is perfectly fine to place object in that cell.

CURA-7951
@jellespijker jellespijker marked this pull request as ready for review September 10, 2023 09:43
@jellespijker jellespijker merged commit 3813398 into main Sep 11, 2023
3 of 4 checks passed
@jellespijker jellespijker deleted the CURA-10475_engineplugin branch December 11, 2023 06:48
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.

5 participants