Skip to content

Commit

Permalink
Pre-release/v1.0 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhu-flexiv authored May 8, 2023
1 parent a9931cb commit 52043d1
Show file tree
Hide file tree
Showing 546 changed files with 939 additions and 169,122 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CMake

on:
push:
branches: [main]
branches: [main, v1.x]
pull_request:
branches: [main]
branches: [main, v1.x]
workflow_dispatch:

env:
Expand All @@ -22,8 +22,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Build and install dependencies
# Build and install all dependencies to RDK installation directory.
run: |
cd ${{github.workspace}}
cd thirdparty
bash build_and_install_dependencies.sh ~/rdk_install
- name: Build and install library
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to an external directory.
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to RDK installation directory.
run: |
cd ${{github.workspace}}
mkdir -p build && cd build
Expand Down Expand Up @@ -56,8 +63,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Build and install dependencies
# Build and install all dependencies to RDK installation directory.
run: |
cd ${{github.workspace}}
cd thirdparty
bash build_and_install_dependencies.sh ~/rdk_install
- name: Build and install library
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to an external directory.
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to RDK installation directory.
run: |
cd ${{github.workspace}}
mkdir -p build && cd build
Expand Down Expand Up @@ -90,8 +104,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Build and install dependencies
# Build and install all dependencies to RDK installation directory.
run: |
cd ${{github.workspace}}
cd thirdparty
bash build_and_install_dependencies.sh ~/rdk_install
- name: Build and install library
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to an external directory.
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to RDK installation directory.
run: |
cd ${{github.workspace}}
mkdir build && cd build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
.DS_Store
config.h
build/
cloned/
html/
__pycache__
48 changes: 36 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.4)
# ===================================================================
# PROJECT CONFIG
# ===================================================================
project(flexiv_rdk VERSION 0.8.0)
project(flexiv_rdk VERSION 1.0.0)

# C++14 required
set(CMAKE_CXX_STANDARD 14)
Expand All @@ -13,27 +13,28 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
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
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/libFlexivRdk.x86_64-linux-gnu.a")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libflexiv_rdk.linux-gnu-x86_64.a")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libFlexivRdk.aarch64-linux-gnu.a")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libflexiv_rdk.linux-gnu-aarch64.a")
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/libFlexivRdk.arm64-darwin.a")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libflexiv_rdk.darwin-arm64.a")
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/FlexivRdk.win_amd64.lib")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/flexiv_rdk.win-amd64.lib")
else()
message(FATAL_ERROR "Windows with ${CMAKE_SYSTEM_PROCESSOR} processor is currently not supported.")
endif()
Expand All @@ -42,9 +43,30 @@ endif()
# ===================================================================
# PROJECT DEPENDENCIES
# ===================================================================
# pthread
# Threads
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(Threads_FOUND)
message(STATUS "Found Threads: HAVE_PTHREAD = ${THREADS_HAVE_PTHREAD_ARG}")
endif()

# Eigen3
find_package(Eigen3 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX})
if(Eigen3_FOUND)
message(STATUS "Found Eigen3: ${Eigen3_DIR}")
endif()

# Fast-CDR
find_package(fastcdr 1.0.24 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX})
if(fastcdr_FOUND)
message(STATUS "Found fastcdr: ${fastcdr_DIR}")
endif()

# Fast-DDS (Fast-RTPS)
find_package(fastrtps 2.6.2 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX})
if(fastrtps_FOUND)
message(STATUS "Found fastrtps: ${fastrtps_DIR}")
endif()

# ===================================================================
# PROJECT LIBRARIES
Expand All @@ -64,8 +86,16 @@ target_include_directories(${PROJECT_NAME} INTERFACE
target_link_libraries(${PROJECT_NAME} INTERFACE
${RDK_STATIC_LIBRARY}
Threads::Threads
Eigen3::Eigen
fastrtps
fastcdr
)

# librt is required for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(${PROJECT_NAME} INTERFACE -lrt)
endif()

# Use moderate compiler warning option
if(MSVC)
target_compile_options(${PROJECT_NAME} INTERFACE /W1)
Expand All @@ -76,9 +106,3 @@ endif()
# Install the INTERFACE library
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FlexivInstallLibrary.cmake)
FlexivInstallLibrary()

