Skip to content

Commit e701350

Browse files
author
Murilo Marinho
committed
Adding base of OXBR.
1 parent 4fcd9f1 commit e701350

File tree

11 files changed

+848
-0
lines changed

11 files changed

+848
-0
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
## 2025
4+
5+
- I'm removing `spatialmath` from the tutorials and moving any old content to `legacy/spatialmath`. The original intention when adding this library was to facilitate more complex content in later parts of the module. With variable levels of programming knowledge in the standard cohort this is not possible, and the following issues were observed:
6+
- `spatialmath` not being available as binary package in many distributions, causing students to have to compile the `wheel` even when using `pip`.
7+
- In Windows enviroments, for example, this means having a working VS Compiler installation which is not default and is beyond the scope of this module.
8+
- In any distribution, this could take several minutes and even fail depending on student's enviroments.
9+
- Students tend to default to memorising the library functions instead of understanding the underlying mechanism, irrespective of how trivial the operations are. It is more pedagogical to rely on the matricial operations that they are expected to learn and reinforce that knowledge.
10+
11+
- Remove all mentions of `import` in sample code, and keep them to explicit and isolated import cells. Despite the clear indication in the text that the `import` statement was merely illustrative, novice readers often default to copying and pasting chunks of example code causing extraneous `import` statements that result in unprofessional code that, beyond aesthetics, can cause all sorts of issues.

LICENSE

Lines changed: 437 additions & 0 deletions
Large diffs are not rendered by default.

M3logo_black.png

25.9 KB
Loading

M3logo_black.svg

Lines changed: 68 additions & 0 deletions
Loading

M3logo_white.svg

Lines changed: 57 additions & 0 deletions
Loading

