+
## Optimal Control
@@ -196,7 +196,7 @@ let status = optimizer.solve(&mut u)?;
```
See the dedicated [Rust documentation](https://alphaville.github.io/optimization-engine/docs/openrust-basic) for a full introduction and more complete examples.
-See more Rust examples [here](examples).
+See more Rust examples [here](rust/examples).
## Check out next...
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index e91d5115..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,74 +0,0 @@
-#This Appveyor configuration file is based on the configuration
-#file of the following project:
-#
-#https://github.com/starkat99/appveyor-rust/
-#
-
-## Operating System (VM environment) ##
-
-# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets.
-os: Visual Studio 2015
-
-
-environment:
- matrix:
-
-### MSVC Toolchains ###
-
- # Stable 64-bit MSVC
- - channel: stable
- target: x86_64-pc-windows-msvc
- # Stable 32-bit MSVC
- # - channel: stable
- # target: i686-pc-windows-msvc
-
-### GNU Toolchains ###
-
- # Stable 64-bit GNU
- # - channel: stable
- # target: x86_64-pc-windows-gnu
- # Stable 32-bit GNU
- # - channel: stable
- # target: i686-pc-windows-gnu
-
-### Allowed failures ###
-
-# See Appveyor documentation for specific details. In short, place any channel or targets you wish
-# to allow build failures on (usually nightly at least is a wise choice). This will prevent a build
-# or test failure in the matching channels/targets from failing the entire build.
-#matrix:
-# allow_failures:
-# - channel: nightly
-
-# If you only care about stable channel build failures, uncomment the following line:
- #- channel: beta
-
-## Install Script ##
-
-# This is the most important part of the Appveyor configuration. This installs the version of Rust
-# specified by the 'channel' and 'target' environment variables from the build matrix. This uses
-# rustup to install Rust.
-#
-# For simple configurations, instead of using the build matrix, you can simply set the
-# default-toolchain and default-host manually here.
-install:
- - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- - rustup-init -yv --default-toolchain %channel% --default-host %target%
- - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- - rustc -vV
- - cargo -vV
-
-## Build Script ##
-
-# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
-# the "directory does not contain a project or solution file" error.
-build: false
-
-# Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs
-#directly or perform other testing commands. Rust will automatically be placed in the PATH
-# environment variable.
-test_script:
- - cargo add roots
- - cargo add ndarray --features approx
- - cargo build
- - cargo test --verbose %cargoflags%
diff --git a/build/README.md b/build/README.md
deleted file mode 100644
index dd1346dd..00000000
--- a/build/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Build folder
-
-This folder is used (by MATLAB and Python) as the default destination to store auto-generated optimizers.
diff --git a/ci/script.sh b/ci/script.sh
index 18f1f2b7..cb599288 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -1,7 +1,19 @@
#!/bin/bash
set -euxo pipefail
+# To use locally, from the root directory and from a bash shell...
+#
+# 1. To run the core Python tests:
+# ci/script.sh python-tests
+#
+# 2. To run the Python OCP tests:
+# ci/script.sh ocp-tests
+#
+# 3. To run the Python ROS2 tests:
+# ci/script.sh ros2-tests
+
SKIP_RPI_TEST="${SKIP_RPI_TEST:-0}"
+DO_DOCKER="${DO_DOCKER:-0}"
TASK="${1:-all-python-tests}"
function run_clippy_test() {
@@ -25,7 +37,7 @@ function run_clippy_test() {
}
setup_python_test_env() {
- cd open-codegen
+ cd python
export PYTHONPATH=.
python -m venv venv
@@ -60,6 +72,35 @@ run_python_core_tests() {
generated_clippy_tests
}
+run_python_ros2_tests() {
+ export PYTHONPATH=.
+ set +u
+ if [ -n "${ROS_DISTRO:-}" ] && [ -f "/opt/ros/${ROS_DISTRO}/setup.bash" ]; then
+ # setup-ros installs the ROS underlay but does not source it for our shell
+ source "/opt/ros/${ROS_DISTRO}/setup.bash"
+ elif [ -f "/opt/ros/jazzy/setup.bash" ]; then
+ source "/opt/ros/jazzy/setup.bash"
+ else
+ set -u
+ echo "ROS2 environment setup script not found"
+ exit 1
+ fi
+ set -u
+
+ if ! python -c "import em, lark, catkin_pkg" >/dev/null 2>&1; then
+ # ROS2 build helpers run under the active Python interpreter. The test venv
+ # already has NumPy from `pip install .`, but we also need the ROS-side
+ # Python packages used during interface and package metadata generation.
+ # Empy 4 has broken older ROS message generators in the past, so keep it
+ # on the 3.x API here.
+ python -m pip install "empy<4" lark catkin_pkg
+ fi
+
+ command -v ros2 >/dev/null
+ command -v colcon >/dev/null
+ python -W ignore test/test_ros2.py -v
+}
+
run_python_ocp_tests() {
export PYTHONPATH=.
python -W ignore test/test_ocp.py -v
@@ -77,31 +118,37 @@ test_docker() {
}
main() {
- if [ $DO_DOCKER -eq 0 ]; then
- case "$TASK" in
- python-tests)
- echo "Running Python tests and generated Clippy tests"
- setup_python_test_env
- run_python_core_tests
- ;;
- ocp-tests)
- echo "Running OCP Python tests"
- setup_python_test_env
- run_python_ocp_tests
- ;;
- all-python-tests)
- echo "Running Python tests, generated Clippy tests, and OCP tests"
- all_python_tests
- ;;
- *)
- echo "Unknown task: $TASK"
- exit 1
- ;;
- esac
- else
+ if [ "$DO_DOCKER" -ne 0 ]; then
echo "Building Docker image"
test_docker
+ return
fi
+
+ case "$TASK" in
+ python-tests)
+ echo "Running Python tests and generated Clippy tests"
+ setup_python_test_env
+ run_python_core_tests
+ ;;
+ ros2-tests)
+ echo "Running ROS2 Python tests"
+ setup_python_test_env
+ run_python_ros2_tests
+ ;;
+ ocp-tests)
+ echo "Running OCP Python tests"
+ setup_python_test_env
+ run_python_ocp_tests
+ ;;
+ all-python-tests)
+ echo "Running Python tests, generated Clippy tests, and OCP tests"
+ all_python_tests
+ ;;
+ *)
+ echo "Unknown task: $TASK"
+ exit 1
+ ;;
+ esac
}
main
diff --git a/ci/sphinx-documentation.sh b/ci/sphinx-documentation.sh
index 452f057e..12a3794b 100644
--- a/ci/sphinx-documentation.sh
+++ b/ci/sphinx-documentation.sh
@@ -27,7 +27,7 @@ pip install sphinx
pip install sphinx-rtd-theme
# Install opengen
-pushd open-codegen
+pushd python
pip install .
popd # back to $GITHUB_WORKSPACE
@@ -48,11 +48,11 @@ git checkout $current_branch
# Build the docs
rm -rf sphinx
mkdir -p sphinx
-pushd sphinx-dox
-sphinx-apidoc -o ./source/ ../open-codegen/opengen
+pushd docs/sphinx
+sphinx-apidoc -o ./source/ ../../python/opengen
echo Last updated: $(date -u) >> source/index.rst; sed '$d' source/index.rst; # update date at the end of file
make html || :
-cp -r build/html/ ../sphinx
+cp -r build/html/ ../../sphinx
git checkout source/index.rst # no need to commit this
popd # back to $GITHUB_WORKSPACE
diff --git a/docs/algorithm.md b/docs/content/algorithm.md
similarity index 100%
rename from docs/algorithm.md
rename to docs/content/algorithm.md
diff --git a/docs/cite_open.md b/docs/content/cite_open.md
similarity index 100%
rename from docs/cite_open.md
rename to docs/content/cite_open.md
diff --git a/docs/content/contributing.mdx b/docs/content/contributing.mdx
new file mode 100644
index 00000000..0355dd19
--- /dev/null
+++ b/docs/content/contributing.mdx
@@ -0,0 +1,430 @@
+---
+id: contributing
+sidebar_label: Contributing
+title: Contributing to OpEn
+description: How do I contribute to OpEn
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+## How can I contribute to OpEn?
+Thank you for considering contributing to Optimization Engine (OpEn)!
+
+OpEn is an open source project and welcomes contributions from the community.
+
+You can contribute in several ways:
+
+- Submit an [**issue**](https://github.com/alphaville/optimization-engine/issues):
+ Often bugs will go unnoticed by the core development team and certain
+ use cases and user needs will have evaded our attention.
+ Consider submitting an issue if:
+ - You would like to report a [bug]; please, use the provided template for reporting
+ bugs. It is essential to give information about your system (OS, OpEn version)
+ and outline a sequence of steps to reproduce the error. When possible, please
+ provide a [minimum working example]
+ - You would like to request a [new feature]; please use the provided template
+ - You would like to propose modifications in OpEn's documentation, such as
+ for some concepts to be better elucidated or a request for an additional example
+- Share with us a **success story** on [**Discord**](https://discord.gg/mfYpn4V)
+- Create a **pull request** (see below)
+
+or, show us your love:
+
+- Give us a [**star on gitub**](https://github.com/alphaville/optimization-engine)
+- Spread the word on [**Twitter**]
+
+
+
+## I just have a question!
+The easiest and quickest way to ask a question is to reach us on [**Discord**](https://discord.gg/mfYpn4V) or [**Gitter**](https://gitter.im/alphaville/optimization-engine).
+
+You may also consult the [**frequently asked questions**](/optimization-engine/docs/faq).
+
+
+## Submitting issues
+You may submit an issue regarding anything related to **OpEn**, such as:
+
+- a bug
+- insufficient/vague documentation
+- request for a feature
+- request for an example
+
+You should, however, make sure that the same - or a very similar - issue is not already open. In that case, you may write a comment in an existing issue.
+
+
+## Contributing code or docs
+
+In order to contribute code or documentation, you need to [fork] our github repository, make you modifications and submit a pull request. You should follow these rules:
+
+- create one or more [issues on github] that will be associated with your changes
+- take it from `master`: fork OpEn and create a branch on `master`
+
+```console
+git checkout -b fix/xyz master
+```
+
+- read the [style guide](#coding-style-guide) below (and write unit/integration tests)
+- create a pull request in which you need to explain the key changes
+
+## Coding style guide
+
+Things to keep in mind:
+
+- **Code**: intuitive structure and variable names, short atomic functions,
+- **Comments**: help others better understand your code
+- **Docs**: document all functions (even private ones)
+- **Tests**: write comprehnsive, exhaustive tests
+
+### Rust
+
+*General guidelines:* Read the Rust [API guidelines] and this [API checklist]
+
+*Naming convention:* We follow the [standard naming convention](https://rust-lang-nursery.github.io/api-guidelines/naming.html) of Rust.
+
+*Documentation:* We follow [these guidelines](https://rust-lang-nursery.github.io/api-guidelines/documentation.html). Everything should be documented.
+
+### Python
+
+We follow [this style guide](https://www.python.org/dev/peps/pep-0008) and its [naming convention](https://www.python.org/dev/peps/pep-0008/#naming-conventions)
+
+
+### Website
+This documentation is generated with Docusaurus - read a detailed guide [here](https://github.com/alphaville/optimization-engine/blob/master/docs/website/README.md).
+
+- All docs are in `docs/content/`
+- Blog entries are in `docs/website/blog/`
+
+To start the website locally (at [http://localhost:3000/optimization-engine](http://localhost:3000/optimization-engine)) change directory to `docs/website` and run `yarn start`. To update the website, execute `./publish.sh` from there (you need to be a collaborator on github).
+
+## Using Git
+When using Git, keep in mind the following guidelines:
+
+- Create simple, atomic, commits
+- Write comprehensive commit messages
+- Work on a forked repository
+- When you're done, submit a pull request to
+[`alphaville/optimization-engine`](https://github.com/alphaville/optimization-engine/);
+it will be promptly delegated to a reviewer and we will contact you
+as soon as possible.
+
+Branch `master` is protected and all pull requests need to be reviewed by a person
+other than their proposer before they can be merged into `master`.
+
+## Versioning
+This project consists of independent modules:
+(i) the core Rust library,
+(ii) the MATLAB interface,
+(iii) the Python interface.
+Each module has a different version number (`X.Y.Z`).
+
+We use the **SemVer** standard - we quote from [semver.org](https://semver.org/):
+
+Given a version number `MAJOR.MINOR.PATCH`, increment the:
+
+- `MAJOR` version when you make incompatible API changes,
+- `MINOR` version when you add functionality in a backwards-compatible manner, and
+- `PATCH` version when you make backwards-compatible bug fixes.
+
+Additional labels for pre-release and build metadata are available as extensions to the `MAJOR.MINOR.PATCH` format.
+
+We also keep a [log of changes](https://github.com/alphaville/optimization-engine/blob/master/CHANGELOG.md) where we summarize the main changes since last version.
+
+## Releasing
+
+Each time the major or minor number of the Rust library is updated, a new crate should be published on [crates.io](https://crates.io/crates/optimization_engine).
+
+In order to release a new version make sure that
+you have done the following:
+
+---
+
+OptimizationResultNew in opegen 0.11
++ OpEn can now generate ROS2 packages directly from a parametric + optimizer. The generated package includes ROS2 messages, + configuration files, a launch file, and a node that exposes the + solver through topics. +
++ This makes it easy to connect optimization-based controllers, + estimators, and planning modules into a modern robotics stack + without writing the ROS2 wrapper code by hand. +
+Docker image
++ OpEn ships with a Docker image that gets you straight into a + working environment with Jupyter, Python, and the tooling needed + to explore examples without local setup friction. +
++ It is a convenient way to try the Python interface, browse the + notebooks, and experiment with the OCP workflows in a clean, + reproducible environment. +
+