{"id":17334261,"url":"https://github.com/cmower/optas","last_synced_at":"2025-05-16T18:09:30.079Z","repository":{"id":37908833,"uuid":"486694246","full_name":"cmower/optas","owner":"cmower","description":"OpTaS: An optimization-based task specification library for trajectory optimization and model predictive control.","archived":false,"fork":false,"pushed_at":"2025-05-01T00:14:34.000Z","size":11246,"stargazers_count":119,"open_issues_count":9,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-01T01:25:40.676Z","etag":null,"topics":["forward-kinematics","inverse-kinematics","library","model-predictive-control","nonlinear","optimal-control","optimization","planning","python","robotics","task-specification","trajectory-optimization"],"latest_commit_sha":null,"homepage":"https://cmower.github.io/optas/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.bib","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-28T17:48:06.000Z","updated_at":"2025-05-01T00:14:38.000Z","dependencies_parsed_at":"2023-02-18T18:01:06.713Z","dependency_job_id":"3c5a5039-bda7-41b1-9ff1-5fa72ccd4ae6","html_url":"https://github.com/cmower/optas","commit_stats":{"total_commits":925,"total_committers":10,"mean_commits":92.5,"dds":"0.27459459459459457","last_synced_commit":"889cbe3c3e20f94d174d8156528144cf00c264c7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmower%2Foptas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmower%2Foptas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmower%2Foptas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmower%2Foptas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmower","download_url":"https://codeload.github.com/cmower/optas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["forward-kinematics","inverse-kinematics","library","model-predictive-control","nonlinear","optimal-control","optimization","planning","python","robotics","task-specification","trajectory-optimization"],"created_at":"2024-10-15T15:05:34.415Z","updated_at":"2025-05-16T18:09:30.023Z","avatar_url":"https://github.com/cmower.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/cmower/optas/master/doc/logo.png\" width=\"60\" align=\"right\"\u003e\n\u003c/p\u003e\n\n# OpTaS\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Lint](https://github.com/cmower/optas/actions/workflows/black.yaml/badge.svg)](https://github.com/cmower/optas/actions/workflows/black.yaml)\n[![Run tests](https://github.com/cmower/optas/actions/workflows/pytest.yaml/badge.svg)](https://github.com/cmower/optas/actions/workflows/pytest.yaml)\n[![Build documentation](https://github.com/cmower/optas/actions/workflows/documentation.yaml/badge.svg)](https://github.com/cmower/optas/actions/workflows/documentation.yaml)\n\n\nOpTaS is an OPtimization-based TAsk Specification library for trajectory optimization and model predictive control.\n\n- Code: [https://github.com/cmower/optas](https://github.com/cmower/optas)\n- Documentation: [https://cmower.github.io/optas/](https://cmower.github.io/optas/)\n- PyPI: [https://pypi.org/project/pyoptas/](https://pypi.org/project/pyoptas/)\n- Issues: [https://github.com/cmower/optas/issues](https://github.com/cmower/optas/issues)\n- ICRA 2023 paper:\n  - (arXiv) [https://arxiv.org/abs/2301.13512](https://arxiv.org/abs/2301.13512)\n  - (ieee) [https://ieeexplore.ieee.org/document/10161272](https://ieeexplore.ieee.org/document/10161272)\n- Video: [https://youtu.be/gCMNOenFngU](https://youtu.be/gCMNOenFngU)\n- Presentation: [https://vimeo.com/824802366](https://vimeo.com/824802366)\n\nIn the past, OpTaS supported ROS from an internal module. This functionality, with additional updates, has now been moved to a dedicated repository: [optas_ros](https://github.com/cmower/optas_ros).\n\n# Example\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/cmower/optas/master/doc/image/kuka_example.png\" width=\"61.803398875%\"\u003e\n\u003c/p\u003e\n\n\nIn this example we implement an optimization-based IK problem.\nThe problem computes an optimal joint configuration $q^*\\in\\mathbb{R}^n$ given by\n\n$$\nq^* = \\underset{q}{\\text{arg}\\min}~\\|\\|q - q_N\\|\\|^2\\quad\\text{subject to}\\quad p(q) = p_g, q^-\\leq q \\leq q^+\n$$\n\nwhere\n* $q\\in\\mathbb{R}^n$ is the joint configuration for an $n$-dof robot (in our example, we use the KUKA LWR in the above figure with $n=7$),\n* $q_N\\in\\mathbb{R}^n$ is a nominal joint configuration,\n* $\\|\\|\\cdot\\|\\|$ is the Euclidean norm,\n* $p: \\mathbb{R}^n\\rightarrow\\mathbb{R}^3$ computes the end-effector position via the forward kinematics,\n* $p_g\\in\\mathbb{R}^3$ is a goal position, and\n* $q^-, q^+\\in\\mathbb{R}^n$ is the lower and upper joint position limits respectively.\n\nThe example problem has a quadratic cost function with nonlinear constraints.\nWe use the nominal configuration $q_N$ as the initial seed for the problem.\n\nThe following example script showcases some of the main features of OpTaS:\ncreating a robot model,\nbuilding an optimization problem,\npassing the problem to a solver,\ncomputing an optimal solution, and\nvisualizing the robot in a given configuration.\n\n```python\nimport os\nimport pathlib\n\nimport optas\n\n# Specify URDF filename\ncwd = pathlib.Path(__file__).parent.resolve()  # path to current working directory\nurdf_filename = os.path.join(\n    cwd, \"robots\", \"kuka_lwr\", \"kuka_lwr.urdf\"\n)  # KUKA LWR, 7-DoF\n\n# Setup robot model\nrobot = optas.RobotModel(urdf_filename=urdf_filename)\nname = robot.get_name()\n\n# Setup optimization builder\nT = 1\nbuilder = optas.OptimizationBuilder(T, robots=robot)\n\n# Setup parameters\nqn = builder.add_parameter(\"q_nominal\", robot.ndof)\npg = builder.add_parameter(\"p_goal\", 3)\n\n# Constraint: end goal\nq = builder.get_model_state(name, 0)\nend_effector_name = \"end_effector_ball\"\np = robot.get_global_link_position(end_effector_name, q)\nbuilder.add_equality_constraint(\"end_goal\", p, pg)\n\n# Cost: nominal configuration\nbuilder.add_cost_term(\"nominal\", optas.sumsqr(q - qn))\n\n# Constraint: joint position limits\nbuilder.enforce_model_limits(name)  # joint limits extracted from URDF\n\n# Build optimization problem\noptimization = builder.build()\n\n# Interface optimization problem with a solver\nsolver = optas.CasADiSolver(optimization).setup(\"ipopt\")\n# solver = optas.ScipyMinimizeSolver(optimization).setup(\"SLSQP\")\n\n# Specify a nominal configuration\nq_nominal = optas.deg2rad([0, 45, 0, -90, 0, -45, 0])\n\n# Get end-effector position in nominal configuration\np_nominal = robot.get_global_link_position(end_effector_name, q_nominal)\n\n# Specify a goal end-effector position\np_goal = p_nominal + optas.DM([0.0, 0.3, -0.2])\n\n# Reset solver parameters\nsolver.reset_parameters({\"q_nominal\": q_nominal, \"p_goal\": p_goal})\n\n# Reset initial seed\nsolver.reset_initial_seed({f\"{name}/q\": q_nominal})\n\n# Compute a solution\nsolution = solver.solve()\nq_solution = solution[f\"{name}/q\"]\n\n# Visualize the robot\nvis = optas.Visualizer(quit_after_delay=2.0)\n\n# Draw goal position and start visualizer\nvis.sphere(0.05, rgb=[0, 1, 0], position=p_goal.toarray().flatten().tolist())\n# vis.robot(robot, q=q_nominal,display_link_names=True,show_links=True)   # nominal\nvis.robot(robot, q=q_solution, display_link_names=True, show_links=True)  # solution\n\nvis.start()\n```\n\nRun the example script [example.py](example/example.py).\nOther examples, including dual-arm planning, Model Predictive Control, Trajectory Optimization, etc can be found in the [example/](example) directory.\n\n# Support\n\nThe following operating systems and python versions are [officially supported](https://github.com/cmower/optas/blob/master/.github/workflows/pytest.yaml):\n\n* Ubuntu 20.04 and 22.04\n  * Python 3.7, 3.8, 3.9\n* Windows\n  * Python 3.8, 3.9\n* Mac OS\n  * Python 3.9\n\nNote that OpTaS makes use of [dataclasses](https://docs.python.org/3/library/dataclasses.html) that was [introduced in Python 3.7](https://peps.python.org/pep-0557/), and so Python versions from 3.6 and lower are not supported on any operating system.\nOther operating systems or higher Python versions will likely work.\nIf you experience problems, please [submit an issue](https://github.com/cmower/optas/issues/new/choose).\n\n# Install\n\nMake sure `pip` is up-to-date by running `$ python -m pip install --upgrade pip`.\n\n## Via pip\n\n```\n$ pip install pyoptas\n```\n\nAlternatively, you can also install OpTaS using:\n\n```\n$ python -m pip install 'optas @ git+https://github.com/cmower/optas.git'\n```\n\n## From source\n1. `$ git clone --recursive git@github.com:cmower/optas.git` (if you do not want to build the documentation then the `--recursive` flag is not necessary)\n2. `$ cd optas`\n4. `$ pip install .`\n   - if you want to run the examples use: `$ pip install .[example]`\n   - if you want to run the tests use: `$ pip install .[test]`\n\n### Build documentation\n\n1. `$ cd /path/to/optas/doc`\n2. `$ sudo apt install doxygen graphviz`\n3. `$ python gen_mainpage.py`\n3. `$ doxygen`\n4. Open the documentation in either HTML or PDF:\n   - `html/index.html`\n   - `latex/refman.pdf`\n\n### Run tests\n\n1. `$ cd /path/to/optas`\n2. Each test can be run as follows\n   - `$ pytest tests/test_builder.py`\n   - `$ pytest tests/test_examples.py`\n   - `$ pytest tests/test_models.py`\n   - `$ pytest tests/test_optas_utils.py`\n   - `$ pytest tests/test_optimization.py`\n   - `$ pytest tests/test_solver.py`\n   - `$ pytest tests/test_spatialmath.py`\n   - `$ pytest tests/test_sx_container.py`\n\n# Known Issues\n\n- Loading robot models from xacro files is supported, however there can be issues if you are running this in a ROS agnositic environment. If you do not have ROS installed, then the xacro file should not contain ROS-specific features. For further details see [here](https://github.com/cmower/optas/issues/78).\n- If NumPy ver 1.24 is installed, an `AttributeError` error is thrown when you try to solve an unconstrained problem with the OSQP interface. A temporary workaround is to add a constraint, e.g. `x \u003e= -1e9` where `x` is a decision variable. See details on the issue [here](https://github.com/osqp/osqp-python/issues/104) and pull request [here](https://github.com/osqp/osqp-python/pull/105).\n\n# Citation\n\nIf you use OpTaS in your work, please consider including the following citation.\n\n```bibtex\n@inproceedings{mower23optas,\n  author={Mower, Christopher E. and Moura, João and Behabadi, Nazanin Zamani and Vijayakumar, Sethu and Vercauteren, Tom and Bergeles, Christos},\n  booktitle={2023 IEEE International Conference on Robotics and Automation (ICRA)},\n  title={OpTaS: An Optimization-based Task Specification Library for Trajectory Optimization and Model Predictive Control},\n  year={2023},\n  volume={},\n  number={},\n  pages={9118-9124},\n  doi={10.1109/ICRA48891.2023.10161272}\n}\n```\n\nThe preprint can be found on [arXiv](https://arxiv.org/abs/2301.13512).\n\n# Contributing\n\nWe welcome contributions from the community.\nIf you come across any issues or inacuracies in the documentation, please [submit an issue](https://github.com/cmower/optas/issues/new/choose).\nIf you would like to contribute any new features, please [fork the repository](https://github.com/cmower/optas/fork), and submit a pull request.\n\n# Acknowledgement\n\nThis research received funding from the European Union’s Horizon 2020 research and innovation program under grant agreement No. 101016985 ([FAROS](https://h2020faros.eu/)).\nFurther, this work was supported by core funding from the Wellcome/EPSRC [WT203148/Z/16/Z; NS/A000049/1].\nT. Vercauteren is supported by a Medtronic / RAEng Research Chair [RCSRF1819\\7\\34], and C. Bergeles by an ERC Starting Grant [714562].\nThis work has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 101017008, Enhancing Healthcare with Assistive Robotic Mobile Manipulation ([HARMONY](https://harmony-eu.org/)).\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/cmower/optas/master/doc/image/eu.png\" width=\"180\" align=\"left\"\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmower%2Foptas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmower%2Foptas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmower%2Foptas/lists"}