Skip to content

Commit

Permalink
Flexiv RDK 0.5.0 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhu-flexiv authored Apr 13, 2022
1 parent 1865733 commit 10a57dc
Show file tree
Hide file tree
Showing 660 changed files with 4,424 additions and 32,044 deletions.
51 changes: 37 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ if( NOT CMAKE_BUILD_TYPE )
FORCE )
endif()

option(BUILD_FOR_ARM64 "Link to RDK library for arm64 processor, otherwise link to x64" OFF)

set(CMAKE_VERBOSE_MAKEFILE ON)

set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand All @@ -25,16 +27,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/example)

# list of examples
set(EXAMPLE_LIST
auto_recovery
cartesian_impedance_control
clear_fault
display_robot_states
floating_with_soft_limits
gripper_control
joint_impedance_control
joint_position_control
plan_execution
primitive_execution
robot_dynamics
display_robot_states
series_operation
floating_with_soft_limits
auto_recovery
visualization
)

Expand All @@ -46,14 +50,24 @@ foreach(example ${EXAMPLE_LIST})
target_include_directories(${example}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Eigen
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen3
)

# Link basic libraries
target_link_libraries(${example}
${CMAKE_CURRENT_SOURCE_DIR}/lib/libFlexivRdk.a
anl
Threads::Threads
anl
)

