Skip to content

Commit 6454dd4

Browse files
committed
default installation to minimal dependencies, updated cython function, updated animation for matplotlib>=3.8
1 parent 4047c1b commit 6454dd4

File tree

9 files changed

+47
-22
lines changed

9 files changed

+47
-22
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ install: python cpp
1010
python:
1111
make -C $(PYTHON_ROOT)
1212

13+
pythonfull:
14+
make -C $(PYTHON_ROOT) full
15+
1316
cpp:
1417
make -C $(CPP_ROOT)
1518

docs/text/installation.rst

+12-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ We recommend using a virtual python environment.
1818
sudo apt-get install libyaml-cpp-dev libeigen3-dev libpython3.8 libx11-6 libsm6 libxt6 libglib2.0-0 python3-sphinx python3-numpydoc python3-sphinx-rtd-theme
1919

2020
# ubuntu22
21-
sudo apt-get install libyaml-cpp-dev libeigen3-dev libx11-6 libsm6 libglib2.0-0 python3-sphinx python3-numpydoc python3-sphinx-rtd-theme
21+
sudo apt-get install libyaml-cpp-dev libeigen3-dev libx11-6 libsm6 libglib2.0-0 libboost-dev python3-sphinx python3-numpydoc python3-sphinx-rtd-theme
2222

2323

2424
2. Clone the repository::
@@ -32,18 +32,28 @@ We recommend using a virtual python environment.
3232
make install
3333

3434

35-
With this you are done. The following two bullet points may be useful when only
35+
With this you are done and you can use all functionalities and some controllers in this repository.
36+
If you want install all requirements (this includes also larger depoendencies
37+
such as tensorflow, drake etc.) for all controllers do
38+
39+
4. (Optional) Full installation ::
40+
41+
make pythonfull
42+
43+
The following two bullet points may be useful when only
3644
the C++/Python code is needed, if you work on the code and need to recompile
3745
often, or if errors appear during the installation call in 3.
3846

3947
4. If you want to install only the Python package, you can do::
4048

4149
make python
50+
# make pythonfull
4251

4352
# or
4453

4554
cd src/python
4655
pip install .
56+
# pip install .[all]
4757

4858
5. If you want to build C++ code and install python bindings::
4959

examples/realistic/ilqr_mpc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
perturbation_array, _, _, _ = get_random_gauss_perturbation_array(
7171
t_final, dt, 3, 1.0, [0.01, 0.05], [0.1, 1.0]
7272
)
73-
plot_perturbation_array(t_final, dt, perturbation_array)
73+
# plot_perturbation_array(t_final, dt, perturbation_array)
7474

7575
# filter args
7676
lowpass_alpha = [1.0, 1.0, 0.3, 0.3]

examples/realistic/lqr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
perturbation_array, _, _, _ = get_random_gauss_perturbation_array(
7575
t_final, dt, 3, 1.0, [0.01, 0.05], [0.1, 1.0]
7676
)
77-
plot_perturbation_array(t_final, dt, perturbation_array)
77+
# plot_perturbation_array(t_final, dt, perturbation_array)
7878

7979
# filter args
8080
lowpass_alpha = [1.0, 1.0, 0.2, 0.2]

src/cpp/python/cppilqr.pyx

+7-6
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ cdef class cppilqrmpc:
313313

314314
array_wrapper = ArrayWrapper()
315315
array_wrapper.set_data(N-1, <void*> vec)
316-
ar = np.array(array_wrapper, copy=False)
316+
# ar = np.array(array_wrapper, copy=False)
317+
ar = np.array(array_wrapper)
317318
ar.base = <PyObject*> array_wrapper
318319
Py_INCREF(array_wrapper)
319320
return ar
@@ -326,7 +327,7 @@ cdef class cppilqrmpc:
326327

327328
array_wrapper = ArrayWrapper()
328329
array_wrapper.set_data(N-1, <void*> vec)
329-
ar = np.array(array_wrapper, copy=False)
330+
ar = np.array(array_wrapper)
330331
ar.base = <PyObject*> array_wrapper
331332
Py_INCREF(array_wrapper)
332333
return ar
@@ -339,7 +340,7 @@ cdef class cppilqrmpc:
339340

340341
array_wrapper = ArrayWrapper()
341342
array_wrapper.set_data(N, <void*> vec)
342-
ar = np.array(array_wrapper, copy=False)
343+
ar = np.array(array_wrapper)
343344
ar.base = <PyObject*> array_wrapper
344345
Py_INCREF(array_wrapper)
345346
return ar
@@ -352,7 +353,7 @@ cdef class cppilqrmpc:
352353

353354
array_wrapper = ArrayWrapper()
354355
array_wrapper.set_data(N, <void*> vec)
355-
ar = np.array(array_wrapper, copy=False)
356+
ar = np.array(array_wrapper)
356357
ar.base = <PyObject*> array_wrapper
357358
Py_INCREF(array_wrapper)
358359
return ar
@@ -365,7 +366,7 @@ cdef class cppilqrmpc:
365366

