Skip to content

Commit

Permalink
Release/v1.4 (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhu-flexiv authored Jul 15, 2024
1 parent c675f5f commit 7f020e6
Show file tree
Hide file tree
Showing 75 changed files with 2,458 additions and 1,877 deletions.
56 changes: 48 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,48 @@ cmake_minimum_required(VERSION 3.16.3)
# ===================================================================
# PROJECT SETUP
# ===================================================================
project(flexiv_rdk VERSION 1.3.0)
project(flexiv_rdk VERSION 1.4.0)

# Configure build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "CMake build type" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo")

# Set static library
# Configure Python RDK
option(INSTALL_PYTHON_RDK "Install Python RDK (to user site packages path)" OFF)
if(INSTALL_PYTHON_RDK)
if(NOT RDK_PYTHON_VERSION)
set(RDK_PYTHON_VERSION 3.10 CACHE STRING "Python version to install RDK for" FORCE)
endif()
set_property(CACHE RDK_PYTHON_VERSION PROPERTY STRINGS "3.10" "3.12")
find_package(Python3 ${RDK_PYTHON_VERSION} EXACT COMPONENTS Interpreter REQUIRED)
endif()

# Set C++ and Python library filename
message("OS: ${CMAKE_SYSTEM_NAME}")
message("Processor: ${CMAKE_SYSTEM_PROCESSOR}")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libflexiv_rdk.x86_64-linux-gnu.a")
set(RDK_CPP_LIB "libflexiv_rdk.x86_64-linux-gnu.a")
set(RDK_PY_LIB "flexivrdk.cpython-${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}-x86_64-linux-gnu.so")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libflexiv_rdk.aarch64-linux-gnu.a")
set(RDK_CPP_LIB "libflexiv_rdk.aarch64-linux-gnu.a")
set(RDK_PY_LIB "flexivrdk.cpython-${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}-aarch64-linux-gnu.so")
else()
message(FATAL_ERROR "Linux with ${CMAKE_SYSTEM_PROCESSOR} processor is currently not supported.")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libflexiv_rdk.arm64-darwin.a")
set(RDK_CPP_LIB "libflexiv_rdk.arm64-darwin.a")
set(RDK_PY_LIB "flexivrdk.cpython-${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}-darwin.so")
else()
message(FATAL_ERROR "Mac with ${CMAKE_SYSTEM_PROCESSOR} processor is currently not supported.")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/flexiv_rdk.win_amd64.lib")
set(RDK_CPP_LIB "flexiv_rdk.win_amd64.lib")
set(RDK_PY_LIB "flexivrdk.cp${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}-win_amd64.pyd")
else()
message(FATAL_ERROR "Windows with ${CMAKE_SYSTEM_PROCESSOR} processor is currently not supported.")
endif()
Expand All @@ -52,6 +66,12 @@ if(Eigen3_FOUND)
message(STATUS "Found Eigen3: ${Eigen3_DIR}")
endif()

# spdlog
find_package(spdlog REQUIRED)
if(spdlog_FOUND)
message(STATUS "Found spdlog: ${spdlog_DIR}")
endif()

# Fast-CDR
find_package(fastcdr 1.0.24 REQUIRED)
if(fastcdr_FOUND)
Expand All @@ -65,7 +85,7 @@ if(fastrtps_FOUND)
endif()

# ===================================================================
# CREATE LIBRARY
# INSTALL C++ LIBRARY
# ===================================================================
# Create an INTERFACE library with no source file to compile
add_library(${PROJECT_NAME} INTERFACE)
Expand All @@ -80,9 +100,10 @@ target_include_directories(${PROJECT_NAME} INTERFACE
)

target_link_libraries(${PROJECT_NAME} INTERFACE
${RDK_STATIC_LIBRARY}
${CMAKE_CURRENT_SOURCE_DIR}/lib/${RDK_CPP_LIB}
Threads::Threads
Eigen3::Eigen
spdlog::spdlog
fastrtps
fastcdr
)
Expand All @@ -95,5 +116,24 @@ else()
endif()

# Install the INTERFACE library
message(STATUS "C++ RDK library: ${RDK_CPP_LIB}")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FlexivInstallLibrary.cmake)
FlexivInstallLibrary()

# ===================================================================
# INSTALL PYTHON LIBRARY
# ===================================================================
if(INSTALL_PYTHON_RDK)
# Get user site packages path
message(STATUS "Python executable: ${Python3_EXECUTABLE}")
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import site; print(site.getusersitepackages())"
OUTPUT_VARIABLE USER_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Python site packages path: ${USER_SITE}")

# Install Python RDK to user site packages path
message(STATUS "Python RDK library: ${RDK_PY_LIB}")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib_py/${RDK_PY_LIB}" DESTINATION ${USER_SITE})
endif()
121 changes: 68 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,93 +15,108 @@ Flexiv RDK (Robotic Development Kit), a key component of the Flexiv Robotic Soft
| -------------------------- | ----------------------- | ---------------------- | ------------------------- |
| Linux (Ubuntu 20.04/22.04) | x86_64, arm64 | C++, Python | build-essential |
| macOS 12 and above | arm64 | C++, Python | Xcode Command Line Tools |
| Windows 10/11 | x86_64 | C++, Python | MSVC v142+ |
| Windows 10/11 | x86_64 | C++, Python | MSVC v14.2+ |

