top of page

11. Robot Peripherals

11.1. Configure Gripper

/**
* @brief  Configure gripper
* @param  [in] company  Gripper manufacturer, to be determined
* @param  [in] device  Device number, not currently used, default is 0
* @param  [in] softvesion  Software version number, not currently used, default is 0
* @param  [in] bus Device bus position, currently unused, default is 0
* @return  Error code
*/
int SetGripperConfig(int company, int device, int softvesion, int bus);

11.2. Get gripper configuration

/**
* @brief  Get gripper configuration
* @param  [in] company  Gripper manufacturer, to be determined
* @param  [in] device  Device number, currently unused, default is 0
* @param  [in] softvesion  Software version number, currently unused, default is 0
* @param  [in] bus Device bus position, currently unused, default is 0
* @return  Error code
*/
int GetGripperConfig(int *company, int *device, int *softvesion, int *bus);

11.3. Activate Gripper

/**
* @brief  Activate gripper
* @param  [in] index  Gripper number
* @param  [in] act  0-reset, 1-activate
* @return  Error code
*/
int ActGripper(int index, byte act);

11.4. Control gripper

/**
* @brief  Control gripper
* @param  [in] index  Gripper ID
* @param  [in] pos  Position percentage, range [0~100]
* @param  [in] vel  Speed percentage, range [0~100]
* @param  [in] force  Torque percentage, range [0~100]
* @param  [in] max_time  Maximum wait time, range [0~30000], unit ms
* @param  [in] block  0-blocking, 1-non-blocking
* @param  [in] type Gripper type, 0-parallel gripper; 1-rotating gripper
* @param  [in] rotNum Number of rotation cycles
* @param  [in] rotVel Rotation speed percentage [0-100]
* @param  [in] rotTorque Rotation torque percentage [0-100]
* @return Error code
*/
int MoveGripper(int index, int pos, int vel, int force, int max_time, byte block, int type, double rotNum, int rotVel, int rotTorque);

11.5. Get gripper motion status

/**
* @brief  Get gripper motion status
* @param  [out] fault  0-no error, 1-error
* @param  [out] staus  0-motion not completed, 1-motion completed
* @return  Error code
*/
int GetGripperMotionDone(ref int fault, ref int status);

11.6. Get gripper activation status

/**
* @brief  Get gripper activation status
* @param  [out] fault  0-no error, 1-error
* @param  [out] status  bit0~bit15 corresponds to gripper numbers 0~15, bit=0 is not activated, bit=1 is activated
* @return  Error code
*/
int GetGripperActivateStatus(ref int fault, ref int status);

11.7. Get Gripper Position

/**
* @brief  Get gripper position
* @param  [out] fault  0-no error, 1-error
* @param  [out] position  Position percentage, range 0~100%
* @return  Error code
*/
int GetGripperCurPosition(ref int fault, ref int position);

11.8. Get gripper speed

/**
* @brief  Get gripper speed
* @param  [out] fault  0-no error, 1-error
* @param  [out] speed  Speed percentage, range 0~100%
* @return  Error code
*/
int GetGripperCurSpeed(ref int fault, ref int speed);

11.9. Get gripper current

/**
* @brief  Get gripper current
* @param  [out] fault  0-no error, 1-error
* @param  [out] current  Current percentage, range 0~100%
* @return Error code
*/
int GetGripperCurrent(ref int fault, ref int current);

11.10. Get gripper voltage

/**
* @brief Get gripper voltage
* @param [out] fault 0-no error, 1-error
* @param  [out] voltage  Voltage, unit 0.1V
* @return  Error code
*/
int GetGripperVoltage(ref int fault, ref int voltage);

11.11. Get gripper temperature

/**
* @brief  Get gripper temperature
* @param  [out] fault  0-no error, 1-error
* @param  [out] temp  Temperature, unit °C
* @return  Error code
*/
int GetGripperTemp(ref int fault, ref int temp);

11.12. Calculate pre-gripping point - vision

/**
* @brief Calculate pre-gripping point - vision
* @param [in] desc_pos Gripping point Cartesian pose
* @param [in] zlength Z-axis offset
* @param [in] zangle Rotation offset around the z-axis
* @param [out] pre_pos Pre-pick point
* @return Error code
*/
int ComputePrePick(DescPose desc_pos, double zlength, double zangle, ref DescPose pre_pos);

