Skip to content

Commit

Permalink
Release/v1.3 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhipengZhang-flexiv authored Jan 17, 2025
1 parent d5cdff1 commit 466620f
Show file tree
Hide file tree
Showing 10 changed files with 565 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16.3)
# ===================================================================
# PROJECT SETUP
# ===================================================================
project(flexiv_tdk VERSION 1.2.2)
project(flexiv_tdk VERSION 1.3)

# Configure build type
if(NOT CMAKE_BUILD_TYPE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flexiv TDK

![CMake Badge](https://github.com/flexivrobotics/flexiv_tdk/actions/workflows/cmake.yml/badge.svg) ![Version](https://img.shields.io/badge/version-1.1-blue.svg) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
![CMake Badge](https://github.com/flexivrobotics/flexiv_tdk/actions/workflows/cmake.yml/badge.svg) ![Version](https://img.shields.io/badge/version-1.3-blue.svg) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)

Flexiv TDK (Teleoperation Development Kit) is an SDK for developing customized robot-robot or device-robot teleoperation applications with Flexiv's adaptive robots. It features synchronized motions that are force-guided using high-fidelity perceptual feedback and supports both LAN (Local Area Network) and WAN (Wide Area Network, i.e. Internet) connections.

Expand Down
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ endif()

# Example list
set(EXAMPLE_LIST
high_transparency_teleop
cartesian_teleop_under_lan
joint_teleop_over_wan
joint_teleop_under_lan
Expand Down
214 changes: 214 additions & 0 deletions example/high_transparency_teleop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/**
* @file high_transparency_teleop.cpp
* @copyright Copyright (C) 2016-2025 Flexiv Ltd. All Rights Reserved.
*/

// Flexiv
#include <atomic>
#include <chrono>
#include <spdlog/spdlog.h>
#include <flexiv/tdk/transparent_cartesian_teleop_lan.hpp>
#include <flexiv/tdk/data.hpp>
#include <getopt.h>
#include <iostream>
#include <thread>
namespace {
std::vector<double> kPreferredJntPos
= {60 * M_PI / 180.0, -60 * M_PI / 180.0, -85 * M_PI / 180.0, 115 * M_PI / 180.0,
70 * M_PI / 180.0, 0 * M_PI / 180.0, 0 * M_PI / 180.0}; ///< Preferred joint position
std::vector<double> kHomeJntPos
= {0 * M_PI / 180.0, -40 * M_PI / 180.0, 0 * M_PI / 180.0, 90 * M_PI / 180.0, 0 * M_PI / 180.0,
40 * M_PI / 180.0, 0 * M_PI / 180.0}; ///< Preferred joint position

const std::array<double, flexiv::tdk::kCartDoF> kDefaultMaxContactWrench
= {5.0, 5.0, 5.0, 40.0, 40.0, 40.0}; ///< Maximum contact wrench

std::atomic<bool> g_stop_sched = {false}; ///< Atomic signal to stop scheduler tasks
} // namespace

void printHelp()
{
// clang-format off
spdlog::error("Invalid program arguments");
spdlog::info(" -l [necessary] serial number of local robot.");
spdlog::info(" -r [necessary] serial number of remote robot.");
spdlog::info("Usage: ./cart_teleop -l Rizon4s-123456 -r Rizon4s-654321 ");
// clang-format on
}

struct option kLongOptions[] = {
// clang-format off
{"local SN", required_argument, 0, 'l'},
{"remote SN", required_argument, 0, 'r'},
{0, 0, 0, 0 }
// clang-format on
};

/**
* @brief function for test
*/
void ConsoleTask(flexiv::tdk::TransparentCartesianTeleopLAN& teleop)
{
unsigned int index = 0;
flexiv::tdk::AxisLock cmd;
teleop.GetAxisLockState(index, cmd);

while (!teleop.any_fault()) {

std::string userInput;
std::getline(std::cin, userInput);

switch (userInput[0]) {
case 'x':
cmd.lock_trans_axis[0] = !cmd.lock_trans_axis[0];
cmd.coord = flexiv::tdk::CoordType::COORD_WORLD;
break;
case 'y':
cmd.lock_trans_axis[1] = !cmd.lock_trans_axis[1];
cmd.coord = flexiv::tdk::CoordType::COORD_WORLD;
break;
case 'z':
cmd.lock_trans_axis[2] = !cmd.lock_trans_axis[2];
cmd.coord = flexiv::tdk::CoordType::COORD_WORLD;
break;
case 'q':
cmd.lock_ori_axis[0] = !cmd.lock_ori_axis[0];
cmd.coord = flexiv::tdk::CoordType::COORD_WORLD;
break;
case 'w':
cmd.lock_ori_axis[1] = !cmd.lock_ori_axis[1];
cmd.coord = flexiv::tdk::CoordType::COORD_WORLD;
break;
case 'e':
cmd.lock_ori_axis[2] = !cmd.lock_ori_axis[2];
cmd.coord = flexiv::tdk::CoordType::COORD_WORLD;
break;

case 'X':
cmd.lock_trans_axis[0] = !cmd.lock_trans_axis[0];
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'Y':
cmd.lock_trans_axis[1] = !cmd.lock_trans_axis[1];
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'Z':
cmd.lock_trans_axis[2] = !cmd.lock_trans_axis[2];
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'Q':
cmd.lock_ori_axis[0] = !cmd.lock_ori_axis[0];
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'W':
cmd.lock_ori_axis[1] = !cmd.lock_ori_axis[1];
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'E':
cmd.lock_ori_axis[2] = !cmd.lock_ori_axis[2];
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'r':
teleop.Engage(index, true);
break;
case 'R':
teleop.Engage(index, false);
break;
case 's':
cmd.lock_ori_axis = {false, false, false};
cmd.lock_trans_axis = {false, false, false};
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 'S':
cmd.lock_ori_axis = {true, true, true};
cmd.lock_trans_axis = {true, true, true};
cmd.coord = flexiv::tdk::CoordType::COORD_TCP;
break;
case 't':
teleop.SetRepulsiveForce(index, {5, 0, 0});
break;
case 'T':
teleop.SetWrenchFeedbackScalingFactor(index, 1.5);
break;
case 'i':
teleop.SetLocalNullSpacePosture(index, kPreferredJntPos);
break;
case 'I':
teleop.SetLocalNullSpacePosture(index, kHomeJntPos);
break;
case 'o':
teleop.SetRemoteNullSpacePosture(index, kPreferredJntPos);
break;
case 'O':
teleop.SetRemoteNullSpacePosture(index, kHomeJntPos);
break;
case 'p':
teleop.SetRemoteMaxContactWrench(index, kDefaultMaxContactWrench);
break;
case 'L':
teleop.robot_states(0);
break;
case 'k':
teleop.digital_inputs(0);
break;

default:
spdlog::warn("Invalid command!");
break;
}
teleop.SetAxisLockCmd(index, cmd);
}
return;
}

int main(int argc, char* argv[])
{
std::string remote_sn;
std::string local_sn;
int opt = 0;
int longIndex = 0;
while ((opt = getopt_long_only(argc, argv, "", kLongOptions, &longIndex)) != -1) {
switch (opt) {
case 'r':
remote_sn = std::string(optarg);
break;
case 'l':
local_sn = std::string(optarg);
break;
default:
printHelp();
return 1;
}
}
if (local_sn.empty() || remote_sn.empty()) {
printHelp();
return 1;
}

try {

// Allocate tdk object
flexiv::tdk::TransparentCartesianTeleopLAN htt({{local_sn, remote_sn}});

// Init high transparency teleop
htt.Init();

// Start high transparency teleop
htt.Start();

// Helper thread
std::thread helper_thread(std::bind(ConsoleTask, std::ref(htt)));

// Block main with helper thead
helper_thread.join();

// Exit high transparency teleop
htt.Stop();

} catch (const std::exception& e) {
spdlog::error(e.what());
return 1;
}

return 0;
}
2 changes: 1 addition & 1 deletion include/flexiv/tdk/cartesian_teleop_lan.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file cartesian_teleop_lan.hpp
* @copyright Copyright (C) 2016-2024 Flexiv Ltd. All Rights Reserved.
* @copyright Copyright (C) 2016-2025 Flexiv Ltd. All Rights Reserved.
*/
#pragma once

Expand Down
68 changes: 58 additions & 10 deletions include/flexiv/tdk/data.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/**
* @file data.hpp
* @brief Header file containing various constant expressions, data structs, and enums.
* @copyright Copyright (C) 2016-2024 Flexiv Ltd. All Rights Reserved.
* @copyright Copyright (C) 2016-2025 Flexiv Ltd. All Rights Reserved.
*/

#pragma once

#include <array>
#include <vector>
#include <cstddef>
#include <string>

namespace flexiv {
namespace tdk {
Expand All @@ -21,6 +22,60 @@ constexpr size_t kPoseSize = 7;
/** Number of digital IO ports (16 on control box + 2 inside the wrist connector) */
constexpr size_t kIOPorts = 18;

/** Max wrench feedback scaling factor for high transparency teleop*/
constexpr double kMaxWrenchFeedbackScale = 3;

/**
* @brief Reference coordinate that the axis to be locked
*/
enum CoordType
{
COORD_UNKNOWN = 0, ///> Unknown coordinate
COORD_TCP, ///> TCP coordinate of local robot
COORD_WORLD ///> WORLD coordinate of local robot
};

static const std::string CoordTypeStr[] = {"UNKNOWN", "TCP", "WORLD"};

/**
* @brief Get the coordinate type of axis locking status
* @param[in] str string name of the coordinate
* @return CoordType
*/
static inline CoordType GetCoordType(const std::string& str)
{
for (size_t i = 0; i < COORD_WORLD - COORD_UNKNOWN + 1; i++) {
if (str == CoordTypeStr[i]) {
return static_cast<CoordType>(i);
}
}
return COORD_UNKNOWN;
}

/**
* @brief Data for locking axis, including reference frame and axis to be locked.
* Coordinate type options are: "COORD_TCP" for TCP frame and "COORD_WORLD" for WORLD frame.
*/
struct AxisLock
{
/**
* @brief Reference coordinate that the axis to be locked
*/
CoordType coord = CoordType::COORD_UNKNOWN;

/**
* @brief Translation axis lock, the corresponding axis order is \f$ [X, Y, Z] \f$. True
* for locking, false for floating.
*/
std::array<bool, 3> lock_trans_axis = {false, false, false};

/**
* @brief Orientation axis lock, the corresponding axis order is \f$ [Rx, Ry, Rz] \f$.
* True for locking, false for floating.
*/
std::array<bool, 3> lock_ori_axis = {false, false, false};
};

/**
* @struct RobotStates
* @brief Data structure containing the joint- and Cartesian-space robot states.
Expand Down Expand Up @@ -107,13 +162,6 @@ struct RobotStates
*/
std::array<double, kPoseSize> tcp_pose = {};

/**
* Desired TCP pose expressed in world frame: \f$ {^{O}T_{TCP}}_{d} \in \mathbb{R}^{7 \times 1}
* \f$. Consists of \f$ \mathbb{R}^{3 \times 1} \f$ position and \f$ \mathbb{R}^{4 \times 1} \f$
* quaternion: \f$ [x, y, z, q_w, q_x, q_y, q_z]^T \f$. Unit: \f$ [m]:[] \f$.
*/
std::array<double, kPoseSize> tcp_pose_des = {};

/**
* Measured TCP velocity expressed in world frame: \f$ ^{O}\dot{X} \in \mathbb{R}^{6 \times 1}
* \f$. Consists of \f$ \mathbb{R}^{3 \times 1} \f$ linear velocity and \f$ \mathbb{R}^{3 \times
Expand Down Expand Up @@ -164,5 +212,5 @@ struct RobotStates
std::array<double, kCartDoF> ext_wrench_in_world_raw = {};
};

} /* namespace tdk */
} /* namespace flexiv */
} // namespace tdk
} // namespace flexiv
2 changes: 1 addition & 1 deletion include/flexiv/tdk/joint_teleop_lan.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file joint_teleop_lan.hpp
* @copyright Copyright (C) 2016-2024 Flexiv Ltd. All Rights Reserved.
* @copyright Copyright (C) 2016-2025 Flexiv Ltd. All Rights Reserved.
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion include/flexiv/tdk/joint_teleop_wan.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file joint_teleop_wan.hpp
* @copyright Copyright (C) 2016-2024 Flexiv Ltd. All Rights Reserved.
* @copyright Copyright (C) 2016-2025 Flexiv Ltd. All Rights Reserved.
*/
#pragma once

Expand Down
Loading

0 comments on commit 466620f

Please sign in to comment.