Skip to content

Commit

Permalink
updated to current rai
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcToussaint committed Jun 14, 2024
1 parent 7de8cb4 commit 569c60d
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 41 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
python-version: '3.10'
- name: install ubuntu dependencies
run: |
sudo apt-get install libboost-system-dev libfcl-dev=0.5.0
sudo apt-get install libboost-system-dev libccd-dev
APTGETYES=1 make -C rai -j1 installUbuntuAll
- name: install source dependencies
run: |
wget https://github.com/MarcToussaint/rai-extern/raw/main/install.sh; chmod a+x install.sh
./install.sh fcl
- name: install python dependencies
run: |
pip install numpy pybind11
Expand All @@ -30,6 +34,8 @@ jobs:
- name: cmake configure
run: |
export PY_VER=`python3 -c "import sys; print(str(sys.version_info[0])+'.'+str(sys.version_info[1]))"`
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_PHYSX=OFF -DUSE_BULLET=OFF -DUSE_LIBFRANKA=OFF -DUSE_REALSENSE=OFF -DUSE_H5=OFF -DPY_VERSION=$PY_VER -DUSE_QHULL8=ON .
- name: make build
run: make -C build
cmake . -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_PHYSX=OFF -DUSE_BULLET=OFF -DUSE_LIBFRANKA=OFF -DUSE_REALSENSE=OFF -DUSE_H5=OFF -DPY_VERSION=$PY_VER -DUSE_QHULL8=ON
- name: build
run: make -C build _robotic bot install
- name: test
run: ry-info
4 changes: 2 additions & 2 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
pip install sphinx sphinx_rtd_theme myst_parser nbsphinx robotic numpy
- name: Sphinx build
run: |
cd rai-docs && git fetch --all && git reset --hard origin/main
cd rai-tutorials && git fetch --all && git reset --hard origin/main
cd .. && sphinx-build doc ../html
cd ../rai-docs && git fetch --all && git reset --hard origin/main
sphinx-build doc ../html
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "rai-docs"]
path = rai-docs
url = ../rai-docs.git
[submodule "rai-tutorials"]
path = rai-tutorials
url = ../rai-tutorials.git
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PY_VER = $(shell python3 -c "import sys; print(str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
PY_SITE = $(shell python3 -m site --user-site)

default: docs

Expand All @@ -12,11 +13,11 @@ local-install:
ln -f -s _build_utils/CMakeLists-ubuntu.txt CMakeLists.txt
-rm -f ${HOME}/.local/lib/*rai*
cmake . -B build
+make -C build _robotic docstrings install
cp build/_robotic.pyi ${HOME}/.local/lib/python$(PY_VER)/site-packages/robotic
+make -C build _robotic docstrings install -j $(command nproc --ignore 2)
cp build/_robotic.pyi $(PY_SITE)

local-clean:
-rm -Rf ${HOME}/.local/lib/python$(PY_VER)/site-packages/robotic*
-rm -Rf $(PY_SITE)
-rm -f ${HOME}/.local/lib/*rai*
-rm -f ${HOME}/.local/bin/*ry*

Expand All @@ -36,14 +37,17 @@ wheels-install:
test:
cd ${HOME} && python3 -c 'import robotic as ry; print("ry version:", ry.__version__, ry.compiled());'

test2:
ry-view $(PY_SITE)/rai-robotModels/scenarios/pandasTable.g

test-tutorials:
make -j1 -C rai-docs/rai-tutorials run
make -j1 -C rai-tutorials run

pull:
cd rai && git pull
cd rai-robotModels && git pull
cd rai-docs && git pull
cd rai-docs/rai-tutorials && git pull
cd rai-tutorials && git pull
cd botop && git pull

docker-clean:
Expand Down
36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,23 @@ pip install robotic
ry-info
```
```
python3 -c 'import robotic as ry; print("ry version:", ry.__version__, ry.compiled());'
```
```
python3 -c 'import robotic as ry; ry.test.RndScene()'
```
<!--
If the `rai-robotModels` path fails, find rai-robotModels and try something like
```
python3 -c 'import robotic as ry; ry.setRaiPath("/usr/local/rai-robotModels"); ry.test.RndScene()'
```
When rai-robotModels is still messed up, try cloning it completely:
ry-view `python3 -m site --user-site`/robotic/rai-robotModels/scenarios/pandaSingle.g
```
cd ~/.local; rm -Rf rai-robotModels;
git clone https://github.com/MarcToussaint/rai-robotModels.git
* Run all tutorial notebooks as a test and showcase (takes long):
```
* You can download other examples and test:
```
wget https://github.com/MarcToussaint/robotic/raw/master/examples/skeleton-solving-example.py
python3 skeleton-solving-example.py
```
-->
pip install jupyter nbconvert matplotlib
git clone https://github.com/MarcToussaint/rai-tutorials.git
cd rai-tutorials
make run -j1
``
## Installation from source with real Franka & realsense support
This assumes a standard Ubuntu 20.04 (or 18.04) machine.
This assumes a standard Ubuntu 22.04 (or 20.04, 18.04) machine.
* Install Ubuntu and python packages:
Expand Down Expand Up @@ -107,7 +98,7 @@ This assumes a standard Ubuntu 20.04 (or 18.04) machine.
You need to log out and back in (or even reboot) for this to take
effect. Check with `groups` in a terminal.
* Follow the [Real Robot Operation Tutorial](https://marctoussaint.github.io/robotic/tutorials/botop_2_real_robot.html) on the [tutorials page](https://marctoussaint.github.io/robotic/tutorials/) to test and debug first steps with the real franka.
* Follow the [Real Robot Operation Tutorial](https://marctoussaint.github.io/robotic/tutorials/botop_2_real_robot.html) on the [tutorials page](https://marctoussaint.github.io/robotic/tutorials.html) to test and debug first steps with the real franka.
## Building the wheels within a manylinux docker
Expand All @@ -116,13 +107,10 @@ This assumes a standard Ubuntu 20.04 (or 18.04) machine.
_build_utils/build-docker.sh
```
* Run docker and compile wheels inside
* Compile wheels (this runs `local/_build_utils/build-wheels.sh`
inside the docker -- see `Makefile`)
```
_build_utils/run-docker.sh
## inside docker:
cd local #this mounts robotic/
_build_utils/build-wheels.sh
exit
make wheels
```
* Outside of docker, install locally with pip or push wheels to pypi
Expand Down
3 changes: 2 additions & 1 deletion _build_utils/CMakeLists-ubuntu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ link_directories(
if(USE_PHYSX)
link_directories($ENV{HOME}/.local/lib/PhysX)
endif()

if(USE_H5)
link_directories(/usr/lib/x86_64-linux-gnu/hdf5/serial)
endif()
Expand Down Expand Up @@ -227,7 +228,7 @@ install(
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE}/robotic)

install(
FILES robotic/__init__.py robotic/version.py robotic/render.py robotic/_robotic.pyi
FILES robotic/__init__.py robotic/version.py robotic/render.py robotic/nlp.py robotic/_robotic.pyi
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE}/robotic)

install(
Expand Down
2 changes: 1 addition & 1 deletion _build_utils/build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mv robotic/include/src robotic/include/rai
export PYTHONPATH=.

### build each version
for ver in 8 9 10 11 6 7; do
for ver in 10 11 7 8 9; do
echo -e "\n\n======== compiling (python version " $ver ") ========"
cmake -B build_wheel -DPY_VERSION=3.$ver .
make -C build_wheel rai _robotic meshTool --quiet
Expand Down
2 changes: 1 addition & 1 deletion rai
Submodule rai updated 48 files
+1 −1 _make/config.mk.default
+8 −6 _make/defines.mk
+6 −0 _make/generic.mk
+1 −1 src/Algo/Makefile
+1 −0 src/Core/defines.h
+1 −1 src/Core/graph.cpp
+2 −1 src/Core/h5.cpp
+8 −8 src/Core/util.cpp
+2 −2 src/Core/util.h
+9 −11 src/Geo/mesh.cpp
+1 −2 src/Geo/qhull.cpp
+27 −180 src/Gui/opengl.cpp
+18 −60 src/Gui/opengl.h
+1 −1 src/KOMO/komo.cpp
+1 −1 src/KOMO/komo.h
+1 −1 src/KOMO/splined.cpp
+4 −2 src/Kin/frame.cpp
+13 −7 src/Kin/kin.cpp
+58 −174 src/Kin/kin_feather.cpp
+1 −0 src/Kin/kin_feather.h
+7 −11 src/Kin/viewer.cpp
+1 −1 src/LGP/LGP_computers.cpp
+1 −1 src/Optim/Makefile
+5 −24 src/Optim/NLP.cpp
+0 −10 src/Optim/NLP.h
+280 −91 src/Optim/NLP_Sampler.cpp
+36 −17 src/Optim/NLP_Sampler.h
+3 −3 src/Optim/NLP_Solver.cpp
+1 −0 src/Optim/NLP_Solver.h
+3 −2 src/Optim/benchmarks.cpp
+1 −1 src/Optim/constrained.h
+2 −3 src/Optim/opt-ceres.cpp
+2 −2 src/Optim/opt-ipopt.cpp
+1 −2 src/Optim/opt-nlopt.cpp
+0 −7 src/Optim/retired/Graph_Problem.cpp
+0 −2 src/Optim/retired/Graph_Problem.h
+0 −2 src/Optim/retired/KOMO_Problem.h
+0 −2 src/Optim/retired/convert.h
+2 −5 src/Optim/utils.h
+3 −3 src/ry/py-Config.cpp
+49 −6 src/ry/py-Optim.cpp
+4 −3 test/Algo/ML-regression/main.cpp
+6 −24 test/Gui/opengl/main.cpp
+1 −1 test/Gui/opengl_mini/main.cpp
+3 −2 test/KOMO/timeopt/main.cpp
+39 −67 test/Kin/kin/main.cpp
+1 −1 test/Optim/constrained/lecture.cpp
+1 −1 test/Optim/constrained/main.cpp
2 changes: 1 addition & 1 deletion rai-docs
Submodule rai-docs updated 3 files
+0 −3 .gitmodules
+1 −1 doc/tutorials
+0 −1 rai-tutorials
1 change: 1 addition & 0 deletions rai-tutorials
Submodule rai-tutorials added at 2529d5
131 changes: 131 additions & 0 deletions robotic/nlp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import numpy as np

class OT():
none = 0
f = 1
sos = 2
ineq = 3
eq = 4


class NLP():
"""
Non-Linear Mathematical Program
min_x 1^T phi_f(x) + phi_sos(x)^T phi_sos(x)
s.t. phi_eq(x) = 0
phi_ineq(x) <= 0
B[0] <= x <= B[1]
where:
x is a continous variable, in vector space R^n
phi_f is a vector of cost terms
phi_sos is a vector of sum-of-square cost terms
phi_eq is a vector of equality constraints
phi_ineq is a vector of inequality constraints
B[0] and B[1] in R^n are, respectively, the lower and upper box bounds
See Also:
-----
NLPTraced
"""

def __init__(self, *args, **kwargs):
pass

def evaluate(self, x):
"""
query the NLP at a point x; returns the tuple (phi,J), which is
the feature vector and its Jacobian; features define cost terms,
sum-of-square (sos) terms, inequalities, and equalities depending
on 'getFeatureTypes'.
If the returned Jacobian has 3 columns and #rows non-equal to
dim(phi) it should be interpreted by solvers as sparse in
triple format; the C++ solvers exploit such sparse Jacobians,
e.g., to efficiently compute Gauss-Newton steps.
Parameters
------
x: np.array, 1-D
Returns
------
phi: np.array 1-D
J: np.array 2-D. J[i,j] is derivative of feature i w.r.t variable j
"""
raise NotImplementedError()

def getDimension(self):
"""
return the dimensionality of x
Returns
-----
output: integer
"""
raise NotImplementedError()

def getBounds(self):
"""
returns 2-times-n array, where n is the dimensionality of x
B[0] is the lower and B[1] the upper bounds, so that B[0] <= x <= B[1]
Returns
------
B: np.array 2D (2-times-n)
"""
n = self.getDimension()
return np.tile([[-np.Inf], [+np.Inf]], (1,n))

def getFeatureTypes(self):
"""
returns
-----
output: list of feature Types
"""
return [OT.f]

def getFHessian(self, x):
"""
Returns Hessian of the $f$ objective
Default: all zeros
Returns
-----
hessian: np.array 2D
"""
n = self.getDimension()
return np.zeros((n, n))

def getInitializationSample(self):
"""
returns a sample (e.g. uniform within bounds) to initialize an optimization -- not necessarily feasible
Returns
-----
x: np.array 1-D
"""
return np.ones(self.getDimension())

def report(self, verbose):
"""
displays semantic information on the last query
Parameters
----
Returns
----
output: string
"""
raise NotImplementedError()
2 changes: 1 addition & 1 deletion robotic/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.9b'
__version__ = '0.1.11'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def has_ext_modules(foo):
#packages=['robotic'],
packages=setuptools.find_namespace_packages(),
package_data={
'robotic': ['_robotic.so', 'librai.so', 'meshTool', '_robotic.pyi', 'version.py', 'render.py',
'robotic': ['_robotic.so', 'librai.so', 'meshTool', '_robotic.pyi', 'version.py', 'render.py', 'nlp.py',
'rai-robotModels/*/*', 'rai-robotModels/*/*/*', 'rai-robotModels/*/*/*/*', 'rai-robotModels/*/*/*/*/*', 'rai-robotModels/*/*/*/*/*/*',
'include/rai/*/*', 'include/rai/*/*/*']
},
Expand Down

0 comments on commit 569c60d

Please sign in to comment.