11.13. Calculate retreat point - vision

/**
* @brief Calculate retreat point - visual
* @param [in] desc_pos Retreat point Cartesian pose
* @param [in] zlength Z-axis offset
* @param [in] zangle Rotation offset around the Z-axis
* @param [out] post_pos Retreat point
* @return Error code
*/
int ComputePostPick(DescPose desc_pos, double zlength, double zangle, ref DescPose post_pos);

11.14. Robot Gripper Operation Code Example

private void button36_Click(object sender, EventArgs e)
{
    int company = 4;
    int device = 0;
    int softversion = 0;
    int bus = 2;
    int index = 2;
    byte act = 0;
    int max_time = 30000;
    byte block = 0;
    int status=0;
    int fault=0;
    int active_status = 0;
    int current_pos = 0;
    int current = 0;
    int voltage = 0;
    int temp = 0;
    int speed = 0;

    robot.SetGripperConfig(company, device, softversion, bus);
    Thread.Sleep(1000);
    robot.GetGripperConfig(ref company, ref device, ref softversion, ref bus);
    Console.WriteLine("gripper config:{0},{1},{2},{3}\n", company, device, softversion, bus);

    robot.ActGripper(index, act);
    Thread.Sleep(1000);
    act = 1;
    robot.ActGripper(index, act);
    Thread.Sleep(1000);

    robot.MoveGripper(index, 90, 50, 50, max_time, block, 0, 0, 0, 0);
    Thread.Sleep(1000);
    robot.MoveGripper(index, 30, 50, 0, max_time, block, 0, 0, 0, 0);

    robot.GetGripperMotionDone(ref fault, ref status);
    Console.WriteLine("motion status:{0},{1}\n", fault, status);

    robot.GetGripperActivateStatus(ref fault, ref active_status);
    Console.WriteLine("gripper active fault is: {0}, status is: {1}\n", fault, active_status);

    robot.GetGripperCurPosition(ref fault, ref current_pos);
    Console.WriteLine("fault is:{0}, current position is: {1}\n", fault, current_pos);

    robot.GetGripperCurCurrent(ref fault, ref current);
    Console.WriteLine("fault is:{0}, current current is: {1}\n", fault, current);

    robot.GetGripperVoltage(ref fault, ref voltage);
    Console.WriteLine("fault is:{0}, current voltage is: {1} \n", fault, voltage);

    robot.GetGripperTemp(ref fault, ref temp);
    Console.WriteLine("fault is:{0}, current temperature is: {1}\n", fault, temp);

    robot.GetGripperCurSpeed(ref fault, ref speed);
    Console.WriteLine("fault is:{0}, current speed is: {1}\n", fault, speed);

    int retval = 0;
    DescPose prepick_pose = new DescPose();
    DescPose postpick_pose = new DescPose();

    DescPose p1Desc = new DescPose(-419.524f, -13.000f, 351.569f, -178.118f, 0.314f, 3.833f);
    DescPose p2Desc = new DescPose(-321.222f, 185.189f, 335.520f, -179.030f, -1.284f, -29.869f);

    retval = robot.ComputePrePick(p1Desc, 10, 0, ref prepick_pose);
    Console.WriteLine("ComputePrePick retval is: {0}\n", retval);
    Console.WriteLine("xyz is: {0}, {1}, {2}; rpy is: {3}, {4}, {5}\n",
        prepick_pose.tran.x, prepick_pose.tran.y, prepick_pose.tran.z,
        prepick_pose.rpy.rx, prepick_pose.rpy.ry, prepick_pose.rpy.rz);

    retval = robot.ComputePostPick( p2Desc, -10, 0, ref postpick_pose);
    Console.WriteLine("ComputePostPick retval is: {0}\n", retval);
    Console.WriteLine("xyz is: {0}, {1}, {2}; rpy is: {3}, {4}, {5}\n",
        postpick_pose.tran.x, postpick_pose.tran.y, postpick_pose.tran.z,
        postpick_pose.rpy.rx, postpick_pose.rpy.ry, postpick_pose.rpy.rz);

}

11.15. Get the number of rotations of the rotating gripper