book.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Making your own executable book
2+
3+
```{warning}
4+
This notebook is a work in progress. This is based on `Jupyter Book 2.0` which is currently in alpha, meaning that
5+
it might change considerably before release.
6+
```
7+
8+
```{seealso}
9+
- Jupyter book: https://next.jupyterbook.org
10+
- MyST: https://mystmd.org/guide/
11+
```
12+
13+
## Dependencies
14+
15+
Remember to set a `venv` first. The Python policies are becoming evermore stringent in this regard.
16+
17+
```commandline
18+
python -m venv venv
19+
source venv/bin/activate
20+
```
21+
22+
Installation can be done as follows.
23+
24+
```{important}
25+
The `--pre` flag is important while this version is not released.
26+
```
27+
28+
```commandline
29+
python -m pip install jupyter-book --pre
30+
```
31+
32+
## Cloning or downloading the repository
33+
34+
To clone, please use the usual.
35+
36+
```commandline
37+
git clone https://github.com/MarinhoLab/OpenExecutableBooksRobotics.git
38+
```
39+
40+
Further, the package can be downloaded from [here](https://github.com/MarinhoLab/OpenExecutableBooksRobotics/archive/refs/heads/main.zip).
41+
42+
## Building the book
43+
44+
### Live document
45+
46+
```commandline
47+
jupyter book start
48+
```
49+
50+
Then click on the link, output below
51+
52+
```
53+
✨✨✨ Starting Book Theme ✨✨✨
54+
55+
56+
57+
🔌 Server started on port 3000! 🥳 🎉
58+
59+
60+
👉 http://localhost:3000 👈
61+
62+
```
63+
64+
which usually, as described, connects to `http://localhost:3000`.
65+
66+
### Building the HTML
67+
68+
```
69+
jupyter book build --html
70+
```
71+
72+
If needed, the page can be opened at `_build/html/index.html`.
73+
74+
## Notebook configuration
75+
76+
In this version of jupyter notebook, `myst.yml` is the soul of the book. It is very uncommon that `conf.py` is needed.
77+
78+
```{literalinclude} myst.yml
79+
```
80+
81+
Everything in `myst.yml` is standard, aside from the following block.
82+
83+
```{literalinclude} myst.yml
84+
:start-at: #USING DQROBOTICS DEVEL [START]
85+
:end-at: #USING DQROBOTICS DEVEL [END]
86+
```
87+
88+
This is a temporary solution to address notebooks that do not play well together. Currently, a jupyter book spawns one process
89+
of each notebook and results can be nondeterministic if notebooks can affect each other. More information can be seen
90+
[here](https://github.com/jupyter-book/mystmd/issues/1794).
91+
92+
I'm combining that block with a simple use of `sed` to guarantee the initial lessons that use the stable version of `dqrobotics`
93+
run before lessons that need the development version of `dqrobotics.` For more information, see the file below.
94+
95+
```{literalinclude} build_html.sh
96+
```
97+
98+
We currently only need `conf.py` below for math commands in MySt documents.
99+
100+
```{literalinclude} conf.py
101+
```
102+
103+
## Deployment in GitHub
104+
105+
```{important}
106+
It is very common for GitHub Actions to change how it works internally. This can affect, for instance, the version of the
107+
images run by the GitHub Actions runners, how GitHub Pages works, or how artifact upload works. If the workflow mentioned
108+
herein no longer works in the future, it is important to look at initially newer versions of the imported actions.
109+
Currently:
110+
- `actions/checkout@v4`
111+
- `actions/upload-pages-artifact@v3`
112+
- `actions/configure-pages@v4`
113+
- `actions/deploy-pages@v4`
114+
```
115+
116+
This workflow is straightforward and effective. The only external action needed is to set, in your repository,
117+
`⚙Settings > Pages > Build and deployment > Source > GitHub Actions`.
118+
119+
120+
```{literalinclude} .github/workflows/notebook_to_html.yml
121+
```
122+
123+

build_html.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# While 2.0 is not stable
4+
python -m pip install jupyter-book --pre
5+
6+
# Otherwise the links will not be correctly set up for th webpage
7+
export BASE_URL="https://marinholab.github.io/OpenExecutableBooksRobotics"
8+
9+
# This is a bit hacky.
10+
# https://github.com/orgs/jupyter-book/discussions/2055#discussioncomment-13250715
11+
# This is my temporary hacky solution
12+
13+
# Run once without the devel
14+
cp myst.yml _myst.yml
15+
sed -i.bak '/\#USING DQROBOTICS DEVEL \[START\]/,/\#USING DQROBOTICS DEVEL \[END\]/d' myst.yml
16+
echo "RUN ONE, WITHOUT DQROBOTICS DEVEL PAGES"
17+
cat myst.yml
18+
python -m jupyter book build --html --execute
19+
20+
# Run again with the devel. The cached should no longer collide
21+
mv _myst.yml myst.yml
22+
python -m jupyter book build --html --execute
23+
echo "RUN TWO, WITH DQROBOTICS DEVEL PAGES"
24+
cat myst.yml
25+

conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
2+
myst_enable_extensions = [
3+
"dollarmath"
4+
]

loc.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
## From: https://stackoverflow.com/questions/45382122/how-to-count-lines-of-code-in-jupyter-notebook
3+
from json import load
4+
from sys import argv
5+
6+
def loc(nb):
7+
cells = load(open(nb))['cells']
8+
9+
wc = 0
10+
for c in cells:
11+
for a in c['source']:
12+
x = str(a).split()
13+
wc = wc + len(x)
14+
print(f"--- {x} ---")
15+
return wc
16+
17+
def run(ipynb_files):
18+
return sum(loc(nb) for nb in ipynb_files)
19+
20+
if __name__ == '__main__':
21+
print(run(argv[1:]))

myst.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# See docs at: https://mystmd.org/guide/frontmatter
2+
version: 1
3+
4+
project:
5+
id: f420092a-e58c-429b-aca2-fb33c47059c7
6+
jupyter: true # https://mystmd.org/guide/integrating-jupyter
7+
title: "OXBR"
8+
github: https://github.com/MarinhoLab/OpenExecutableBooksRobotics
9+
math:
10+
'\myvec': '\mathbf{\boldsymbol{ #1 }}'
11+
'\mymatrix': '\mathbf{\boldsymbol{ #1 }}'
12+
'\quat': '\mathbf{\boldsymbol{ #1 }}'
13+
'\dual': '\varepsilon'
14+
authors:
15+
- name: Murilo M. Marinho
16+
email: murilo.marinho@manchester.ac.uk
17+
url: https://mmmarinho.github.io
18+
# The LinkedIn key is listed in the docs but gives a warning and does nothing
19+
# linkedin: www.linkedin.com/in/murilo-marques-marinho-046178252
20+
# The GitHub key has no warning but also doesn't do anything
21+
# github: https://github.com/mmmarinho
22+
note: Lecturer in Robotics
23+
orcid: 0000-0003-2795-9484
24+
affiliations:
25+
- id: MMM
26+
institution: The University of Manchester
27+
department: EEE
28+
ror: 027m9bs27
29+
license:
30+
content:
31+
id: CC-BY-NC-SA-4.0
32+
toc:
33+
- file: README.md
34+
- title: "[Basic] Robotics using numpy"
35+
children:
36+
- file: basic_lessons/README.md
37+
- file: basic_lessons/lesson1_tutorial.ipynb
38+
- file: basic_lessons/lesson2_tutorial.ipynb
39+
- file: basic_lessons/lesson3_tutorial.ipynb
40+
- file: basic_lessons/lesson4_tutorial.ipynb
41+
- file: basic_lessons/lesson5_tutorial.ipynb
42+
- title: "[Advanced] DQ Robotics"
43+
children:
44+
- file: dqrobotics/README.md
45+
- file: dqrobotics/lesson1/lesson_dq1_python_basics.ipynb
46+
- file: dqrobotics/lesson2/lesson_dq2_quaternion_basics.ipynb
47+
- file: dqrobotics/lesson3/lesson_dq3_dual_quaternion_basics_part1.ipynb
48+
- file: dqrobotics/lesson4/lesson_dq4_dual_quaternion_basics_part2.ipynb
49+
- file: dqrobotics/lesson5/lesson_dq5_robot_control_basics_part1.ipynb
50+
- file: dqrobotics/lesson6/lesson_dq6_robot_control_basics_part2.ipynb
51+
- file: dqrobotics/lesson7/lesson_dq7_robot_control_basics_part3.ipynb
52+
- file: dqrobotics/lesson8/lesson_dq8_optimization_based_robot_control.ipynb
53+
- file: book.md
54+
- file: CHANGELOG.md
55+
- file: TODO.md
56+
#USING DQROBOTICS DEVEL [START]
57+
- title: "[Incomplete] Working chapters"
58+
children:
59+
- file: working/README.md
60+
- file: working/adaptive_control.md
61+
#USING DQROBOTICS DEVEL [END]
62+
63+
site:
64+
template: book-theme
65+
title: OXBR Website
66+
options:
67+
logo: M3logo_black.png
68+
logo_dark: M3logo_white.svg
69+
logo_text: "(Murilo's) OXBR"

0 commit comments

Comments
 (0)