top of page

Java 4.27. Joint space servo mode movement example program

public static void TestServoJ()
{
    Robot robot = new Robot();
    robot.SetReconnectParam(true,20,500);//Set reconnection times and interval
    robot.LoggerInit(FrLogType.DIRECT, FrLogLevel.INFO, "D://log", 10, 10);
    int rtn = robot.RPC("192.168.58.2");
    if(rtn == 0)
    {
        System.out.println("rpc connection success");
    }
    else
    {
        System.out.println("rpc connection fail");
        return ;
    }
    JointPos j5 = new JointPos();
    ExaxisPos ePos=new ExaxisPos();
    int ret = robot.GetActualJointPosDegree(j5);
    if (ret == 0)
    {
        int count = 200;
        while (count > 0)
        {
            robot.ServoJ(j5, ePos,100, 100, 0.008, 0, 0);
            j5.J1 += 0.2;//Joint 1 position increase
            count -= 1;
            robot.WaitMs((int)(8));
        }
    }
}

4.28. Joint torque control start

/**
* @brief  Joint torque control start
* @return  Error code
*/
int ServoJTStart()

4.29. Joint torque control

/**
* @brief Joint Torque Control
* @param torque Torque for joints j1~j6, unit: Nm
* @param interval Command cycle, unit: s, range: [0.001~0.008]
* @param checkFlag Detection strategy
*                  0-No restrictions;
*                  1-Power limit;
*                  2-Velocity limit;
*                  3-Both power and velocity limits
* @param jPowerLimit Maximum joint power limit for each joint (W)
* @param jVelLimit Maximum joint velocity for each joint (°/s)
* @return Error code
*/
public int ServoJT(double[] torque, double interval, int checkFlag, double[] jPowerLimit, double[] jVelLimit)

4.30. Joint torque control end

/**
* @brief  Joint torque control end
* @return  Error code
*/
int ServoJTEnd()

4.31. Joint space servo mode movement example program

public static int TestServoJT(Robot robot)
{

    robot.DragTeachSwitch(1);
    List<Number> joint_toq=new ArrayList<>();
    joint_toq=robot.GetJointTorques(1);

    int count = 100;
    robot.ServoJTStart(); //   #servoJT start
    int error = 0;
    while (count > 0)
    {
        error = robot.ServoJT(torques, 0.001);
        count = count - 1;
        robot.Sleep(1);
    }
    error = robot.ServoJTEnd();
    robot.DragTeachSwitch(0);

    robot.CloseRPC();
    return 0;
}

4.32. Joint Torque Control Code Example with Overspeed Protection

public static void ServoJTWithSafety(Robot robot)
{
    robot.ResetAllError();
    robot.Sleep(500);
    List<Number> torques;
    torques = robot.GetJointTorques(1);
    robot.ServoJTStart(); // Start servoJT
    ROBOT_STATE_PKG pkg = new ROBOT_STATE_PKG();
    robot.DragTeachSwitch(1);
    int checkFlag = 3; // -1,3 - Both power and velocity limits
    // double[] jPowerLimit = {1.0,1.0,1.0,1.0,1.0,1.0}; // 5001
    double[] jPowerLimit = { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 }; // Power limits for each joint (W)
    double[] jVelLimit = { 50, 50, 50, 50, 50, 50 }; // 180.1,-1 - Velocity limits for each joint (°/s)
    int count = 800000;
    int error = 0;
    double[] tor = new double[]{(double)torques.get(1), (double)torques.get(2), (double)torques.get(3),
                               (double)torques.get(4), (double)torques.get(5), (double)torques.get(6)};
    while (count > 0)
    {
        tor[2] = tor[2] + 0.01; // Increase torque of axis 1 by 0.01NM each time, moving 100 times
        error = robot.ServoJT(tor, 0.01, checkFlag, jPowerLimit, jVelLimit); // Joint space servo mode motion
        System.out.printf("ServoJT return is %d\n", error);
        count = count - 1;
        robot.Sleep(1);
        pkg = robot.GetRobotRealTimeState();
        System.out.printf("maincode %d, subcode %d\n", pkg.main_code, pkg.sub_code);
    }
    robot.DragTeachSwitch(0);
    error = robot.ServoJTEnd(); // End servo motion
}

4.33. Cartesian Space Servo Mode Motion

/**
* @brief Cartesian space servo mode motion
* @param mode 0-Absolute motion (base coordinate system), 1-Incremental motion (base coordinate system), 2-Incremental motion (tool coordinate system)
* @param desc_pose Target Cartesian pose or pose increment
* @param exaxis Extended axis position
* @param pos_gain Pose increment proportionality coefficient, only effective in incremental motion, range [0~1]
* @param acc Acceleration percentage, range [0~100], temporarily not available, default 0
* @param vel Velocity percentage, range [0~100], temporarily not available, default 0
* @param cmdT Command transmission period, unit s, recommended range [0.001~0.016]
* @param filterT Filter time, unit s, temporarily not available, default 0
* @param gain Proportional amplifier for target position, temporarily not available, default 0
* @return Error code
*/
public int ServoCart(int mode, DescPose desc_pose, ExaxisPos exaxis, double[] pos_gain, double acc, double vel, double cmdT, double filterT, double gain)

4.34. Cartesian Space Servo Mode Motion Code Example

