···11+#show figure: set block(spacing: 3em)
22+13Unitree met à disposition du public un _SDK_#footnote[Kit de développement logiciel (Software Development Kit)] permettant de contrôler ses robots (dont le H1v2).
2435== Une base de code partiellement open-source
4655-Le code source du SDK d'unitree est disponible sur _Github_ à https://github.com/unitreerobotics/unitree_sdk2. Cependant, le code source comprend des fichiers binaires déjà compilés:
77+Le code source du SDK d'unitree est disponible sur Github @sdk2_source_today. Cependant, le dépôt git comprend des fichiers binaires déjà compilés:
6879#figure(
88- caption: [Résultat de `tree lib thirdparty` dans le dépot git @sdk2_source_today],
1010+ caption: [Résultat de `tree lib thirdparty` dans le dépot git],
911```
1012lib
1113├── aarch64
···32343335Compiler le SDK nécéssite l'existance de ces fichiers binaires:
34363535-#import "@preview/zebraw:0.5.5": zebraw
3737+#import "@preview/zebraw:0.5.5"
3838+#let zebraw = (..args) => zebraw.zebraw(lang: false, background-color: luma(255), ..args)
36393740#figure(
3841 caption: [Extrait de `cmake/unitree_sdk2Targets.cmake`],
3942 zebraw(
4043 numbering-offset: 63 - 1,
4144 highlight-lines: (4,),
4242- lang: false,
4343- background-color: luma(255),
4444- ```cmake
4545- # Create imported target unitree_sdk2
4646- add_library(unitree_sdk2 STATIC IMPORTED GLOBAL)
4747- set_target_properties(unitree_sdk2 PROPERTIES
4848- IMPORTED_LOCATION ${_IMPORT_PREFIX}/lib/libunitree_sdk2.a
4949- INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
5050- INTERFACE_LINK_LIBRARIES "ddsc;ddscxx;Threads::Threads"
5151- LINKER_LANGUAGE CXX
5252- ```
4545+```cmake
4646+# Create imported target unitree_sdk2
4747+add_library(unitree_sdk2 STATIC IMPORTED GLOBAL)
4848+set_target_properties(unitree_sdk2 PROPERTIES
4949+ IMPORTED_LOCATION ${_IMPORT_PREFIX}/lib/libunitree_sdk2.a
5050+ INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
5151+ INTERFACE_LINK_LIBRARIES "ddsc;ddscxx;Threads::Threads"
5252+ LINKER_LANGUAGE CXX
5353+```
5354))
54555556Ici est défini, via `set_target_properties(... IMPORTED_LOCATION)`, le chemin d'une bibliothèque à lier avec la bibliothèque finale @cmake-imported-location.
56575757-== Canaux DDS bas niveau
5858+On confirme ceci en lançant `mkdir build && cd build && cmake ..` après avoir supprimé le répertoire `lib/` :
5959+6060+#{
6161+ show regex(".*CMake Error.*"): set text(fill: red)
6262+ show regex(".*not found.*"): set text(fill: red)
6363+6464+ zebraw(
6565+ highlight-lines: (18, 19),
6666+ numbering: false,
6767+```
6868+-- The C compiler identification is GNU 13.3.0
6969+-- The CXX compiler identification is GNU 13.3.0
7070+-- Detecting C compiler ABI info
7171+-- Detecting C compiler ABI info - done
7272+-- Check for working C compiler: /usr/bin/cc - skipped
7373+-- Detecting C compile features
7474+-- Detecting C compile features - done
7575+-- Detecting CXX compiler ABI info
7676+-- Detecting CXX compiler ABI info - done
7777+-- Check for working CXX compiler: /usr/bin/c++ - skipped
7878+-- Detecting CXX compile features
7979+-- Detecting CXX compile features - done
8080+-- Setting build type to 'Release' as none was specified.
8181+-- Current system architecture: x86_64
8282+-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
8383+-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
8484+-- Found Threads: TRUE
8585+-- Importing: /home/glebihan/playground/unitree_sdk2/thirdparty/lib/x86_64/libddsc.so
8686+-- Importing: /home/glebihan/playground/unitree_sdk2/thirdparty/lib/x86_64/libddscxx.so
8787+8888+CMake Error at CMakeLists.txt:42 (message):
8989+Unitree SDK library for the architecture is not found
9090+9191+9292+-- Configuring incomplete, errors occurred!
9393+```
9494+ )
9595+}
9696+9797+Les logs montrent aussi que les recettes de compilation dépendent de versions précompilées de LibDDSC et LibDDSCXX, dont le code source semble cependant être fourni dans le code source:
9898+9999+```sh-session
100100+thirdparty/include/dds
101101+├── config.h
102102+├── ddsc
103103+│ ├── dds_basic_types.h
104104+│ ├── dds_data_allocator.h
105105+│ ├── dds_internal_api.h
106106+│ ├── dds_loan_api.h
107107+│ ├── dds_opcodes.h
108108+│ ├── dds_public_alloc.h
109109+...
110110+```
111111+112112+Ces particularités laissent planner quelques doutes sur la nature open-source du code: ces binaires requis sont-ils seulement présent pour améliorer l'expérience développeur en accélererant la compilation, ou "cachent"-ils du code non public?
5811359114== Rétroingénierie des binaires
115115+116116+Ces constats ont motivé une première tentative de décompilation de ces `libunitree_sdk2.a` pour comprendre le fonctionnement du SDK2.
117117+118118+== Canaux DDS bas niveau
6011961120== Un autre bridge existant: `unitree_mujoco`
62121