# Also install Eigen headers
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen3/Eigen
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,27 @@ NOTE: if you will only be using Python RDK, you can skip this section and jump t
sudo apt install build-essential git cmake cmake-qt-gui -y

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, use CMake to configure ``flexiv_rdk``:
3. In a new Terminal, run the provided script to compile and install all dependencies to the installation directory chosen in step 1:

cd flexiv_rdk/thirdparty
bash build_and_install_dependencies.sh ~/rdk_install

4. In a new Terminal, use CMake to configure ``flexiv_rdk``:

cd flexiv_rdk
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install

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.

4. Compile and install ``flexiv_rdk`` library:
5. Compile and install ``flexiv_rdk`` library:

cd flexiv_rdk/build
cmake --build . --target install --config Release

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.

5. To find and link to the installed ``flexiv_rdk`` library from a user project, using the provided example project for instance:
6. To find and link to the installed ``flexiv_rdk`` library from a user project, using the provided example project for instance:

cd flexiv_rdk/example
mkdir build && cd build
Expand All @@ -58,11 +63,15 @@ NOTE: if you will only be using Python RDK, you can skip this section and jump t

NOTE: ``-D`` followed by ``CMAKE_INSTALL_PREFIX`` tells user project's CMake where to find the installed ``flexiv_rdk`` library.

6. Assuming the system setup detailed in the Flexiv RDK Manual is done, to run an compiled example program:
7. Assuming the system setup detailed in the Flexiv RDK Manual is done, to run an compiled example program:

./<program_name> [robot_serial_number]

For example:

./<program_name> [robot_ip] [local_ip] [...]
./display_robot_states Rizon4s-123456

Note: ``sudo`` is not required unless prompted by the program saying "root privilege is required".
Note: ``sudo`` is not required unless prompted by the program.

#### Compile and install for macOS

Expand All @@ -89,4 +98,4 @@ Python 3.8 and 3.10 are supported by RDK, see Flexiv RDK Manual for more details
2. Assume the system setup detailed in Flexiv RDK Manual is done, to run an example Python program:

cd flexiv_rdk/example_py
python3 <program_name>.py [robot_ip] [local_ip] [...]
python3 <program_name>.py [robot_serial_number]
3 changes: 3 additions & 0 deletions cmake/flexiv_rdk-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ include(CMakeFindDependencyMacro)
# Find dependency
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_dependency(Threads REQUIRED)
find_dependency(Eigen3 REQUIRED)
find_dependency(fastrtps 2.6.2 REQUIRED)
find_dependency(fastcdr 1.0.24 REQUIRED)

