top of page

4.12. Cartesian Space Full Circle Motion (Automatic Inverse Kinematics Calculation)

4.12. Cartesian Space Full Circle Motion (Automatic Inverse Kinematics Calculation)

/**
* @brief Cartesian Space Full Circle Motion (Automatic Inverse Kinematics Calculation)
* @param [in] desc_pos_p  Path point 1 Cartesian pose
* @param [in] ptool Tool coordinate number, range [0~14]
* @param [in] puser Workpiece coordinate number, range [0~14]
* @param [in] pvel Velocity percentage, range [0~100]
* @param [in] pacc Acceleration percentage, range [0~100], temporarily not available
* @param [in] epos_p Extended axis position, unit: mm
* @param [in] desc_pos_t  Path point 2 Cartesian pose
* @param [in] ttool Tool coordinate number, range [0~14]
* @param [in] tuser Workpiece coordinate number, range [0~14]
* @param [in] tvel Velocity percentage, range [0~100]
* @param [in] tacc Acceleration percentage, range [0~100], temporarily not available
* @param [in] epos_t Extended axis position, unit: mm
* @param [in] ovl Velocity scaling factor, range [0~100]
* @param [in] offset_flag 0-No offset, 1-Offset in base coordinate system/workpiece coordinate system, 2-Offset in tool coordinate system
* @param [in] offset_pos Pose offset value
* @param [in] oacc Acceleration percentage
* @param [in] blendR -1: Blocking; 0~1000: Smoothing radius
* @param [in] config Inverse kinematics joint space configuration, [-1]-Calculate based on current joint position, [0~7]-Solve based on specific joint space configuration
* @return Error code
*/
errno_t Circle(DescPose* desc_pos_p, int ptool, int puser, float pvel, float pacc, ExaxisPos* epos_p, DescPose* desc_pos_t, int ttool, int tuser, float tvel, float tacc, ExaxisPos* epos_t, float ovl, uint8_t offset_flag, DescPose* offset_pos, double oacc = 100.0, double blendR = -1, int config = -1);

4.13. Cartesian Space Point-to-Point Motion

/**
* @brief  Cartesian Space Point-to-Point Motion
* @param  [in]  desc_pos  Target Cartesian pose or pose increment
* @param  [in] tool  Tool coordinate number, range [0~14]
* @param  [in] user  Workpiece coordinate number, range [0~14]
* @param  [in] vel  Velocity percentage, range [0~100]
* @param  [in] acc  Acceleration percentage, range [0~100], temporarily not available
* @param  [in] ovl  Velocity scaling factor, range [0~100]
* @param  [in] blendT [-1.0]-Move to position (blocking), [0~500.0]-Smoothing time (non-blocking), unit: ms
* @param  [in] config  Joint space configuration, [-1]-Calculate based on current joint position, [0~7]-Calculate based on specific joint space configuration, default is -1
* @return  Error code
*/
errno_t  MoveCart(DescPose *desc_pos, int tool, int user, float vel, float acc, float ovl, float blendT, int config);

4.14. Robot Basic Motion Instruction Code Example