public static void TestServoCart1(Robot robot)
{
    DescPose desc_pos_dt = new DescPose(83.00800, 50.525000 , 29.246 , 179.629 , -7.138 , -166.975 );
    ExaxisPos exaxis = new ExaxisPos( 100.0, 0.0, 0.0, 0.0 );
    double[] pos_gain = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
    int mode = 0;
    double vel = 0.0;
    double acc = 0.0;
    double cmdT = 0.001;
    double filterT = 0.0;
    double gain = 0.0;
    int flag = 0;
    int count = 5000;
    robot.SetSpeed(20);
    while (count>0)
    {
        int rtn = robot.ServoCart(mode, desc_pos_dt, exaxis, pos_gain, acc, vel, cmdT, filterT, gain);
        System.out.printf("ServoCart rtn is %d\n", rtn);
        count -= 1;
        desc_pos_dt.tran.x += 0.01;
        exaxis.axis1 += 0.01;
    }
    robot.CloseRPC();
}

4.35. Spline movement start

/**
* @brief  Spline movement start
* @return  Error code
*/
int SplineStart();

4.36. Joint movement PTP

/**
* @brief  Joint space spline movement
* @param  [in] joint_pos  Target joint position in 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  Speed percentage, range [0~100]
* @param  [in] acc  Acceleration percentage, range [0~100], not currently available
* @param  [in] ovl  Speed scaling factor, range [0~100]
* @return  Error code
*/
int SplinePTP(JointPos joint_pos, DescPose desc_pos, int tool, int user, double vel, double acc, double ovl);

4.37. Joint space spline motion (automatic forward kinematics calculation)

New in version Java: SDK-v1.0.8-3.8.5

/**
* @brief Joint space spline motion (automatic forward kinematics calculation)
* @param [in] joint_pos  Target joint position, unit deg
* @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], not open yet
* @param [in] ovl  Velocity scaling factor, range [0~100]
* @return Error code
*/
int SplinePTP(JointPos joint_pos, int tool, int user, double vel, double acc, double ovl)

4.38. Spline movement end

/**
* @brief  Spline movement end
* @return  Error code
*/
int SplineEnd();

4.39. Spline movement code example

public static int TestSpline(Robot robot)
{
    JointPos j1=new JointPos(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
    JointPos j2=new JointPos(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
    JointPos j3=new JointPos(-61.954, -84.409, 108.153, -116.316, -91.283, 74.260);
    JointPos j4=new JointPos(-89.575, -80.276, 102.713, -116.302, -91.284, 74.267);
    DescPose offset_pos=new DescPose(0, 0, 0, 0, 0, 0);
    ExaxisPos epos=new ExaxisPos(0, 0, 0, 0);

    int tool = 0;
    int user = 0;
    double vel = 100.0;
    double acc = 100.0;
    double ovl = 100.0;
    double blendT = -1.0;
    int flag = 0;

    int err1 = robot.MoveJ(j1, tool, user, vel, acc, ovl, epos, blendT, flag, offset_pos);
    System.out.println("movej errcode:"+ err1);
    robot.SplineStart();
    robot.SplinePTP(j1, tool, user, vel, acc, ovl);
    robot.SplinePTP(j2, tool, user, vel, acc, ovl);
    robot.SplinePTP(j3, tool, user, vel, acc, ovl);
    robot.SplinePTP(j4, tool, user, vel, acc, ovl);
    robot.SplineEnd();
    return 0;
}

4.40. New spline movement start

/**
* @brief New spline movement start
* @param [in] type   0-circular transition, 1-given points as path points
* @param [in] averageTime  Global average transition time(ms)(10 ~  ), default 2000
* @return Error code
*/
int NewSplineStart(int type, int averageTime);

4.41. New spline command point

/**
* @brief Add spline movement command point
* @param [in] joint_pos  Target joint position in 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  Speed percentage, range [0~100]
* @param [in] acc  Acceleration percentage, range [0~100], not currently available
* @param [in] ovl  Speed scaling factor, range [0~100]
* @param [in] blendR [-1.0]-move to position (blocking), [0~1000.0]-smoothing radius (non-blocking) in mm
* @param [in] lastFlag Whether it is the last point, 0-no, 1-yes
* @return Error code
*/
int NewSplinePoint(JointPos joint_pos, DescPose desc_pos, int tool, int user, double vel, double acc, double ovl, double blendR, int lastFlag);

4.42. New spline command point (automatic inverse kinematics calculation)

New in version Java: SDK-v1.0.8-3.8.5

/**
* @brief New spline command point (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], not open yet
* @param [in] ovl  Velocity scaling factor, range [0~100]
* @param [in] blendR [-1.0]-move to position (blocking), [0~1000.0]-smoothing radius (non-blocking), unit mm
* @param [in] lastFlag Whether it is the last point, 0-no, 1-yes
* @param [in] config Inverse kinematics joint space configuration, [-1]-calculate based on current joint position, [0~7]-solve according to specific joint space configuration
* @return Error code
*/
int NewSplinePoint(DescPose desc_pos, int tool, int user, double vel, double acc, double ovl, double blendR, int lastFlag,int config)

4.43. New spline movement end

/**
* @brief New spline movement start
* @return Error code
*/
int NewSplineEnd();

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