## Quick Start

The **C++ and Python** RDK libraries are packed into a unified modern CMake project named ``flexiv_rdk``, which can be configured and installed via CMake on all supported OS.

### Note

* The full documentation is in [Flexiv RDK Manual](https://rdk.flexiv.com/manual/).
* You might need to turn off your computer's firewall to be able to connect to the robot.
* The instructions below serve as a quick reference. You can find the full documentation at [Flexiv RDK Manual](https://rdk.flexiv.com/manual/).
* You might need to turn off your computer's firewall or whitelist the RDK programs to be able to establish connection with the robot.

### C++ RDK
### Install on Linux

The C++ interface of Flexiv RDK is packed into a unified modern CMake library named ``flexiv_rdk``, which can be configured via CMake on all supported OS.
1. In a new Terminal, install compiler kit, CMake (with GUI), Python interpreter, and Python package manager:

NOTE: if you will only be using Python RDK, you can skip this section and jump to [Python RDK](#python-rdk).
sudo apt install build-essential cmake cmake-qt-gui python3 python3-pip -y

#### Compile and install for Linux
2. Choose a directory for installing C++ RDK library and all its dependencies. This directory can be under system path or not, depending on whether you want RDK to be globally discoverable by CMake. For example, a new folder named ``rdk_install`` under the home directory.
3. In a new Terminal, run the provided script to compile and install all C++ dependencies to the installation directory chosen in step 2:

1. In a new Terminal, install C++ compiler, Git, and CMake (with GUI) using the package manager:
cd flexiv_rdk/thirdparty
bash build_and_install_dependencies.sh ~/rdk_install

sudo apt install build-essential git cmake cmake-qt-gui -y
4. In a new Terminal, use CMake to configure the ``flexiv_rdk`` project:

2. Choose a directory for installing ``flexiv_rdk`` library and all its dependencies. For example, a new folder named ``rdk_install`` under the home directory.
3. In a new Terminal, run the provided script to compile and install all dependencies to the installation directory chosen in step 2:
cd flexiv_rdk
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install -DINSTALL_PYTHON_RDK=ON

cd flexiv_rdk/thirdparty
bash build_and_install_dependencies.sh ~/rdk_install
NOTE: ``-D`` followed by ``CMAKE_INSTALL_PREFIX`` sets the CMake variable that specifies the path of the installation directory. ``-D`` followed by ``INSTALL_PYTHON_RDK=ON`` enables the installation of Python RDK besides C++ RDK. The configuration process can also be done using CMake GUI.

4. In a new Terminal, use CMake to configure ``flexiv_rdk``:
5. Install C++ and Python RDK:

cd flexiv_rdk
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
cd flexiv_rdk/build
cmake --build . --target install --config Release

NOTE: ``-D`` followed by ``CMAKE_INSTALL_PREFIX`` is a CMake parameter specifying the path of the chosen installation directory. Alternatively, this configuration step can also be done through CMake GUI.
C++ RDK is installed to the path specified by ``CMAKE_INSTALL_PREFIX``, which may or may not be globally discoverable by CMake. Python RDK is installed to the user site packages path, which is globally discoverable by Python interpreter.

5. Compile and install ``flexiv_rdk`` library:
### Install on macOS

cd flexiv_rdk/build
cmake --build . --target install --config Release
1. Install compiler kit: In a new Terminal, enter command ``xcode-select`` to invoke the installation of Xcode Command Line Tools, then follow the prompted window to finish the installation.
2. Install CMake (with GUI): Download ``cmake-3.x.x-macos-universal.dmg`` from [CMake download page](https://cmake.org/download/) and install the dmg file. The minimum required version is 3.16.3. When done, start CMake from Launchpad and navigate to Tools -> How to Install For Command Line Use. Then follow the instruction "Or, to install symlinks to '/usr/local/bin', run:" to install ``cmake`` and ``cmake-gui`` commands for use in Terminal.
3. Install Python interpreter and package manager (replace "3.x" with the actual Python3 version you wish to use):

NOTE: the installation of ``flexiv_rdk`` library is complete now. The following steps show how to link to the installed library from a user project.
brew install [email protected]

6. To find and link to the installed ``flexiv_rdk`` library from a user project, using the provided example project for instance:
4. The rest are identical to steps 2 and below in [Install on Linux](#install-on-linux).

cd flexiv_rdk/example
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
cmake --build . --config Release -j 4
### Install on Windows

NOTE: ``-D`` followed by ``CMAKE_INSTALL_PREFIX`` tells user project's CMake where to find the installed ``flexiv_rdk`` library.
1. Install compiler kit: Download and install Microsoft Visual Studio 2019 (MSVC v14.2) or above. Choose "Desktop development with C++" under the *Workloads* tab during installation. You only need to keep the following components for the selected workload:
* MSVC ... C++ x64/x86 build tools (Latest)
* C++ CMake tools for Windows
* Windows 10 SDK or Windows 11 SDK, depending on your actual Windows version
2. Install CMake (with GUI): Download ``cmake-3.x.x-windows-x86_64.msi`` from [CMake download page](https://cmake.org/download/) and install the msi file. The minimum required version is 3.16.3. **Add CMake to system PATH** when prompted, so that ``cmake`` and ``cmake-gui`` command can be used from Command Prompt or a bash emulator.
3. Install bash emulator: Download and install [Git for Windows](https://git-scm.com/download/win/), which comes with a bash emulator Git Bash.
4. Within the bash emulator, the rest are identical to steps 2 and below in [Install on Linux](#install-on-linux).

7. Assuming the system setup detailed in the Flexiv RDK Manual is done, to run an compiled example program:
### Link to C++ RDK from a user program

./<program_name> [robot_serial_number]
After C++ RDK is installed, it can be found as a CMake library and linked to by other CMake projects. Use the provided examples project for instance::

For example:
cd flexiv_rdk/example
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
cmake --build . --config Release -j 4

./display_robot_states Rizon4s-123456
NOTE: ``-D`` followed by ``CMAKE_INSTALL_PREFIX`` tells the user project's CMake where to find the installed C++ RDK library. The instruction above applies to all supported OS.

Note: ``sudo`` is not required unless prompted by the program.
### Run example programs

#### Compile and install for macOS
#### C++

1. In a Terminal, use ``xcode-select`` command to invoke the installation of Xcode Command Line Tools, then follow the prompted window to finish the installation.
2. Download ``cmake-3.x.x-macos-universal.dmg`` from [CMake download page](https://cmake.org/download/) and install the dmg file. The minimum required version is 3.16.3.
3. When done, start CMake from Launchpad and navigate to Tools -> How to Install For Command Line Use. Then follow the instruction "Or, to install symlinks to '/usr/local/bin', run:" to install ``cmake`` and ``cmake-gui`` command for use in Terminal.
4. The rest steps are the same as [Compile and install for Linux](#compile-and-install-for-linux), beginning from step 2.
To run a compiled example C++ program:

#### Compile and install for Windows
cd flexiv_rdk/example/build
./<program_name> [robot_serial_number]

1. Install Microsoft Visual Studio 2019 (MSVC v142) or above . Choose "Desktop development with C++" under the *Workloads* tab during installation. You only need to keep the following components for the selected workload:
* MSVC ... C++ x64/x86 build tools (Latest)
* C++ CMake tools for Windows
* Windows 10 SDK or Windows 11 SDK, depending on your actual Windows version
2. Download ``cmake-3.x.x-windows-x86_64.msi`` from [CMake download page](https://cmake.org/download/) and install the msi file. The minimum required version is 3.16.3. **Add CMake to system PATH** when prompted, so that ``cmake`` and ``cmake-gui`` command can be used from Command Prompt or a bash emulator.
3. Install a bash emulator. Git Bash that comes with Git (for Windows) installation is recommended.
4. Within the bash emulator, the rest steps are the same as [Compile and install for Linux](#compile-and-install-for-linux), beginning from step 2.
For example:

./basics1_display_robot_states Rizon4s-123456

NOTE: ``sudo`` is only required if the real-time scheduler API ``flexiv::rdk::Scheduler`` is used.

#### Python

To run a example Python program:

cd flexiv_rdk/example_py
python3 <program_name>.py [robot_serial_number]

### Python RDK
For example:

Python 3.10 and 3.12 are supported by RDK, see Flexiv RDK Manual for more details. A brief instruction is provided below and applies to all supported OS.
python3 ./basics1_display_robot_states.py Rizon4s-123456

1. Check Python version is 3.10.x or 3.12.x:
## API Documentation

python3 --version
The complete and detailed API documentation of the **latest release** can be found at https://rdk.flexiv.com/api/. The API documentation of a previous release can be generated manually using Doxygen. For example, on Linux:

2. Assume the system setup detailed in Flexiv RDK Manual is done, to run an example Python program:
sudo apt install doxygen-latex graphviz
cd flexiv_rdk
git checkout <previous_release_tag>
doxygen doc/Doxyfile.in

cd flexiv_rdk/example_py
python3 <program_name>.py [robot_serial_number]
The generated API documentation is under ``flexiv_rdk/doc/html/`` directory. Open any html file with your browser to view it.
1 change: 1 addition & 0 deletions cmake/flexiv_rdk-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include(CMakeFindDependencyMacro)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_dependency(Threads REQUIRED)
find_dependency(Eigen3 REQUIRED)
find_dependency(spdlog REQUIRED)
find_dependency(fastrtps 2.6.2 REQUIRED)
find_dependency(fastcdr 1.0.24 REQUIRED)

Expand Down
Loading

0 comments on commit 7f020e6

Please sign in to comment.