/**
* @brief  Get the number of rotations of the rotating gripper
* @param  [out] fault  0-no error, 1-error
* @param  [out] num  Number of rotations
* @return  Error code
*/
int GetGripperRotNum(ref UInt16 fault, ref double num);

11.16. Get the rotation speed percentage of the rotating gripper

/**
* @brief  Get the rotation speed percentage of the rotating gripper
* @param  [out] fault  0-no error, 1-error
* @param  [out] speed  Rotation speed percentage
* @return  Error code
*/
int GetGripperRotSpeed(ref UInt16 fault, ref int speed);

11.17. Get the rotation torque percentage of the rotating gripper

/**
* @brief  Get the rotational torque percentage of the rotating gripper
* @param  [out] fault  0-no error, 1-error
* @param  [out] torque  Rotational torque percentage
* @return  Error code
*/
int GetGripperRotTorque(ref UInt16 fault, ref int torque);

11.18. Example of retrieving the rotational gripper status code

int MoveRotGripper(int pos, double rotPos)
{
    robot.ResetAllError();
    robot.ActGripper(1, 1);
    Thread.Sleep(1000);
    int rtn = robot.MoveGripper(1, pos, 50, 50, 5000, 1, 1, rotPos, 50, 100);
    Console.WriteLine($"move gripper rtn is {rtn}" );
    UInt16 fault = 0;
    double rotNum = 0.0;
    int rotSpeed = 0;
    int rotTorque = 0;
    robot.GetGripperRotNum(ref fault, ref rotNum);
    robot.GetGripperRotSpeed(ref fault, ref rotSpeed);
    robot.GetGripperRotTorque(ref fault, ref rotTorque);
    Console.WriteLine($"gripper rot num :{ rotNum}, gripper rotSpeed :{rotSpeed}, gripper rotTorque : { rotTorque}");
    return 0;
}

11.19. Drive belt start/stop

/**
* @brief Conveyor belt start/stop
* @param [in] status Status, 1-start, 0-stop
* @return Error code
*/
int ConveyorStartEnd(byte status);

11.20. Record IO detection points

/**
* @brief Record IO detection point
* @return Error code
*/
int ConveyorPointIORecord();

11.21. Record point A

/**
* @brief Record Point A
* @return Error code
*/
int ConveyorPointARecord();

11.22. Record reference point

/**
* @brief Record reference point
* @return Error code
*/
int ConveyorRefPointRecord();

11.23. Record Point B

/**
* @brief Record Point B
* @return Error code
*/
int ConveyorPointBRecord();

11.24. Conveyor belt workpiece IO detection

/**
* @brief Conveyor workpiece IO detection
* @param [in] max_t Maximum detection time, unit ms
* @return Error code
*/
int ConveyorIODetect(int max_t);

11.25. Get Object Current Position

/**
* @brief Get object current position
* @param [in] mode 1-track grab, 2-track movement, 3-TPD tracking
* @return Error code
*/
int ConveyorGetTrackData(int mode);

11.26. Start conveyor tracking

/**
* @brief Start conveyor tracking
* @param [in] status Status, 1-start, 0-stop
* @return Error code
*/
int ConveyorTrackStart(byte status);

11.27. Conveyor tracking stop

/**
* @brief Conveyor tracking stop
* @return Error code
*/
int ConveyorTrackEnd();

11.28. Drive Belt Parameter Configuration

/**
* @brief Drive belt parameter configuration
* @param [in] para[0] Encoder channel 1~2
* @param [in] para[1] Number of pulses per encoder revolution
* @param [in] para[2] Conveyor belt travel distance per encoder revolution
* @param [in] para[3] Workpiece coordinate system number Select the workpiece coordinate system number for tracking motion functionality; set to 0 for tracking grasping and TPD tracking
* @param [in] para[4] Whether to configure vision 0: No configuration 1: Configuration
* @param [in] para[5] Speed ratio for conveyor belt tracking and grasping options (1-100). Other options default to 1.
* @param [in] followType Tracking motion type: 0-Tracking motion; 1 - Inspection movement
* @param [in] startDis Inspection tracking requires setting, tracking start distance, -1: automatically calculated (inspection starts automatically when the workpiece reaches below the robot), unit mm, default value 0
* @param [in] endDis Inspection tracking requires setting, tracking end distance, unit mm, default value 100
* @return Error code
*/
int ConveyorSetParam(int encChannel, int resolution, double lead, int wpAxis, int vision, double speedRadio, int followType, int startDis=0, int endDis=100);