366367
array_wrapper = ArrayWrapper()
367368
array_wrapper.set_data(N, <void*> vec)
368-
ar = np.array(array_wrapper, copy=False)
369+
ar = np.array(array_wrapper)
369370
ar.base = <PyObject*> array_wrapper
370371
Py_INCREF(array_wrapper)
371372
return ar
@@ -378,7 +379,7 @@ cdef class cppilqrmpc:
378379

379380
array_wrapper = ArrayWrapper()
380381
array_wrapper.set_data(N, <void*> vec)
381-
ar = np.array(array_wrapper, copy=False)
382+
ar = np.array(array_wrapper)
382383
ar.base = <PyObject*> array_wrapper
383384
Py_INCREF(array_wrapper)
384385
return ar

src/python/double_pendulum/simulation/simulation.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -690,20 +690,20 @@ def _animation_step(self, par_dict):
690690
ani_plot_counter += 1
691691

692692
# plot base
693-
self.animation_plots[ani_plot_counter].set_data(ee_pos[0][0], ee_pos[0][1])
693+
self.animation_plots[ani_plot_counter].set_data([ee_pos[0][0]], [ee_pos[0][1]])
694694
ani_plot_counter += 1
695695

696696
# plot bodies
697697
for link in range(self.plant.n_links):
698698
self.animation_plots[ani_plot_counter].set_data(
699-
ee_pos[link + 1][0], ee_pos[link + 1][1]
699+
[ee_pos[link + 1][0]], [ee_pos[link + 1][1]]
700700
)
701701
ani_plot_counter += 1
702702

703703
if self.plot_trail:
704704
self.animation_plots[ani_plot_counter].set_data(
705-
np.asarray(self.ee_poses)[:, link + 1, 0],
706-
np.asarray(self.ee_poses)[:, link + 1, 1],
705+
[np.asarray(self.ee_poses)[:, link + 1, 0]],
706+
[np.asarray(self.ee_poses)[:, link + 1, 1]],
707707
)
708708
ani_plot_counter += 1
709709

@@ -734,7 +734,7 @@ def _animation_step(self, par_dict):
734734
coords = np.asarray(coords)
735735
if len(coords) > 1:
736736
self.animation_plots[ani_plot_counter].set_data(
737-
coords.T[0], coords.T[1]
737+
[coords.T[0]], [coords.T[1]]
738738
)
739739
ani_plot_counter += 1
740740

@@ -747,7 +747,7 @@ def _animation_step(self, par_dict):
747747
coords = np.asarray(coords)
748748
if len(coords) > 1:
749749
self.animation_plots[ani_plot_counter].set_data(
750-
coords.T[0], coords.T[1]
750+
[coords.T[0]], [coords.T[1]]
751751
)
752752
ani_plot_counter += 1
753753

src/python/double_pendulum/simulation/visualization.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def get_arrow(radius, centX, centY, angle_, theta2_, color_="black"):
4747
endY = centY + (radius / 2) * np.sin(rad(theta2_ + angle_))
4848

4949
head = RegularPolygon(
50-
(endX, endY), # (x,y)
51-
3, # number of vertices
52-
radius / 20, # radius
53-
rad(angle_ + theta2_), # orientation
50+
xy=(endX, endY), # (x,y)
51+
numVertices=3, # number of vertices
52+
radius=radius / 20, # radius
53+
orientation=rad(angle_ + theta2_), # orientation
5454
color=color_,
5555
)
5656
return arc, head

src/python/makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
default: double_pendulum_python
22

33
double_pendulum_python: setup.py
4+
pip install .
5+
6+
full: setup.py
47
pip install .[all]

src/python/setup.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dill",
2525
"argparse",
2626
"opencv-python",
27+
"pyyaml",
2728
# c++ python bindings
2829
"cython<1.0.0",
2930
],
@@ -39,7 +40,6 @@
3940
"gymnasium",
4041
"stable_baselines3",
4142
"shimmy",
42-
"pyyaml",
4343
"jax",
4444
"jaxlib",
4545
"flax",
@@ -48,7 +48,15 @@
4848
"doc": ["sphinx", "sphinx-rtd-theme", "numpydoc"],
4949
"test": ["pytest", "lark"],
5050
"OC": ["drake", "meshcat"],
51-
"RL": ["gymnasium", "stable_baselines3", "shimmy", "pyyaml", "jax", "jaxlib", "flax", "tqdm"],
51+
"RL": [
52+
"gymnasium",
53+
"stable_baselines3",
54+
"shimmy",
55+
"jax",
56+
"jaxlib",
57+
"flax",
58+
"tqdm",
59+
],
5260
},
5361
classifiers=[
5462
"Development Status :: 5 - Stable",

0 commit comments

Comments
 (0)