Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ shown in the image above of this README).

To open the graphical editor, run:
```bash
pysimblocks examples/quick_start/gui
pysimblocks gui examples/quick_start/gui
```

The quick-start GUI project is stored in a single
Expand All @@ -129,7 +129,7 @@ A collection of basic and advanced examples is available in the
[examples](./examples) directory, including:

- Control system demonstrations
- SOFA-based simulations
- SOFA-based simulations (tested with SOFA v24.06 and later.)
- Hardware and real-time use cases
- Comparisons with external tools

Expand Down
2 changes: 1 addition & 1 deletion docs/User_Guide/tutorial_2_gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Create a new project folder and start the GUI:
```bash
$ mkdir tutorial-gui
$ cd tutorial-gui
$ pysimblocks
$ pysimblocks gui
```
The main window opens, with the `Toolbar` at the top, the `Blocks List` on the left, and the `Diagram View` on the right.
![Gui](./images/tutorial_2-gui_main.png)
Expand Down
6 changes: 4 additions & 2 deletions docs/User_Guide/tutorial_3_sofa.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## 1. Overview

This tutorial builds on the closed-loop system introduced in [Tutorial 1](./tutorial_1_python.md) and [Tutorial 2](./tutorial_2_gui.md). We demonstrate how **pySimBlocks can be coupled with SOFA**
to control and interact with a physics-based simulation.
This tutorial builds on the closed-loop system introduced in [Tutorial 1](./tutorial_1_python.md)
and [Tutorial 2](./tutorial_2_gui.md). We demonstrate how **pySimBlocks can be
coupled with SOFA** to control and interact with a physics-based simulation.

### 1.1 Goals

Expand Down Expand Up @@ -40,6 +41,7 @@ your environment so that:

### 2.1 Install SOFA

> **Compatibility:** pySimBlocks has been tested with SOFA v24.06 and later.

Install SOFA from the [website](https://www.sofa-framework.org/download/) either
using the precompiled binaries (recommended) or building from source (advanced
Expand Down
31 changes: 14 additions & 17 deletions pySimBlocks/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@


def _run_gui(project_dir: str | None) -> None:
from pySimBlocks.gui.editor import run_app
try:
from pySimBlocks.gui.editor import run_app
except ImportError as e:
print(f"Error importing GUI modules: {e}")
print("Make sure PySide6 is installed to use the GUI editor.")
sys.exit(1)

path = Path(project_dir).resolve() if project_dir else Path.cwd().resolve()
run_app(path)
Expand All @@ -36,9 +41,13 @@ def _run_export(args: argparse.Namespace) -> None:
output = Path(args.out) if args.out else None

if args.sofa_controller:
from pySimBlocks.project.generate_sofa_controller import generate_sofa_controller

generate_sofa_controller(project_dir=project_dir, project_yaml=project_yaml)
try:
from pySimBlocks.project.generate_sofa_controller import generate_sofa_controller
generate_sofa_controller(project_dir=project_dir, project_yaml=project_yaml)
except Exception as e:
print(f"Error generating SOFA controller: {e}")
print("See SOFA integration documentation for troubleshooting.")
sys.exit(1)
else:
from pySimBlocks.project import generate_run_script

Expand All @@ -57,8 +66,7 @@ def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog="pysimblocks",
description=(
"pySimBlocks command line interface.\n"
"Default behavior with no subcommand: launch the GUI editor."
"pySimBlocks command line interface."
),
)

Expand Down Expand Up @@ -104,17 +112,6 @@ def _build_parser() -> argparse.ArgumentParser:
def main(argv: list[str] | None = None) -> None:
args_list = list(sys.argv[1:] if argv is None else argv)
parser = _build_parser()

if not args_list:
_run_gui(project_dir=None)
return

if args_list[0] not in {"gui", "export", "update", "-h", "--help"}:
if len(args_list) > 1:
parser.error(f"unrecognized arguments: {' '.join(args_list[1:])}")
_run_gui(project_dir=args_list[0])
return

args = parser.parse_args(args_list)
if args.command == "gui":
_run_gui(project_dir=args.project_dir)
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ authors = [
{name = "Antoine Alessandrini", email = "antoine.alessandrini@univ-lille.fr"}
]
readme = "README.md"
license = {file = "LICENSE.md"}
requires-python = ">=3.10"
keywords = ["simulation", "block-diagram", "control", "discrete-time", "pyside6"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Education",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Visualization",
]
dependencies = [
"numpy",
"matplotlib",
Expand All @@ -19,6 +33,11 @@ dependencies = [
"typing_extensions; python_version < '3.11'"
]

[project.urls]
Homepage = "https://github.com/AlessandriniAntoine/pySimBlocks"
Repository = "https://github.com/AlessandriniAntoine/pySimBlocks"
Issues = "https://github.com/AlessandriniAntoine/pySimBlocks/issues"

[project.scripts]
pysimblocks = "pySimBlocks.cli:main"

Expand Down
Loading