diff --git a/CMakeLists.txt b/CMakeLists.txt index cfe67f1..d7bbfbd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16.3) # =================================================================== # PROJECT SETUP # =================================================================== -project(flexiv_ddk VERSION 1.0.0) +project(flexiv_ddk VERSION 1.0.1) # Configure build type if(NOT CMAKE_BUILD_TYPE) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index c70c7e6..31d675d 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NAME = "Flexiv DDK APIs" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.0 +PROJECT_NUMBER = 1.0.1 # 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 diff --git a/example/basics3_display_plan_info.cpp b/example/basics3_display_plan_info.cpp index 47a4db5..66486b3 100644 --- a/example/basics3_display_plan_info.cpp +++ b/example/basics3_display_plan_info.cpp @@ -73,15 +73,14 @@ int main(int argc, char *argv[]) { spdlog::info(">>> Tutorial description <<<\nThis tutorial check connection " "with the robot and print plan info."); + // Setup signal handler for graceful exit + std::signal(SIGINT, SignalHandler); try { // DDK Initialization // ========================================================================================= // Instantiate DDK client interface flexiv::ddk::Client client(robot_sn); - // Setup signal handler for graceful exit - std::signal(SIGINT, SignalHandler); - // Print States // ========================================================================================= // Use std::thread to do scheduling so that this example can run on all OS diff --git a/example/basics4_display_primitive_states.cpp b/example/basics4_display_primitive_states.cpp index bae999a..426cd0a 100644 --- a/example/basics4_display_primitive_states.cpp +++ b/example/basics4_display_primitive_states.cpp @@ -46,17 +46,13 @@ void printPrimitiveStates(flexiv::ddk::Client &client) { std::this_thread::sleep_for(std::chrono::seconds(5)); continue; } - // Print all robot states in JSON format using the built-in ostream operator - // overloading + // Print all robot states spdlog::info("Current primitive states:"); - std::cout << "primitiveName= " - << flexiv::ddk::utility::ParsePtStates(client.primitive_states(), - "primitiveName") - << std::endl; - std::cout << "reachedTarget= " - << flexiv::ddk::utility::ParsePtStates(client.primitive_states(), - "reachedTarget") - << std::endl; + for (const auto &pt : client.primitive_states()) { + std::cout << pt.first << " = "; + std::visit([](auto &&arg) { std::cout << arg; }, pt.second); + std::cout << std::endl; + } std::this_thread::sleep_for(std::chrono::seconds(1)); } } @@ -76,7 +72,7 @@ int main(int argc, char *argv[]) { // Print description spdlog::info(">>> Tutorial description <<<\nThis tutorial check connection " - "with the robot and print plan infos."); + "with the robot and print primitive states."); try { // DDK Initialization diff --git a/example/basics5_display_server_time.cpp b/example/basics5_display_server_time.cpp index 7f2226d..038ab51 100644 --- a/example/basics5_display_server_time.cpp +++ b/example/basics5_display_server_time.cpp @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) { // Print description spdlog::info(">>> Tutorial description <<<\nThis tutorial check connection " - "with the robot and print plan infos."); + "with the robot and print server time."); // Setup signal handler for graceful exit std::signal(SIGINT, SignalHandler); diff --git a/example/basics6_display_system_status.cpp b/example/basics6_display_system_status.cpp index ecf9c86..82ba909 100644 --- a/example/basics6_display_system_status.cpp +++ b/example/basics6_display_system_status.cpp @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) { // Print description spdlog::info(">>> Tutorial description <<<\nThis tutorial check connection " - "with the robot and print plan infos."); + "with the robot and print system status."); // Setup signal handler for graceful exit std::signal(SIGINT, SignalHandler); diff --git a/example/basics9_display_manipulability.cpp b/example/basics9_display_manipulability.cpp index 9a2c630..9acf659 100644 --- a/example/basics9_display_manipulability.cpp +++ b/example/basics9_display_manipulability.cpp @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) { // Print description spdlog::info(">>> Tutorial description <<<\nThis tutorial check connection " - "with the robot and print received robot cartesian commands."); + "with the robot and print current manipulability."); // Setup signal handler for graceful exit std::signal(SIGINT, SignalHandler); diff --git a/include/flexiv/ddk/client.hpp b/include/flexiv/ddk/client.hpp index 8492432..df98164 100644 --- a/include/flexiv/ddk/client.hpp +++ b/include/flexiv/ddk/client.hpp @@ -8,6 +8,7 @@ #include "data.hpp" #include +#include #include #include @@ -26,6 +27,11 @@ class Client { * services will initialize and connection with the robot will be established. * @param[in] robot_sn Serial number of the robot to connect. The accepted * formats are: "Rizon 4s-123456" and "Rizon4s-123456". + * @param[in] network_interface_whitelist Limit the network interface(s) that + * can be used to try to establish connection with the specified robot. The + * whitelisted network interface is defined by its associated IPv4 address. + * For example, {"10.42.0.1", "192.168.2.102"}. If left empty, all available + * network interfaces will be tried when searching for the specified robot. * @throw std::invalid_argument if the format of [robot_sn] is invalid. * @throw std::runtime_error if the initialization sequence failed. * @throw std::logic_error if the connected robot does not have a valid DDK @@ -34,7 +40,8 @@ class Client { * @warning This constructor blocks until the initialization sequence is * successfully finished and connection with the robot is established. */ - Client(const std::string &robot_sn); + Client(const std::string &robot_sn, + const std::vector &network_interface_whitelist = {}); virtual ~Client(); /** @@ -86,7 +93,23 @@ class Client { * or the result is invalid. * @note This function blocks until a reply is received. */ - const std::vector primitive_states() const; + [[deprecated( + "[Will be removed in flexiv_ddk v1.1] Use the other primitive_states() " + "instead")]] const std::vector + primitive_states(bool dummy) + const; ///< Unused parameter [dummy] is needed for function overloading + + /** + * @brief [Blocking] State parameters of the executing primitive and their + * current values. + * @return A map of {pt_state_name, pt_state_value(s)}. Booleans are + * represented by int 1 and 0. For example, + * {{"primitiveName","MoveL"},{"reachedTarget", 0}, {"timePeriod", 5.6}}. + * @throw std::runtime_error if failed to get a reply from the connected + * robot. + * @note This function blocks until a reply is received. + */ + std::map primitive_states() const; /** * @brief [Non-blocking] Access the current time from server. It contains @@ -108,7 +131,8 @@ class Client { bool enabling_button_pressed() const; /** - * @brief [Non-blocking] Read all digital input ports on the control box. + * @brief [Non-blocking] Read all digital input ports on the control box, + * including 16 on the control box plus 2 inside the wrist connector. * @return Digital input readings array whose index corresponds to the digital * input port index. True: port high, false: port low. */ diff --git a/include/flexiv/ddk/data.hpp b/include/flexiv/ddk/data.hpp index 05086f5..9082146 100644 --- a/include/flexiv/ddk/data.hpp +++ b/include/flexiv/ddk/data.hpp @@ -10,8 +10,8 @@ #include #include #include +#include #include - namespace flexiv { namespace ddk { @@ -21,8 +21,9 @@ constexpr size_t kCartDoF = 6; /** Size of pose array (3 position + 4 quaternion) */ constexpr size_t kPoseSize = 7; -/** Number of digital IO ports */ -constexpr size_t kIOPorts = 16; +/** Number of digital IO ports (16 on control box + 2 inside the wrist + * connector) */ +constexpr size_t kIOPorts = 18; /** * @struct JointStates @@ -291,6 +292,10 @@ struct ServerTime { int nano_sec = {}; }; +/** Alias of the variant that holds all possible types of flexiv primitive + * states */ +using FlexivPrimitiveStatesType = std::variant; + /** * @brief Operator overloading to out stream all robot states in JSON format: * {"state_1": [val1,val2,val3,...], "state_2": [val1,val2,val3,...], ...}. diff --git a/lib/flexiv_ddk.win_amd64.lib b/lib/flexiv_ddk.win_amd64.lib index b400210..8c4faa2 100644 Binary files a/lib/flexiv_ddk.win_amd64.lib and b/lib/flexiv_ddk.win_amd64.lib differ diff --git a/lib/libflexiv_ddk.x86_64-linux-gnu.a b/lib/libflexiv_ddk.x86_64-linux-gnu.a index fa50d9d..aa665c4 100644 Binary files a/lib/libflexiv_ddk.x86_64-linux-gnu.a and b/lib/libflexiv_ddk.x86_64-linux-gnu.a differ diff --git a/thirdparty/scripts/install_Fast-CDR.sh b/thirdparty/scripts/install_Fast-CDR.sh index 0e36f1f..f582c3a 100644 --- a/thirdparty/scripts/install_Fast-CDR.sh +++ b/thirdparty/scripts/install_Fast-CDR.sh @@ -25,7 +25,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCAMEK_PREFIX_PATH=$INSTALL_DIR \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ -DCOMPILE_EXAMPLES=OFF # Build and install diff --git a/thirdparty/scripts/install_Fast-DDS.sh b/thirdparty/scripts/install_Fast-DDS.sh index e53b940..443978e 100644 --- a/thirdparty/scripts/install_Fast-DDS.sh +++ b/thirdparty/scripts/install_Fast-DDS.sh @@ -26,7 +26,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCAMEK_PREFIX_PATH=$INSTALL_DIR \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ -DTHIRDPARTY_Asio=ON \ -DCOMPILE_EXAMPLES=OFF \ -DSQLITE3_SUPPORT=OFF \ diff --git a/thirdparty/scripts/install_eigen.sh b/thirdparty/scripts/install_eigen.sh index 5d040a7..353a03c 100644 --- a/thirdparty/scripts/install_eigen.sh +++ b/thirdparty/scripts/install_eigen.sh @@ -15,9 +15,8 @@ else fi # Use specific version -git fetch -p -git checkout 3.3.7 -git submodule update --init --recursive +git fetch --prune --tags +git checkout 3.4.0 # Configure CMake mkdir -p build && cd build @@ -25,7 +24,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCAMEK_PREFIX_PATH=$INSTALL_DIR + -DCMAKE_PREFIX_PATH=$INSTALL_DIR # Build and install cmake --build . --target install --config Release -j $NUM_JOBS diff --git a/thirdparty/scripts/install_foonathan_memory.sh b/thirdparty/scripts/install_foonathan_memory.sh index b12454b..d7ce765 100644 --- a/thirdparty/scripts/install_foonathan_memory.sh +++ b/thirdparty/scripts/install_foonathan_memory.sh @@ -24,7 +24,7 @@ mkdir -p build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCAMEK_PREFIX_PATH=$INSTALL_DIR \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR # Build and install diff --git a/thirdparty/scripts/install_spdlog.sh b/thirdparty/scripts/install_spdlog.sh index abff7fc..084fcc1 100644 --- a/thirdparty/scripts/install_spdlog.sh +++ b/thirdparty/scripts/install_spdlog.sh @@ -24,7 +24,7 @@ mkdir -p build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCAMEK_PREFIX_PATH=$INSTALL_DIR \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR # Build and install diff --git a/thirdparty/scripts/install_tinyxml2.sh b/thirdparty/scripts/install_tinyxml2.sh index f781717..1f58150 100644 --- a/thirdparty/scripts/install_tinyxml2.sh +++ b/thirdparty/scripts/install_tinyxml2.sh @@ -24,7 +24,7 @@ mkdir -p build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCAMEK_PREFIX_PATH=$INSTALL_DIR \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR # Build and install