# Link arm64 or x64 version of libFlexivRdk
if (${BUILD_FOR_ARM64})
target_link_libraries(${example}
${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp/arm64/libFlexivRdk.a)
else()
target_link_libraries(${example}
${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp/x64/libFlexivRdk.a)
endif()

endforeach()


Expand All @@ -65,14 +79,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test)

# list of tests
set(TEST_LIST
test_dynamic_engine
test_scheduler
test_set_tool
test_timeliness_monitor
test_data_integrity
test_dynamics_engine
test_dynamics_with_tool
test_endurance
test_log
test_loop_latency
test_scheduler
test_timeliness_monitor
)

foreach(test ${TEST_LIST})
Expand All @@ -83,12 +96,22 @@ foreach(test ${TEST_LIST})
target_include_directories(${test}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Eigen
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen3
)

# Link basic libraries
target_link_libraries(${test}
${CMAKE_CURRENT_SOURCE_DIR}/lib/libFlexivRdk.a
anl
Threads::Threads
anl
)

# Link arm64 or x64 version of libFlexivRdk
if (${BUILD_FOR_ARM64})
target_link_libraries(${test}
${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp/arm64/libFlexivRdk.a)
else()
target_link_libraries(${test}
${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp/x64/libFlexivRdk.a)
endif()

endforeach()
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@

Flexiv RDK (Robot Development Kit) is a powerful toolkit as an add-on to the Flexiv software platform. It enables the users to create complex applications with APIs that provide low-level real-time access to the robot.

**C++** interface (real-time and non-real-time APIs) and **Python** interface (non-real-time APIs only) are supported.
**C++** (access to all APIs) and **Python** (access to non-real-time APIs only) are supported.

## License

Flexiv RDK is licensed under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.html).

## References

**[Flexiv RDK Manual](https://flexivrobotics.github.io/)** is the main reference and contains important information on how to properly set up the system and use Flexiv RDK library.

[API documentation](https://flexivrobotics.github.io/flexiv_rdk/) contains details about available APIs, generated from Doxygen.
[Flexiv RDK main webpage](https://rdk.flexiv.com/) contains important information like the user manual and API documentation, please read them carefully before proceeding.

## Run example programs

**NOTE:** the instruction below is only a quick reference, assuming you've already gone through the Flexiv RDK Manual.

### C++ interface

1. Configure and build example programs:
1. Configure and compile example programs for x64 processors:

cd flexiv_rdk
mkdir build && cd build
cmake ..
make -j4

For arm64 processors, set the additional CMake option when configuring:

cmake .. -DBUILD_FOR_ARM64=ON

2. The compiled program binaries will be output to ``flexiv_rdk/build/example``
3. Assume the robot is booted and connected, to run an example program:

Expand Down Expand Up @@ -66,3 +68,4 @@ Flexiv RDK has integrated visualization (only available for C++ interface) based
4. Use APIs in ``flexiv::Visualization`` to communicate with the Meshcat server, the empty scene will be populated with robot(s) and user-defined objects if any. Refer to ``example/visualization.cpp``.

**Note:** only STL mesh files are supported, which are provided in ``spec/meshes``.

6 changes: 3 additions & 3 deletions doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "RDK"
PROJECT_NAME = "Flexiv RDK APIs"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "0.4.0"
PROJECT_NUMBER = "0.5.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
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "C++ APIs"
PROJECT_BRIEF = ""

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand Down
79 changes: 38 additions & 41 deletions example/auto_recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
* Run auto-recovery if the robot's safety system is in recovery state,
* otherwise run damped floating with joint soft limit disabled, so that the
* user can manually trigger a safety system recovery state by moving any joint
* close to its limit. See flexiv::Mode::MODE_AUTO_RECOVERY for more details.
* close to its limit. See flexiv::Robot::isRecoveryState() for more details.
* @copyright Copyright (C) 2016-2021 Flexiv Ltd. All Rights Reserved.
* @author Flexiv
*/

#include <Robot.hpp>
#include <Log.hpp>
#include <flexiv/Robot.hpp>
#include <flexiv/Exception.hpp>
#include <flexiv/Log.hpp>

#include <string>
#include <thread>
Expand All @@ -32,49 +33,45 @@ int main(int argc, char* argv[])
// IP of the workstation PC running this program
std::string localIP = argv[2];

// RDK Initialization
//=============================================================================
// Instantiate robot interface
auto robot = std::make_shared<flexiv::Robot>();

// Create data struct for storing robot states
auto robotStates = std::make_shared<flexiv::RobotStates>();
try {
// RDK Initialization
//=============================================================================
// Instantiate robot interface
flexiv::Robot robot(robotIP, localIP);

// Initialize robot interface and connect to the robot server
robot->init(robotIP, localIP);
// Create data struct for storing robot states
flexiv::RobotStates robotStates;

// Wait for the connection to be established
do {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} while (!robot->isConnected());

// Enable the robot, make sure the E-stop is released before enabling
if (robot->enable()) {
// Enable the robot, make sure the E-stop is released before enabling
log.info("Enabling robot ...");
}
robot.enable();

// Application-specific Code
//=============================================================================
// If the system is in recovery state, we can't use isOperational to tell if
// the enabling process is done, so just wait long enough for the process to
// finish
std::this_thread::sleep_for(std::chrono::seconds(8));
// Application-specific Code
//=============================================================================
// If the system is in recovery state, we can't use isOperational to
// tell if the enabling process is done, so just wait long enough for
// the process to finish
std::this_thread::sleep_for(std::chrono::seconds(8));

// Start auto recovery if the system is in recovery state, the involved
// Joints will start to move back into allowed position range
if (robot->isRecoveryState()) {
robot->startAutoRecovery();
// Block forever, must reboot the robot and restart user program after
// auto recovery is done
do {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} while (true);
}
// Otherwise the system is normal, do nothing
else {
log.info(
"Robot system is not in recovery state, nothing to be done, "
"exiting ...");
// Start auto recovery if the system is in recovery state, the involved
// Joints will start to move back into allowed position range
if (robot.isRecoveryState()) {
robot.startAutoRecovery();
// Block forever, must reboot the robot and restart user program
// after auto recovery is done
while (true) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
// Otherwise the system is normal, do nothing
else {
log.info(
"Robot system is not in recovery state, nothing to be done, "
"exiting ...");
}
} catch (const flexiv::Exception& e) {
log.error(e.what());
return 0;
}

return 0;
Expand Down
Loading

0 comments on commit 10a57dc

Please sign in to comment.