diff --git a/docs/Makefile b/docs/Makefile index 6744ed5d6..3b1c2b60c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,8 +1,3 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . diff --git a/docs/index.rst b/docs/index.rst index 25a7a7be2..276629774 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,18 +28,24 @@ Features - Default validation of JAX pytrees to prevent JIT re-compilations. - Preliminary support for automatic differentiation of RBDAs. -Installation ------------- - -You can install the project with `pypa/pip `_, preferably in a `virtual environment `_: +.. toctree:: + :maxdepth: 2 + :caption: User Guide -.. code-block:: bash + guide/install - pip install jaxsim +.. toctree:: + :maxdepth: 2 + :caption: JAXsim API -Check `setup.cfg` for the complete list of optional dependencies. Install all of them with ``jaxsim[all]``. + modules/typing + modules/high_level + modules/math + modules/physics + modules/parsers + modules/simulation + modules/utils -**Note:** For GPU support, follow the official `installation instruction of JAX `_. Examples -------- diff --git a/docs/jaxsim_conda_env.yml b/docs/jaxsim_conda_env.yml index c269743f1..e47001990 100644 --- a/docs/jaxsim_conda_env.yml +++ b/docs/jaxsim_conda_env.yml @@ -1,7 +1,6 @@ name: jaxsim channels: - conda-forge - # - nvidia dependencies: - coloredlogs - python=3.11 @@ -10,7 +9,6 @@ dependencies: - jaxlib - jaxlie - jinja2 - # - cuda-nvcc - rod - coloredlogs - sphinx diff --git a/docs/make.bat b/docs/make.bat index f9fe453e4..181c05d63 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -2,7 +2,7 @@ pushd %~dp0 -REM Command file for Sphinx documentation +REM if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build diff --git a/src/jaxsim/parsers/kinematic_graph.py b/src/jaxsim/parsers/kinematic_graph.py index 6ba57314d..bf076f158 100644 --- a/src/jaxsim/parsers/kinematic_graph.py +++ b/src/jaxsim/parsers/kinematic_graph.py @@ -570,15 +570,34 @@ def breadth_first_search( yield child def __iter__(self) -> Iterable[descriptions.LinkDescription]: - return self.breadth_first_search(root=self.root) + yield from KinematicGraph.breadth_first_search(root=self.root) - def __getitem__(self, name: str) -> descriptions.LinkDescription: - if name not in self.links_dict: - raise KeyError(f"Link '{name}' not found in the kinematic graph.") - return self.links_dict[name] + def __reversed__(self) -> Iterable[descriptions.LinkDescription]: + yield from reversed(list(iter(self))) def __len__(self) -> int: - return len(self.links_dict) + return len(list(iter(self))) - def __contains__(self, name: str) -> bool: - return name in self.links_dict or name in self.frames_dict + def __contains__(self, item: Union[str, descriptions.LinkDescription]) -> bool: + if isinstance(item, str): + return item in self.link_names() + + if isinstance(item, descriptions.LinkDescription): + return item in set(iter(self)) + + raise TypeError(type(item).__name__) + + def __getitem__(self, key: Union[int, str]) -> descriptions.LinkDescription: + if isinstance(key, str): + if key not in self.link_names(): + raise KeyError(key) + + return self.links_dict[key] + + if isinstance(key, int): + if key > len(self): + raise KeyError(key) + + return list(iter(self))[key] + + raise TypeError(type(key).__name__)