cmvr-es/third_party/AuboSdk/linux/include/aubo/math.h

910 lines
34 KiB
C
Raw Normal View History

2025-11-18 10:07:08 +08:00
/** @file math.h
* \~chinese @brief 姿
* \~english @brief Mathematic operation interface, such as euler to quaternion conversion, addition/subtraction of poses
*/
#ifndef AUBO_SDK_MATH_INTERFACE_H
#define AUBO_SDK_MATH_INTERFACE_H
#include <vector>
#include <memory>
#include <aubo/type_def.h>
#include <aubo/global_config.h>
namespace arcs {
namespace common_interface {
class ARCS_ABI_EXPORT Math
{
public:
Math();
virtual ~Math();
/**
* \english
* Pose addition
*
* Both arguments contain three position parameters (x, y, z) jointly called
* P, and three rotation parameters (R_x, R_y, R_z) jointly called R. This
* function calculates the result x_3 as the addition of the given poses as
* follows:
*
* p_3.P = p_1.P + p_2.P
*
* p_3.R = p_1.R * p_2.R
*
* @param p1 Tool pose 1
* @param p2 Tool pose 2
* @return sum of position parts and product of rotation parts (pose)
*
* @par Python interface prototype
* poseAdd(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float]) ->
* List[float]
*
* @par Lua interface prototype
* poseAdd(p1: table, p2: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseAdd","params":[[0.2, 0.5, 0.1, 1.57,
* 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.4,1.0,0.7,3.14,-0.0,0.0]}
* \endengish
*
* \chinese
* 姿
* xyzP
* R_xR_yR_zR
* p_3姿
* p_3.P = p_1.P + p_2.P,
* p_3.R = p_1.R * p_2.R
*
* @param p1 姿1pose
* @param p2 姿2pose
* @return pose
*
* @par Python函数原型
* poseAdd(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float]) ->
* List[float]
*
* @par Lua函数原型
* poseAdd(p1: table, p2: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseAdd","params":[[0.2, 0.5, 0.1, 1.57,
* 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.4,1.0,0.7,3.14,-0.0,0.0]}
* \endchinese
*/
std::vector<double> poseAdd(const std::vector<double> &p1,
const std::vector<double> &p2);
/**
* \chinese
* 姿
*
* xyzP
* R_xR_yR_zR
* p_3姿
* p_3.P = p_1.P - p_2.P,
* p_3.R = p_1.R * p_2.R.inverse
*
* @param p1 姿1
* @param p2 姿2
* @return 姿
*
* @par Python函数原型
* poseSub(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float]) ->
* List[float]
*
* @par Lua函数原型
* poseSub(p1: table, p2: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseSub","params":[[0.2, 0.5, 0.1, 1.57,
* 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.0,0.0,-0.5,0.0,-0.0,0.0]}
* \endchinese
*
* \english
* Pose subtraction
*
* Both arguments contain three position parameters (x, y, z) jointly called
* P, and three rotation parameters (R_x, R_y, R_z) jointly called R. This
* function calculates the result x_3 as the addition of the given poses as
* follows:
*
* p_3.P = p_1.P - p_2.P,
*
* p_3.R = p_1.R * p_2.R.inverse
*
* @param p1 tool pose 1
* @param p2 tool pose 2
* @return difference between two poses
*
* @par Python interface prototype
* poseSub(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float]) ->
* List[float]
*
* @par Lua interface prototype
* poseSub(p1: table, p2: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseSub","params":[[0.2, 0.5, 0.1, 1.57,
* 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.0,0.0,-0.5,0.0,-0.0,0.0]}
* \endenglish
*/
std::vector<double> poseSub(const std::vector<double> &p1,
const std::vector<double> &p2);
/**
* \chinese
* 线
*
* @param p1 TCP位姿
* @param p2 TCP位姿
* @param alpha
* 0<alpha<1p1和p2两点直线的之间靠近p1端且占总路径比例为alpha的点
* alpha=0.3,p1那端30
* alpha>1,p2
* alpha<0,p1
* @return
*
* @par Python函数原型
* interpolatePose(self: pyaubo_sdk.Math, arg0: List[float], arg1:
* List[float], arg2: float) -> List[float]
*
* @par Lua函数原型
* interpolatePose(p1: table, p2: table, alpha: number) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.interpolatePose","params":[[0.2, 0.2,
* 0.4, 0, 0, 0],[0.2, 0.2, 0.6, 0, 0, 0],0.5],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.2,0.2,0.5,0.0,-0.0,0.0]}
* \endchinese
*
* \english
* Calculate linear interpolation
*
* @param p1 starting TCP pose
* @param p2 ending TCP pose
* @param alpha coefficient;
* When 0<alpha<1return a point between p1 & p2 that is closer to p1, at alpha percentage of the path
* For example when alpha=0.3,point returned is closer to p1at 30% of the total distance;
* When alpha>1, return p2
* When alpha<0,return p1
* @return interpolation result
*
* @par Python interface prototype
* interpolatePose(self: pyaubo_sdk.Math, arg0: List[float], arg1:
* List[float], arg2: float) -> List[float]
*
* @par Lua interface prototype
* interpolatePose(p1: table, p2: table, alpha: number) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.interpolatePose","params":[[0.2, 0.2,
* 0.4, 0, 0, 0],[0.2, 0.2, 0.6, 0, 0, 0],0.5],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.2,0.2,0.5,0.0,-0.0,0.0]}
* \endenglish
*
*/
std::vector<double> interpolatePose(const std::vector<double> &p1,
const std::vector<double> &p2,
double alpha);
/**
* \chinese
* 姿
*
* p_from p_from_to
* p_from
* p_from_to后的位姿
*
*
* p_from_to p_from
* 姿 p_from p_from_to
* 姿
*
* T_world->to = T_world->from * T_from->to
* T_x->to = T_x->from * T_from->to
*
* 姿姿姿姿姿
*
* B相对于A的位姿C相对于B的位姿C相对于A的位姿
* B相对于A的位姿C相对于B的位姿
* C相对于A的位姿
*
* @param pose_from 姿
* @param pose_from_to 姿姿
* @return 姿 ()
*
* @par Python函数原型
* poseTrans(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float]) ->
* List[float]
*
* @par Lua函数原型
* poseTrans(pose_from: table, pose_from_to: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseTrans","params":[[0.2, 0.5,
* 0.1, 1.57, 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.4,-0.09960164640373415,0.6004776374923573,3.14,-0.0,0.0]}
* \endchinese
*
* \english
* Pose transformation
*
* The first argument, p_from, is used to transform the second argument,
* p_from_to, and the result is then returned. This means that the result is
* the resulting pose, when starting at the coordinate system of p_from, and
* then in that coordinate system moving p_from_to.
*
* This function can be seen in two different views. Either the function
* transforms, that is translates and rotates, p_from_to by the parameters
* of p_from. Or the function is used to get the resulting pose, when first
* making a move of p_from and then from there, a move of p_from_to. If the
* poses were regarded as transformation matrices, it would look like:
*
* T_world->to = T_world->from * T_from->to
* T_x->to = T_x->from * T_from->to
*
*
* These two equations describes the foundations for pose transformation.
* Based on a starting pose and the pose transformation relative to the starting pose, we can get the target pose.
*
* For example, we know pose of B relative to A, pose of C relative to B, find pose of C relative to A.
* param 1 is pose of B relative to Aparam 2 is pose of C relative to B
* the return value is the pose of C relative to A
*
* @param pose_from starting posevector in 3D space
* @param pose_from_to pose transformation relative to starting posevector in 3D space
* @return final pose (vector in 3D space)
*
* @par Python interface prototype
* poseTrans(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float]) ->
* List[float]
*
* @par Lua interface prototype
* poseTrans(pose_from: table, pose_from_to: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseTrans","params":[[0.2, 0.5,
* 0.1, 1.57, 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.4,-0.09960164640373415,0.6004776374923573,3.14,-0.0,0.0]}
* \endenglish
*/
std::vector<double> poseTrans(const std::vector<double> &pose_from,
const std::vector<double> &pose_from_to);
/**
* \english
* Pose inverse transformation
*
* Given pose of C relative to A, pose of C relative to B, find pose of B relative to A.
* param 1 is pose of C relative to Aparam 2 is pose of C relative to B
* the return value is the pose of B relative to A
*
* @param pose_from starting pose
* @param pose_to_from pose transformation relative to final pose
* @return resulting pose
*
* @par Python interface prototype
* poseTransInv(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float])
* -> List[float]
*
* @par Lua interface prototype
* poseTransInv(pose_from: table, pose_to_from: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseTransInv","params":[[0.4, -0.0996016,
* 0.600478, 3.14, 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.2,0.5000000464037341,0.10000036250764266,1.57,-0.0,0.0]}
* \endenglish
*
* \chinese
* 姿
*
* C相对于A的位姿C相对于B的位姿B相对于A的位姿
* C相对于A的位姿C相对于B的位姿
* B相对于A的位姿
*
* @param pose_from 姿
* @param pose_to_from 姿姿
* @return 姿
*
* @par Python函数原型
* poseTransInv(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float])
* -> List[float]
*
* @par Lua函数原型
* poseTransInv(pose_from: table, pose_to_from: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseTransInv","params":[[0.4, -0.0996016,
* 0.600478, 3.14, 0, 0],[0.2, 0.5, 0.6, 1.57, 0, 0]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.2,0.5000000464037341,0.10000036250764266,1.57,-0.0,0.0]}
* \endchinese
*/
std::vector<double> poseTransInv(const std::vector<double> &pose_from,
const std::vector<double> &pose_to_from);
/**
* \chinese
* 姿
*
* @param pose 姿
* @return 姿
*
* @par Python函数原型
* poseInverse(self: pyaubo_sdk.Math, arg0: List[float]) -> List[float]
*
* @par Lua函数原型
* poseInverse(pose: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseInverse","params":[[0.2, 0.5,
* 0.1, 1.57, 0, 3.14]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.19920341988726448,-0.09960155178838484,-0.5003973704832628,
* 1.5699999989900404,-0.0015926530848129354,-3.1415913853161266]}
*
* \endchinese
*
* \english
* Get the inverse of a pose
*
* @param pose tool pose (spatial vector)
* @return inverse tool pose transformation (spatial vector)
*
* @par Python interface prototype
* poseInverse(self: pyaubo_sdk.Math, arg0: List[float]) -> List[float]
*
* @par Lua interface prototype
* poseInverse(pose: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseInverse","params":[[0.2, 0.5,
* 0.1, 1.57, 0, 3.14]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.19920341988726448,-0.09960155178838484,-0.5003973704832628,
* 1.5699999989900404,-0.0015926530848129354,-3.1415913853161266]}
* \endenglish
*
*/
std::vector<double> poseInverse(const std::vector<double> &pose);
/**
* \chinese
* 姿
*
* @param p1 姿1
* @param p2 姿2
* @return 姿
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseDistance","params":[[0.1, 0.3, 0.1,
* 0.3142, 0.0, 1.571],[0.2, 0.5, 0.6, 0, -0.172, 0.0]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":0.5477225575051661}
* \endchinese
*
* \english
* Calculate distance between two poses
*
* @param p1 pose 1
* @param p2 pose 2
* @return distance between the poses
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseDistance","params":[[0.1, 0.3, 0.1,
* 0.3142, 0.0, 1.571],[0.2, 0.5, 0.6, 0, -0.172, 0.0]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":0.5477225575051661}
* \endenglish
*
*/
double poseDistance(const std::vector<double> &p1,
const std::vector<double> &p2);
/**
* \chinese
* 姿
*
* @param p1 姿1
* @param p2 姿2
* @return
* \endchinese
*
* \english
* Calculate axis-angle difference between two poses
*
* @param p1 pose 1
* @param p2 pose 2
* @return axis angle difference
* \endenglish
*/
double poseAngleDistance(const std::vector<double> &p1,
const std::vector<double> &p2);
/**
* \chinese
* 姿
*
* @param p1 姿1
* @param p2 姿2
* @param eps
* @return truefalse
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.poseDistance","params":[[0.1, 0.3, 0.1,
* 0.3142, 0.0, 1.571],[0.1, 0.3, 0.1, 0.3142, 0.0, 1.5711]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":0.0}
* \endchinese
*
* \english
* Determine if two poses are equivalent
*
* @param p1 pose 1
* @param p2 pose 2
* @param eps error margin
* @return true or false
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.poseDistance","params":[[0.1, 0.3, 0.1,
* 0.3142, 0.0, 1.571],[0.1, 0.3, 0.1, 0.3142, 0.0, 1.5711]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":0.0}
* \endenglish
*/
bool poseEqual(const std::vector<double> &p1, const std::vector<double> &p2,
double eps = 5e-5);
/**
* \chinese
* @param F_b_a_old
* @param V_in_a
* @param type
* @return
*
* @par Python函数原型
* transferRefFrame(self: pyaubo_sdk.Math, arg0: List[float], arg1:
* List[float[3]], arg2: int) -> List[float]
*
* @par Lua函数原型
* transferRefFrame(F_b_a_old: table, V_in_a: table, type: number) -> table
* \endchinese
*
* \english
* @param F_b_a_old
* @param V_in_a
* @param type
* @return
*
* @par Python interface prototype
* transferRefFrame(self: pyaubo_sdk.Math, arg0: List[float], arg1:
* List[float[3]], arg2: int) -> List[float]
*
* @par Lua interface prototype
* transferRefFrame(F_b_a_old: table, V_in_a: table, type: number) -> table
* \endenglish
*/
std::vector<double> transferRefFrame(const std::vector<double> &F_b_a_old,
const Vector3d &V_in_a, int type);
/**
* \chinese
* 姿
*
* @param pose
* @param rotv
* @return
*
* @par Python函数原型
* poseRotation(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float])
* -> List[float]
*
* @par Lua函数原型
* poseRotation(pose: table, rotv: table) -> table
* \endchinese
*
* \english
* Pose rotation
*
* @param pose
* @param rotv
* @return
*
* @par Python interface prototype
* poseRotation(self: pyaubo_sdk.Math, arg0: List[float], arg1: List[float])
* -> List[float]
*
* @par Lua interface prototype
* poseRotation(pose: table, rotv: table) -> table
* \endenglish
*/
std::vector<double> poseRotation(const std::vector<double> &pose,
const std::vector<double> &rotv);
/**
* \chinese
*
*
* @param rpy
* @return
*
* @par Python函数原型
* rpyToQuaternion(self: pyaubo_sdk.Math, arg0: List[float]) -> List[float]
*
* @par Lua函数原型
* rpyToQuaternion(rpy: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.rpyToQuaternion","params":[[0.611, 0.785,
* 0.960]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.834721517970497,0.07804256900772265,0.4518931575790371,0.3048637712043723]}
* \endchinese
*
* \english
* Euler angles to quaternions
*
* @param rpy euler angles
* @return quaternions
*
* @par Python interface prototype
* rpyToQuaternion(self: pyaubo_sdk.Math, arg0: List[float]) -> List[float]
*
* @par Lua interface prototype
* rpyToQuaternion(rpy: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.rpyToQuaternion","params":[[0.611, 0.785,
* 0.960]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.834721517970497,0.07804256900772265,0.4518931575790371,0.3048637712043723]}
* \endenglish
*/
std::vector<double> rpyToQuaternion(const std::vector<double> &rpy);
/**
* \chinese
*
*
* @param quat
* @return
*
* @par Python函数原型
* quaternionToRpy(self: pyaubo_sdk.Math, arg0: List[float]) -> List[float]
*
* @par Lua函数原型
* quaternionToRpy(quat: table) -> table
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.quaternionToRpy","params":[[0.834722,
* 0.0780426, 0.451893, 0.304864]],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[0.6110000520523781,0.7849996877683915,0.960000543982093]}
* \endchinese
*
* \english
* Quaternions to euler angles
*
* @param quat quaternions
* @return euler angles
*
* @par Python interface prototype
* quaternionToRpy(self: pyaubo_sdk.Math, arg0: List[float]) -> List[float]
*
* @par Lua interface prototype
* quaternionToRpy(quat: table) -> table
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.quaternionToRpy","params":[[0.834722,
* 0.0780426, 0.451893, 0.304864]],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[0.6110000520523781,0.7849996877683915,0.960000543982093]}
* \endenglish
*/
std::vector<double> quaternionToRpy(const std::vector<double> &quat);
/**
* \chinese
* TCP偏移
*
* 姿
*
*
* @param poses 姿
* @return TCP标定结果和标定结果是否有效
*
* @par Python函数原型
* tcpOffsetIdentify(self: pyaubo_sdk.Math, arg0: List[List[float]]) ->
* Tuple[List[float], int]
*
* @par Lua函数原型
* tcpOffsetIdentify(poses: table) -> table
* \endchinese
*
* \english
* Four point method calibration for TCP offset
*
* About a sharp point, move the robot's tcp in four different poses. Difference between each pose should be drastic.
* Result can be obtained based on these four poses
*
* @param poses combination of four different poses
* @return TCP calibration result and whether successfull
*
* @par Python interface prototype
* tcpOffsetIdentify(self: pyaubo_sdk.Math, arg0: List[List[float]]) ->
* Tuple[List[float], int]
*
* @par Lua interface prototype
* tcpOffsetIdentify(poses: table) -> table
* \endenglish
*/
ResultWithErrno tcpOffsetIdentify(
const std::vector<std::vector<double>> &poses);
/**
* \chinese
*
*
* @param poses 姿
* @param type :\n
* 0 - oxy x轴正方向 xy平面y轴正方向\n
* 1 - oxz x轴正方向 xz平面z轴正方向\n
* 2 - oyz y轴正方向 yz平面z轴正方向\n
* 3 - oyx y轴正方向 yx平面x轴正方向\n
* 4 - ozx z轴正方向 zx平面x轴正方向\n
* 5 - ozy z轴正方向 zy平面y轴正方向\n
* @return
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.calibrateCoordinate","params":[[[0.55462,0.06219,0.37175,-3.142,0.0,1.580],
* [0.63746,0.11805,0.37175,-3.142,0.0,1.580],[0.40441,0.28489,0.37174,-3.142,0.0,1.580]],0],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[[0.55462,0.06219,0.37175,-3.722688983883945e-05,-1.6940658945086007e-21,0.5932768162455785],0]}
* \endchinese
*
* \english
* Calibrate coordinate system with 3 points
*
* @param poses set of 3 poses
* @param type type:\n
* 0 - oxy origin, +x axis, xy plane (+y direction) \n
* 1 - oxz origin, +x axis, xz plane (+z direction) \n
* 2 - oyz origin, +y axis, yz plane (+z direction) \n
* 3 - oyx origin, +y axis, yx plane (+x direction) \n
* 4 - ozx origin, +z axis, zx plane (+x direction) \n
* 5 - ozy origin, +z axis, zy plane (+y direction) \n
* @return Coordinate system calibration result and whether the calibration result is valid
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.calibrateCoordinate","params":[[[0.55462,0.06219,0.37175,-3.142,0.0,1.580],
* [0.63746,0.11805,0.37175,-3.142,0.0,1.580],[0.40441,0.28489,0.37174,-3.142,0.0,1.580]],0],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[[0.55462,0.06219,0.37175,-3.722688983883945e-05,-1.6940658945086007e-21,0.5932768162455785],0]}
* \endenglish
*/
ResultWithErrno calibrateCoordinate(
const std::vector<std::vector<double>> &poses, int type);
/**
* \chinese
* ,
*
* @param p1
* @param p2
* @param p3
* @param mode mode等于1的时候姿
* mode等于0的时候姿
*
* @return
*
* @par JSON-RPC请求示例
* {"jsonrpc":"2.0","method":"Math.calculateCircleFourthPoint","params":[[0.5488696249770836,-0.1214996547187204,0.2631931199112321,-3.14159198038469,-3.673205103150083e-06,1.570796326792424],
* [0.5488696249770835,-0.1214996547187207,0.3599720701808493,-3.14159198038469,-3.6732051029273e-06,1.570796326792423],
* [0.5488696249770836,-0.0389996547187214,0.3599720701808496,-3.141591980384691,-3.673205102557476e-06,
* 1.570796326792422],1],"id":1}
*
* @par JSON-RPC响应示例
* {"id":1,"jsonrpc":"2.0","result":[[0.5488696249770837,-0.031860179583911546,0.27033259504604207,-3.1415919803846903,-3.67320510285378e-06,1.570796326792423],1]}
*
* \endchinese
*
* \english
* Based on three points on an arc, calculate the position of the midpoint of the other half of the fitted circle's arc
*
* @param p1 start point of the arc
* @param p2 middle point of the arc
* @param p3 end point of the arc
* @param mode when mode = 1, need to plan for orientation around arc;
* when mode = 0, do not need to plan for orientation around arc.
* @return position of the midpoint of the other half of the fitted circle's arc and whether the result is valid.
*
* @par JSON-RPC request example
* {"jsonrpc":"2.0","method":"Math.calculateCircleFourthPoint","params":[[0.5488696249770836,-0.1214996547187204,0.2631931199112321,-3.14159198038469,-3.673205103150083e-06,1.570796326792424],
* [0.5488696249770835,-0.1214996547187207,0.3599720701808493,-3.14159198038469,-3.6732051029273e-06,1.570796326792423],
* [0.5488696249770836,-0.0389996547187214,0.3599720701808496,-3.141591980384691,-3.673205102557476e-06,
* 1.570796326792422],1],"id":1}
*
* @par JSON-RPC response example
* {"id":1,"jsonrpc":"2.0","result":[[0.5488696249770837,-0.031860179583911546,0.27033259504604207,-3.1415919803846903,-3.67320510285378e-06,1.570796326792423],1]}
*
* \endenglish
*/
ResultWithErrno calculateCircleFourthPoint(const std::vector<double> &p1,
const std::vector<double> &p2,
const std::vector<double> &p3,
int mode);
/**
* \chinese
* @brief forceTrans:
* force_in_b = pose_a_in_b * force_in_a
* @param pose_a_in_b: a b 姿
* @param force_in_a: a
* @return force_in_b b
* \endchinese
*
* \english
* @brief forceTrans:
* Transform the reference frame of force and torque: force_in_b = pose_a_in_b * force_in_a
* @param pose_a_in_b: pose of frame a in frame b
* @param force_in_a: force and torque described in frame a
* @return Force_in_b, force and torque described in frame b
* \endenglish
*/
std::vector<double> forceTrans(const std::vector<double> &pose_a_in_b,
const std::vector<double> &force_in_a);
/**
* \chinese
* @brief 姿
* @param distances: N , N >=3
* @param position:
* @param radius: tcp的等效半径
* @param track_scale: , (0, 1], 1
* @return 姿
* \endchinese
*
* \english
* @brief Calculate pose increment in tool coordinate system based on sensor data
* @param distances: N distances, N >= 3
* @param position: reference height to maintain from the trajectory
* @param radius: effective radius from sensor center to tool TCP
* @param track_scale: tracking ratio, range (0, 1], 1 means faster tracking
* @return Pose increment in tool coordinate system
* \endenglish
*/
std::vector<double> getDeltaPoseBySensorDistance(
const std::vector<double> &distances, double position, double radius,
double track_scale);
/**
* \chinese
* @brief changeFTFrame:
* @param pose_a_in_b: a b 姿
* @param ft_in_a: a a
* @return ft_in_b b b
* \endchinese
*
* \english
* @brief changeFTFrame: Transform the reference frame of force and torque
* @param pose_a_in_b: pose of frame a in frame b
* @param ft_in_a: force and torque applied at point a, described in frame a
* @return ft_in_b, force and torque applied at point b, described in frame b
* \endenglish
*/
std::vector<double> deltaPoseTrans(const std::vector<double> &pose_a_in_b,
const std::vector<double> &ft_in_a);
/**
* \chinese
* @brief addDeltaPose: 姿
* @param pose_a_in_b: a b 姿
* @param v_in_b: a b
* @return pose_in_b, 姿 b
* \endchinese
*
* \english
* @brief addDeltaPose: Calculate the pose after unit time given a velocity
* @param pose_a_in_b: current pose of a relative to b
* @param v_in_b: velocity of frame a described in frame b at current time
* @return pose_in_b, pose after unit time described in frame b
* \endenglish
*/
std::vector<double> deltaPoseAdd(const std::vector<double> &pose_a_in_b,
const std::vector<double> &v_in_b);
/**
* \chinese
* @brief changePoseWithXYRef: pose_tar , pose_ref
* @param pose_tar: 姿
* @param pose_ref: 姿
* @return 姿pose_tar的 xyz z
* \endchinese
*
* \english
* @brief changePoseWithXYRef: Modify the XY axis direction of pose_tar to be as consistent as possible with pose_ref
* @param pose_tar: target pose to be modified
* @param pose_ref: reference pose
* @return Modified pose, using the xyz coordinates and z axis direction of pose_tar
* \endenglish
*/
std::vector<double> changePoseWithXYRef(
const std::vector<double> &pose_tar,
const std::vector<double> &pose_ref);
/**
* \chinese
* @brief homMatrixToPose: 姿
* @param homMatrix: 4*4 ,
* @return 姿
* \endchinese
*
* \english
* @brief homMatrixToPose: Get pose from homogeneous transformation matrix
* @param homMatrix: 4x4 homogeneous transformation matrix, input elements are arranged row-wise
* @return corresponding pose
* \endenglish
*/
std::vector<double> homMatrixToPose(const std::vector<double> &homMatrix);
/**
* \chinese
* @brief poseToHomMatrix: 姿
* @param pose: 姿
* @return ,
* \endchinese
*
* \english
* @brief poseToHomMatrix: Get homogeneous transformation matrix from pose
* @param pose: input pose
* @return output homogeneous transformation matrix, elements arranged row-wise
* \endenglish
*/
std::vector<double> poseToHomMatrix(const std::vector<double> &pose);
protected:
void *d_;
};
using MathPtr = std::shared_ptr<Math>;
} // namespace common_interface
} // namespace arcs
#endif