int TestMove(void)
{
    ROBOT_STATE_PKG pkg = {};
    FRRobot robot;

    robot.LoggerInit();
    robot.SetLoggerLevel(1);
    int rtn = robot.RPC("192.168.58.2");
    if (rtn != 0)
    {
        return -1;
    }
    robot.SetReConnectParam(true, 30000, 500);

    JointPos j1(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
    JointPos j2(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
    JointPos j3(-29.777, -84.536, 109.275, -114.075, -86.655, 74.257);
    JointPos j4(-31.154, -95.317, 94.276, -88.079, -89.740, 74.256);
    DescPose desc_pos1(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
    DescPose desc_pos2(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
    DescPose desc_pos3(-487.434, 154.362, 308.576, 176.600, 0.268, -14.061);
    DescPose desc_pos4(-443.165, 147.881, 480.951, 179.511, -0.775, -15.409);
    DescPose offset_pos(0, 0, 0, 0, 0, 0);
    ExaxisPos epos(0, 0, 0, 0);
    int tool = 0;
    int user = 0;
    float vel = 100.0;
    float acc = 100.0;
    float ovl = 100.0;
    float oacc = 100.0;
    float blendT = 0.0;
    float blendR = 0.0;
    uint8_t flag = 0;
    uint8_t search = 0;
    int blendMode = 0;
    int velAccMode = 0;
    robot.SetSpeed(20);
    rtn = robot.MoveJ(&j1, &desc_pos1, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
    printf("movej errcode:%d\n", rtn);
    rtn = robot.MoveL(&j2, &desc_pos2, tool, user, vel, acc, ovl, blendR, blendMode, &epos, search, flag, &offset_pos, oacc, velAccMode);
    printf("movel errcode:%d\n", rtn);
    rtn = robot.MoveC(&j3, &desc_pos3, tool, user, vel, acc, &epos, flag, &offset_pos, &j4, &desc_pos4, tool, user, vel, acc, &epos, flag, &offset_pos, ovl, blendR, oacc, velAccMode);
    printf("movec errcode:%d\n", rtn);
    rtn = robot.MoveJ(&j2, &desc_pos2, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
    printf("movej errcode:%d\n", rtn);
    rtn = robot.Circle(&j3, &desc_pos3, tool, user, vel, acc, &epos, &j1, &desc_pos1, tool, user, vel, acc, &epos, ovl, flag, &offset_pos, oacc, -1, velAccMode);
    printf("circle errcode:%d\n", rtn);
    rtn = robot.MoveCart(&desc_pos4, tool, user, vel, acc, ovl, blendT, -1);
    printf("MoveCart errcode:%d\n", rtn);
    rtn = robot.MoveJ(&j1, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
    printf("movej errcode:%d\n", rtn);
    rtn = robot.MoveL(&desc_pos2, tool, user, vel, acc, ovl, blendR, blendMode, &epos, search, flag, &offset_pos, -1, velAccMode);
    printf("movel errcode:%d\n", rtn);
    rtn = robot.MoveC(&desc_pos3, tool, user, vel, acc, &epos, flag, &offset_pos, &desc_pos4, tool, user, vel, acc, &epos, flag, &offset_pos, ovl, blendR, -1, velAccMode);
    printf("movec errcode:%d\n", rtn);
    rtn = robot.MoveJ(&j2, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
    printf("movej errcode:%d\n", rtn);
    rtn = robot.Circle(&desc_pos3, tool, user, vel, acc, &epos, &desc_pos1, tool, user, vel, acc, &epos, ovl, flag, &offset_pos, oacc, blendR, -1, velAccMode);
    printf("circle errcode:%d\n", rtn);
    robot.CloseRPC();
    return 0;
}

4.15. Cartesian Space Spiral Motion

/**
* @brief  Cartesian Space Spiral Motion
* @param  [in] joint_pos  Target joint position, unit: deg
* @param  [in] desc_pos   Target Cartesian pose
* @param  [in] tool  Tool coordinate number, range [0~14]
* @param  [in] user  Workpiece coordinate number, range [0~14]
* @param  [in] vel  Velocity percentage, range [0~100]
* @param  [in] acc  Acceleration percentage, range [0~100], temporarily not available
* @param  [in] epos  Extended axis position, unit: mm
* @param  [in] ovl  Velocity scaling factor, range [0~100]
* @param  [in] offset_flag  0-No offset, 1-Offset in base coordinate system/workpiece coordinate system, 2-Offset in tool coordinate system
* @param  [in] offset_pos  Pose offset value
* @param  [in] spiral_param  Spiral parameters
* @return  Error code
*/
errno_t  NewSpiral(JointPos *joint_pos, DescPose *desc_pos, int tool, int user, float vel, float acc, ExaxisPos *epos, float ovl, uint8_t offset_flag, DescPose *offset_pos, SpiralParam spiral_param);

4.16. Cartesian Space Spiral Motion (Automatic Inverse Kinematics Calculation)

/**
* @brief Cartesian Space Spiral Motion (Automatic Inverse Kinematics Calculation)
* @param [in] desc_pos  Target Cartesian pose
* @param [in] tool Tool coordinate number, range [0~14]
* @param [in] user Workpiece coordinate number, range [0~14]
* @param [in] vel Velocity percentage, range [0~100]
* @param [in] acc Acceleration percentage, range [0~100], temporarily not available
* @param [in] epos Extended axis position, unit: mm
* @param [in] ovl Velocity scaling factor, range [0~100]
* @param [in] offset_flag 0-No offset, 1-Offset in base coordinate system/workpiece coordinate system, 2-Offset in tool coordinate system
* @param [in] offset_pos Pose offset value
* @param [in] spiral_param Spiral parameters
* @param [in] config Inverse kinematics joint space configuration, [-1]-Calculate based on current joint position, [0~7]-Solve based on specific joint space configuration
* @return Error code
*/
errno_t NewSpiral(DescPose* desc_pos, int tool, int user, float vel, float acc, ExaxisPos* epos, float ovl, uint8_t offset_flag, DescPose* offset_pos, SpiralParam spiral_param, int config = -1);

4.17. Spiral Motion Code Example

int TestSpiral(void)
{
  ROBOT_STATE_PKG pkg = {};
  FRRobot robot;
  robot.LoggerInit();
  robot.SetLoggerLevel(1);
  int rtn = robot.RPC("192.168.58.2");
  if (rtn != 0)
  {
    return -1;
  }
  robot.SetReConnectParam(true, 30000, 500);
  JointPos j(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
  DescPose desc_pos(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
  DescPose offset_pos1(50, 0, 0, -30, 0, 0);
  DescPose offset_pos2(50, 0, 0, -5, 0, 0);
  ExaxisPos epos(0, 0, 0, 0);
  SpiralParam sp;
  sp.circle_num = 5;
  sp.circle_angle = 5.0;
  sp.rad_init = 50.0;
  sp.rad_add = 10.0;
  sp.rotaxis_add = 10.0;
  sp.rot_direction = 0;
  int tool = 0;
  int user = 0;
  float vel = 100.0;
  float acc = 100.0;
  float ovl = 100.0;
  float blendT = 0.0;
  uint8_t flag = 2;
  robot.SetSpeed(20);
  rtn = robot.MoveJ(&j, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos1);
  printf("movej errcode:%d\n", rtn);
  rtn = robot.NewSpiral(&desc_pos, tool, user, vel, acc, &epos, ovl, flag, &offset_pos2, sp);
  printf("newspiral errcode:%d\n", rtn);
  robot.CloseRPC();
  return 0;
}

4.18. Servo Motion Start

/**
* @brief Servo motion start, used with ServoJ and ServoCart commands
* @return Error code
*/
errno_t ServoMoveStart();

4.19. Servo Motion End

/**
* @brief Servo motion end, used with ServoJ and ServoCart commands
* @return Error code
*/
errno_t ServoMoveEnd();

4.20. Joint Space Servo Mode Motion

/**
* @brief Joint space servo mode motion
* @param [in] joint_pos Target joint position in deg
* @param [in] acc Acceleration percentage [0~100] (not yet available, default 0)
* @param [in] vel Speed percentage [0~100] (not yet available, default 0)
* @param [in] cmdT Command cycle in seconds, recommended range [0.001~0.0016]
* @param [in] filterT Filter time in seconds (not yet available, default 0)
* @param [in] gain Target position proportional amplifier (not yet available, default 0)
* @param  [in] gain  The target position of the proportional amplifier, temporarily closed, the default is 0
* @param  [in] id servoJInstruction ID, which defaults to 0
* @return  error code
*/
errno_t ServoJ(JointPos *joint_pos, ExaxisPos* axisPos, float acc, float vel, float cmdT, float filterT, float gain, int id = 0);

4.21. Joint Space Servo Mode Motion Example

int TestServoJ(void)
{
    ROBOT_STATE_PKG pkg = {};
    FRRobot robot;
    robot.LoggerInit();
    robot.SetLoggerLevel(1);
    int rtn = robot.RPC("192.168.58.2");
    if (rtn != 0)
    {
        return -1;
    }
    robot.SetReConnectParam(true, 30000, 500);
    JointPos j(0, 0, 0, 0, 0, 0);
    ExaxisPos epos(0, 0, 0, 0);
    float vel = 0.0;
    float acc = 0.0;
    float cmdT = 0.008;
    float filterT = 0.0;
    float gain = 0.0;
    uint8_t flag = 0;
    int count = 500;
    float dt = 0.1;
    int ret = robot.GetActualJointPosDegree(flag, &j);
    if (ret == 0)
    {
        robot.ServoMoveStart();
        while (count)
        {
            robot.ServoJ(&j, &epos, acc, vel, cmdT, filterT, gain);
            j.jPos[0] += dt;
            count -= 1;
            robot.WaitMs(cmdT * 1000);
        }
        robot.ServoMoveEnd();
    }
    else
    {
        printf("GetActualJointPosDegree errcode:%d\n", ret);
    }
    robot.CloseRPC();
    return 0;
}

robotic arm
FAIRINO ROBOTIC ARMS

Contact

Location: 10637 Scripps Summit Court,

San Diego, CA. 92131
Phone: (619) 333-FAIR
Email: hello@fairino.us

© 2023 Fairino US official site Proudly created By G2T

bottom of page