# Add targets file
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
2 changes: 1 addition & 1 deletion doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Flexiv RDK APIs"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "0.8"
PROJECT_NUMBER = "1.0"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
19 changes: 8 additions & 11 deletions example/basics1_display_robot_states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void printDescription()
void printHelp()
{
// clang-format off
std::cout << "Required arguments: [robot IP] [local IP]" << std::endl;
std::cout << " robot IP: address of the robot server" << std::endl;
std::cout << " local IP: address of this PC" << std::endl;
std::cout << "Required arguments: [robot SN]" << std::endl;
std::cout << " robot SN: Serial number of the robot to connect to. "
"Remove any space, for example: Rizon4s-123456" << std::endl;
std::cout << "Optional arguments: None" << std::endl;
std::cout << std::endl;
// clang-format on
Expand All @@ -45,8 +45,7 @@ void printRobotStates(flexiv::Robot& robot, flexiv::Log& log)
// Get the latest robot states
robot.getRobotStates(robotStates);

// Print all robot states in JSON format using the built-in ostream
// operator overloading
// Print all robot states in JSON format using the built-in ostream operator overloading
log.info("Current robot states:");
std::cout << robotStates << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
Expand All @@ -61,14 +60,12 @@ int main(int argc, char* argv[])
flexiv::Log log;

// Parse parameters
if (argc < 3 || flexiv::utility::programArgsExistAny(argc, argv, {"-h", "--help"})) {
if (argc < 2 || flexiv::utility::programArgsExistAny(argc, argv, {"-h", "--help"})) {
printHelp();
return 1;
}
// IP of the robot server
std::string robotIP = argv[1];
// IP of the workstation PC running this program
std::string localIP = argv[2];
// Serial number of the robot to connect to. Remove any space, for example: Rizon4s-123456
std::string robotSN = argv[1];

// Print description
log.info("Tutorial description:");
Expand All @@ -78,7 +75,7 @@ int main(int argc, char* argv[])
// RDK Initialization
// =========================================================================================
// Instantiate robot interface
flexiv::Robot robot(robotIP, localIP);
flexiv::Robot robot(robotSN);

// Clear fault on robot server if any
if (robot.isFault()) {
Expand Down
16 changes: 7 additions & 9 deletions example/basics2_clear_fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ void printDescription()
void printHelp()
{
// clang-format off
std::cout << "Required arguments: [robot IP] [local IP]" << std::endl;
std::cout << " robot IP: address of the robot server" << std::endl;
std::cout << " local IP: address of this PC" << std::endl;
std::cout << "Required arguments: [robot SN]" << std::endl;
std::cout << " robot SN: Serial number of the robot to connect to. "
"Remove any space, for example: Rizon4s-123456" << std::endl;
std::cout << "Optional arguments: None" << std::endl;
std::cout << std::endl;
// clang-format on
Expand All @@ -44,14 +44,12 @@ int main(int argc, char* argv[])
flexiv::Log log;

// Parse parameters
if (argc < 3 || flexiv::utility::programArgsExistAny(argc, argv, {"-h", "--help"})) {
if (argc < 2 || flexiv::utility::programArgsExistAny(argc, argv, {"-h", "--help"})) {
printHelp();
return 1;
}
// IP of the robot server
std::string robotIP = argv[1];
// IP of the workstation PC running this program
std::string localIP = argv[2];
// Serial number of the robot to connect to. Remove any space, for example: Rizon4s-123456
std::string robotSN = argv[1];

// Print description
log.info("Tutorial description:");
Expand All @@ -61,7 +59,7 @@ int main(int argc, char* argv[])
// RDK Initialization
// =========================================================================================
// Instantiate robot interface
flexiv::Robot robot(robotIP, localIP);
flexiv::Robot robot(robotSN);

// Fault Clearing
// =========================================================================================
Expand Down
16 changes: 7 additions & 9 deletions example/basics3_primitive_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ void printDescription()
void printHelp()
{
// clang-format off
std::cout << "Required arguments: [robot IP] [local IP]" << std::endl;
std::cout << " robot IP: address of the robot server" << std::endl;
std::cout << " local IP: address of this PC" << std::endl;
std::cout << "Required arguments: [robot SN]" << std::endl;
std::cout << " robot SN: Serial number of the robot to connect to. "
"Remove any space, for example: Rizon4s-123456" << std::endl;
std::cout << "Optional arguments: None" << std::endl;
std::cout << std::endl;
// clang-format on
Expand All @@ -44,14 +44,12 @@ int main(int argc, char* argv[])
flexiv::Log log;

// Parse parameters
if (argc < 3 || flexiv::utility::programArgsExistAny(argc, argv, {"-h", "--help"})) {
if (argc < 2 || flexiv::utility::programArgsExistAny(argc, argv, {"-h", "--help"})) {
printHelp();
return 1;
}
// IP of the robot server
std::string robotIP = argv[1];
// IP of the workstation PC running this program
std::string localIP = argv[2];
// Serial number of the robot to connect to. Remove any space, for example: Rizon4s-123456
std::string robotSN = argv[1];

// Print description
log.info("Tutorial description:");
Expand All @@ -61,7 +59,7 @@ int main(int argc, char* argv[])
// RDK Initialization
// =========================================================================================
// Instantiate robot interface
flexiv::Robot robot(robotIP, localIP);
flexiv::Robot robot(robotSN);

// Clear fault on robot server if any
if (robot.isFault()) {
Expand Down
Loading

0 comments on commit 52043d1

Please sign in to comment.