11.29. Set conveyor belt pickup point compensation

/**
* @brief Set conveyor belt catch point compensation
* @param [in] cmp Compensation position double[3]{x, y, z}
* @return Error code
*/
int ConveyorCatchPointComp(double[] cmp);

11.30. Conveyor belt tracking linear motion

/**
* @brief Conveyor belt tracking linear motion
* @param [in] name Motion point name
* @param [in] tool Tool coordinate number, range [0~14]
* @param [in] wobj Workpiece coordinate number, range [0~14]
* @param [in] vel Velocity percentage, range [0~100]
* @param [in] acc Acceleration percentage, range [0~100], currently unavailable
* @param [in] ovl Velocity scaling factor, range [0~100]
* @param [in] blendR [-1.0] - move to position (blocked), [0~1000.0] - smooth radius (unblocked), unit mm
* @return Error code
*/
int ConveyorTrackMoveL(string name, int tool, int wobj, float vel, float acc, float ovl, float blendR);

11.31. Conveyor communication input detection

/**
* @brief Conveyor communication input detection
* @param [in] timeout Wait timeout in ms
* @return Error code
*/
int ConveyorComDetect(int timeout);

11.32. Conveyor Communication Input Detection Trigger

/**
* @brief Conveyor Communication Input Detection Trigger
* @return Error code
*/
int ConveyorComDetectTrigger();

11.33. Conveyor Communication Input Detection Trigger Example Program

private void button3_Click(object sender, EventArgs e)
{

    // Disable the button to prevent repeated clicks
    button3.Enabled = false;

    // Execute time-consuming operations in a background thread
    Thread conveyorThread = new Thread(ConveyorTest);
    conveyorThread.IsBackground = true;
    conveyorThread.Start();
}

private void button4_Click(object sender, EventArgs e)
{
    // Get user input
    string input = texBox.Text;
    Console.WriteLine($"please input a number to trigger:{input}");

    int rtn = robot.ConveyorComDetectTrigger();
    Console.WriteLine($"ConveyorComDetectTrigger return value: {rtn}");

}

private void ConveyorTest()
{
    // Use Invoke to update controls on the UI thread
    this.Invoke((MethodInvoker)delegate {
        Console.WriteLine( "Starting conveyor test...");
    });

    int retval = 0;
    int index = 1;
    int max_time = 30000;
    bool block = false;
    retval = 0;

    /* Conveyor belt grabbing process */
    DescPose startdescPose = new DescPose(139.176f, 4.717f, 9.088f, -179.999f, -0.004f, -179.990f);
    JointPos startjointPos = new JointPos(-34.129f, -88.062f, 97.839f, -99.780f, -90.003f, -34.140f);

    DescPose homePose = new DescPose(139.177f, 4.717f, 69.084f, -180.000f, -0.004f, -179.989f);
    JointPos homejointPos = new JointPos(-34.129f, -88.618f, 84.039f, -85.423f, -90.003f, -34.140f);

    ExaxisPos exaxisPos = new ExaxisPos(0, 0, 0, 0);
    DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);

    // Move to a safe position
    retval = robot.MoveL(homejointPos, homePose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);
    Console.WriteLine($"MoveL to safe position return value: {retval}");

    // Conveyor detection
    retval = robot.ConveyComDetect(1000 * 10);
    Console.WriteLine($"ConveyorComDetect return value: {retval}");

    // Get tracking data
    retval = robot.ConveyorGetTrackData(2);
    Console.WriteLine($"ConveyorGetTrackData return value: {retval}");

    // Start tracking
    retval = robot.ConveyorTrackStart(2);
    Console.WriteLine($"ConveyorTrackStart return value: {retval}");

    // Move to the starting position
    robot.MoveL(startjointPos, startdescPose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);
    robot.MoveL(startjointPos, startdescPose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);

    // End tracking
    retval = robot.ConveyorTrackEnd();
    Console.WriteLine($"ConveyorTrackEnd return value: {retval}");

    // Return to safe position
    robot.MoveL(homejointPos, homePose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);

    this.Invoke((MethodInvoker)delegate {
        Console.WriteLine( "Conveyor belt test completed!");
        button3.Enabled = true;
    });
}

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