11. Robot Peripherals
11.1. Configure Gripper
1/**
2* @brief Configure gripper
3* @param [in] company Gripper manufacturer, to be determined
4* @param [in] device Device number, not currently used, default is 0
5* @param [in] softvesion Software version number, not currently used, default is 0
6* @param [in] bus Device bus position, currently unused, default is 0
7* @return Error code
8*/
9int SetGripperConfig(int company, int device, int softvesion, int bus);
11.2. Get gripper configuration
1/**
2* @brief Get gripper configuration
3* @param [in] company Gripper manufacturer, to be determined
4* @param [in] device Device number, currently unused, default is 0
5* @param [in] softvesion Software version number, currently unused, default is 0
6* @param [in] bus Device bus position, currently unused, default is 0
7* @return Error code
8*/
9int GetGripperConfig(int *company, int *device, int *softvesion, int *bus);
11.3. Activate Gripper
1/**
2* @brief Activate gripper
3* @param [in] index Gripper number
4* @param [in] act 0-reset, 1-activate
5* @return Error code
6*/
7int ActGripper(int index, byte act);
11.4. Control gripper
1/**
2* @brief Control gripper
3* @param [in] index Gripper ID
4* @param [in] pos Position percentage, range [0~100]
5* @param [in] vel Speed percentage, range [0~100]
6* @param [in] force Torque percentage, range [0~100]
7* @param [in] max_time Maximum wait time, range [0~30000], unit ms
8* @param [in] block 0-blocking, 1-non-blocking
9* @param [in] type Gripper type, 0-parallel gripper; 1-rotating gripper
10* @param [in] rotNum Number of rotation cycles
11* @param [in] rotVel Rotation speed percentage [0-100]
12* @param [in] rotTorque Rotation torque percentage [0-100]
13* @return Error code
14*/
15int 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
1/**
2* @brief Get gripper motion status(only defined for the end-effector open protocol; for adapted devices, the obtained motion status is a pass-through value)
3* @param [out] fault 0-no error, other-error
4* @param [out] staus 0-motion not completed, 1-motion completed with no object detected, 2-motion completed with object detected
5* @return Error code
6*/
7int GetGripperMotionDone(ref int fault, ref int status);
11.6. Get gripper activation status
1/**
2* @brief Get gripper activation status
3* @param [out] fault 0-no error, 1-error
4* @param [out] status bit0~bit15 corresponds to gripper numbers 0~15, bit=0 is not activated, bit=1 is activated
5* @return Error code
6*/
7int GetGripperActivateStatus(ref int fault, ref int status);
11.7. Wait for Gripper Motion Status
1/**
2* @brief Wait for gripper motion status (only defined for the end-effector open protocol; for adapted devices, the status definition is passed through to each gripper manufacturer)
3* @param [in] status 0-motion not completed, 1-motion completed with no object detected, 2-motion completed with object detected
4* @param [in] timeout Timeout (ms), -1 for infinite wait
5* @param [in] strategy 0-stop with error, 1-continue running
6* @param [in] type 0-parallel gripper, 1-rotary gripper
7* @return Error code
8*/
9public int GripperWaitMotionDone(int status, int timeout, int strategy, int type)
11.8. Wait for Gripper Motion Status Code Example
1public void TestGripperWaitMotionDone()
2{
3 int rtn;
4 ROBOT_STATE_PKG pkg = new ROBOT_STATE_PKG();
5
6
7 // Gripper open
8 rtn = robot.MoveGripper(1, 50, 50, 100, 30000, 0, 0, 0, 0, 0);
9 Console.WriteLine("MoveGripper(open) ret={0}", rtn);
10 Thread.Sleep(2000);
11 robot.GetRobotRealTimeState(ref pkg);
12 Console.WriteLine(" gripper_motiondone {0})", pkg.gripper_motiondone);
13 // Gripper close
14 rtn = robot.MoveGripper(1, 90, 100, 100, 30000, 0, 0, 0, 0, 0);
15 Console.WriteLine("MoveGripper(close) ret={0}", rtn);
16 Thread.Sleep(2000);
17 robot.GetRobotRealTimeState(ref pkg);
18 Console.WriteLine(" gripper_motiondone {0}", pkg.gripper_motiondone);
19 // Wait for motion completed with no object detected, timeout 30s, stop with error
20 rtn = robot.GripperWaitMotionDone(2, -1, 0, 0);
21 Console.WriteLine("GripperWaitMotionDone(wait completed with no object detected) ret={0}", rtn);
22
23 // Gripper open
24 rtn = robot.MoveGripper(1, 0, 100, 100, 30000, 0, 0, 0, 0, 0);
25 Console.WriteLine("MoveGripper(open) ret={0}", rtn);
26}
11.9. Get Gripper Position
1/**
2* @brief Get gripper position
3* @param [out] fault 0-no error, 1-error
4* @param [out] position Position percentage, range 0~100%
5* @return Error code
6*/
7int GetGripperCurPosition(ref int fault, ref int position);
11.10. Get gripper speed
1/**
2* @brief Get gripper speed
3* @param [out] fault 0-no error, 1-error
4* @param [out] speed Speed percentage, range 0~100%
5* @return Error code
6*/
7int GetGripperCurSpeed(ref int fault, ref int speed);
11.11. Get gripper current
1/**
2* @brief Get gripper current
3* @param [out] fault 0-no error, 1-error
4* @param [out] current Current percentage, range 0~100%
5* @return Error code
6*/
7int GetGripperCurrent(ref int fault, ref int current);
11.12. Get gripper voltage
1/**
2* @brief Get gripper voltage
3* @param [out] fault 0-no error, 1-error
4* @param [out] voltage Voltage, unit 0.1V
5* @return Error code
6*/
7int GetGripperVoltage(ref int fault, ref int voltage);
11.13. Get gripper temperature
1/**
2* @brief Get gripper temperature
3* @param [out] fault 0-no error, 1-error
4* @param [out] temp Temperature, unit °C
5* @return Error code
6*/
7int GetGripperTemp(ref int fault, ref int temp);
11.14. Calculate pre-gripping point - vision
1/**
2* @brief Calculate pre-gripping point - vision
3* @param [in] desc_pos Gripping point Cartesian pose
4* @param [in] zlength Z-axis offset
5* @param [in] zangle Rotation offset around the z-axis
6* @param [out] pre_pos Pre-pick point
7* @return Error code
8*/
9int ComputePrePick(DescPose desc_pos, double zlength, double zangle, ref DescPose pre_pos);
11.15. Calculate retreat point - vision
1/**
2* @brief Calculate retreat point - visual
3* @param [in] desc_pos Retreat point Cartesian pose
4* @param [in] zlength Z-axis offset
5* @param [in] zangle Rotation offset around the Z-axis
6* @param [out] post_pos Retreat point
7* @return Error code
8*/
9int ComputePostPick(DescPose desc_pos, double zlength, double zangle, ref DescPose post_pos);
11.16. Robot Gripper Operation Code Example
1private void button36_Click(object sender, EventArgs e)
2{
3 int company = 4;
4 int device = 0;
5 int softversion = 0;
6 int bus = 2;
7 int index = 2;
8 byte act = 0;
9 int max_time = 30000;
10 byte block = 0;
11 int status=0;
12 int fault=0;
13 int active_status = 0;
14 int current_pos = 0;
15 int current = 0;
16 int voltage = 0;
17 int temp = 0;
18 int speed = 0;
19
20 robot.SetGripperConfig(company, device, softversion, bus);
21 Thread.Sleep(1000);
22 robot.GetGripperConfig(ref company, ref device, ref softversion, ref bus);
23 Console.WriteLine("gripper config:{0},{1},{2},{3}\n", company, device, softversion, bus);
24
25 robot.ActGripper(index, act);
26 Thread.Sleep(1000);
27 act = 1;
28 robot.ActGripper(index, act);
29 Thread.Sleep(1000);
30
31 robot.MoveGripper(index, 90, 50, 50, max_time, block, 0, 0, 0, 0);
32 Thread.Sleep(1000);
33 robot.MoveGripper(index, 30, 50, 0, max_time, block, 0, 0, 0, 0);
34
35 robot.GetGripperMotionDone(ref fault, ref status);
36 Console.WriteLine("motion status:{0},{1}\n", fault, status);
37
38 robot.GetGripperActivateStatus(ref fault, ref active_status);
39 Console.WriteLine("gripper active fault is: {0}, status is: {1}\n", fault, active_status);
40
41 robot.GetGripperCurPosition(ref fault, ref current_pos);
42 Console.WriteLine("fault is:{0}, current position is: {1}\n", fault, current_pos);
43
44 robot.GetGripperCurCurrent(ref fault, ref current);
45 Console.WriteLine("fault is:{0}, current current is: {1}\n", fault, current);
46
47 robot.GetGripperVoltage(ref fault, ref voltage);
48 Console.WriteLine("fault is:{0}, current voltage is: {1} \n", fault, voltage);
49
50 robot.GetGripperTemp(ref fault, ref temp);
51 Console.WriteLine("fault is:{0}, current temperature is: {1}\n", fault, temp);
52
53 robot.GetGripperCurSpeed(ref fault, ref speed);
54 Console.WriteLine("fault is:{0}, current speed is: {1}\n", fault, speed);
55
56 int retval = 0;
57 DescPose prepick_pose = new DescPose();
58 DescPose postpick_pose = new DescPose();
59
60 DescPose p1Desc = new DescPose(-419.524f, -13.000f, 351.569f, -178.118f, 0.314f, 3.833f);
61 DescPose p2Desc = new DescPose(-321.222f, 185.189f, 335.520f, -179.030f, -1.284f, -29.869f);
62
63 retval = robot.ComputePrePick(p1Desc, 10, 0, ref prepick_pose);
64 Console.WriteLine("ComputePrePick retval is: {0}\n", retval);
65 Console.WriteLine("xyz is: {0}, {1}, {2}; rpy is: {3}, {4}, {5}\n",
66 prepick_pose.tran.x, prepick_pose.tran.y, prepick_pose.tran.z,
67 prepick_pose.rpy.rx, prepick_pose.rpy.ry, prepick_pose.rpy.rz);
68
69 retval = robot.ComputePostPick( p2Desc, -10, 0, ref postpick_pose);
70 Console.WriteLine("ComputePostPick retval is: {0}\n", retval);
71 Console.WriteLine("xyz is: {0}, {1}, {2}; rpy is: {3}, {4}, {5}\n",
72 postpick_pose.tran.x, postpick_pose.tran.y, postpick_pose.tran.z,
73 postpick_pose.rpy.rx, postpick_pose.rpy.ry, postpick_pose.rpy.rz);
74
75}
11.17. Get the number of rotations of the rotating gripper
1/**
2* @brief Get the number of rotations of the rotating gripper
3* @param [out] fault 0-no error, 1-error
4* @param [out] num Number of rotations
5* @return Error code
6*/
7int GetGripperRotNum(ref UInt16 fault, ref double num);
11.18. Get the rotation speed percentage of the rotating gripper
1/**
2* @brief Get the rotation speed percentage of the rotating gripper
3* @param [out] fault 0-no error, 1-error
4* @param [out] speed Rotation speed percentage
5* @return Error code
6*/
7int GetGripperRotSpeed(ref UInt16 fault, ref int speed);
11.19. Get the rotation torque percentage of the rotating gripper
1/**
2* @brief Get the rotational torque percentage of the rotating gripper
3* @param [out] fault 0-no error, 1-error
4* @param [out] torque Rotational torque percentage
5* @return Error code
6*/
7int GetGripperRotTorque(ref UInt16 fault, ref int torque);
11.20. Example of retrieving the rotational gripper status code
1int MoveRotGripper(int pos, double rotPos)
2{
3 robot.ResetAllError();
4 robot.ActGripper(1, 1);
5 Thread.Sleep(1000);
6 int rtn = robot.MoveGripper(1, pos, 50, 50, 5000, 1, 1, rotPos, 50, 100);
7 Console.WriteLine($"move gripper rtn is {rtn}" );
8 UInt16 fault = 0;
9 double rotNum = 0.0;
10 int rotSpeed = 0;
11 int rotTorque = 0;
12 robot.GetGripperRotNum(ref fault, ref rotNum);
13 robot.GetGripperRotSpeed(ref fault, ref rotSpeed);
14 robot.GetGripperRotTorque(ref fault, ref rotTorque);
15 Console.WriteLine($"gripper rot num :{ rotNum}, gripper rotSpeed :{rotSpeed}, gripper rotTorque : { rotTorque}");
16 return 0;
17}
11.21. Drive belt start/stop
1/**
2* @brief Conveyor belt start/stop
3* @param [in] status Status, 1-start, 0-stop
4* @return Error code
5*/
6int ConveyorStartEnd(byte status);
11.22. Record IO detection points
1/**
2* @brief Record IO detection point
3* @return Error code
4*/
5int ConveyorPointIORecord();
11.23. Record point A
1/**
2* @brief Record Point A
3* @return Error code
4*/
5int ConveyorPointARecord();
11.24. Record reference point
1/**
2* @brief Record reference point
3* @return Error code
4*/
5int ConveyorRefPointRecord();
11.25. Record Point B
1/**
2* @brief Record Point B
3* @return Error code
4*/
5int ConveyorPointBRecord();
11.26. Conveyor belt workpiece IO detection
1/**
2* @brief Conveyor workpiece IO detection
3* @param [in] max_t Maximum detection time, unit ms
4* @return Error code
5*/
6int ConveyorIODetect(int max_t);
11.27. Get Object Current Position
1/**
2* @brief Get object current position
3* @param [in] mode 1-track grab, 2-track movement, 3-TPD tracking
4* @return Error code
5*/
6int ConveyorGetTrackData(int mode);
11.28. Start conveyor tracking
1/**
2* @brief Start conveyor tracking
3* @param [in] status Status, 1-start, 0-stop
4* @return Error code
5*/
6int ConveyorTrackStart(byte status);
11.29. Conveyor tracking stop
1/**
2* @brief Conveyor tracking stop
3* @return Error code
4*/
5int ConveyorTrackEnd();
11.30. Conveyor Belt In-Place Tracking Parameter Configuration
1/**
2* @brief Configure conveyor belt in-place tracking parameters
3* @param [in] trackMode 0-time; 1-distance; 2-time and distance, either condition satisfied
4* @param [in] trackTime Tracking time, unit s
5* @param [in] trackDis Tracking distance
6* @return Error code
7*/
8public int SetStationaryTrackPara(int trackMode, double trackTime, int trackDis)
11.31. Wait for In-Place Idle Motion to Complete
1/**
2* @brief Wait for in-place idle motion to complete
3* @return Error code
4*/
5public int WaitStationaryMotionDone()
11.32. Conveyor Belt In-Place Tracking Motion Code Example
1public int TestStationaryTrack()
2{
3 Console.WriteLine("\n========== Stationary Track Test ==========");
4
5 int rtn;
6
7 JointPos j1 = new JointPos(-35.146, -102.684, 120.805, -100.401, -90.295, 150.105);
8 DescPose d1 = new DescPose(-121.814, -348.341, 209.978, -173.152, -3.585, -5.446);
9
10 ExaxisPos ex = new ExaxisPos(0, 0, 0, 0);
11 DescPose zeroOff = new DescPose(0, 0, 0, 0, 0, 0);
12
13 int tool = 1;
14 int workpiece = 1;
15
16 rtn = robot.ConveyorSetParam(0, 10000, 200, 0, 0, 10);
17
18 robot.MoveJ(j1, d1, tool, workpiece, 100, 100, 100, ex, -1, 0, zeroOff);
19
20 // Step 1: SetDO control signal ON
21 Console.WriteLine("--- Step 1: SetDO(6,1) ---");
22 rtn = robot.SetDO(6, 1, 0, 0);
23 Console.WriteLine(" SetDO(6,1) rtn={0}", rtn);
24
25 // Step 2: Conveyor tracking start
26 Console.WriteLine("--- Step 2: ConveyorTrackStart(2) ---");
27 rtn = robot.ConveyorTrackStart(2);
28 Console.WriteLine(" ConveyorTrackStart(2) rtn={0}", rtn);
29
30 // Step 3: Workpiece IO detect
31 Console.WriteLine("--- Step 3: ConveyorIODetect(10000) ---");
32 rtn = robot.ConveyorIODetect(10000);
33 Console.WriteLine(" ConveyorIODetect(10000) rtn={0}", rtn);
34
35 // Step 4: Get track data
36 Console.WriteLine("--- Step 4: ConveyorGetTrackData(2) ---");
37 rtn = robot.ConveyorGetTrackData(2);
38 Console.WriteLine(" ConveyorGetTrackData(2) rtn={0}", rtn);
39
40 // Step 5: Set stationary track parameters (time mode, 200s, distance 5)
41 Console.WriteLine("--- Step 5: SetStationaryTrackPara(0,200,5) ---");
42 rtn = robot.SetStationaryTrackPara(0, 5, 5);
43 Console.WriteLine(" SetStationaryTrackPara(0,200,5) rtn={0}", rtn);
44
45 // Step 6: Execute stationary motion
46 Console.WriteLine("--- Step 6: MoveStationary() ---");
47 rtn = robot.MoveStationary();
48 Console.WriteLine(" MoveStationary() rtn={0}", rtn);
49
50 // Step 7: Wait for stationary motion done
51 Console.WriteLine("--- Step 7: WaitStationaryMotionDone() ---");
52 rtn = robot.WaitStationaryMotionDone();
53 Console.WriteLine(" WaitStationaryMotionDone() rtn={0}", rtn);
54
55 // Step 8: Conveyor tracking end
56 Console.WriteLine("--- Step 8: ConveyorTrackEnd() ---");
57 rtn = robot.ConveyorTrackEnd();
58 Console.WriteLine(" ConveyorTrackEnd() rtn={0}", rtn);
59
60 // Step 9: SetDO control signal OFF
61 Console.WriteLine("--- Step 9: SetDO(6,0) ---");
62 rtn = robot.SetDO(6, 0, 0, 0);
63 Console.WriteLine(" SetDO(6,0) rtn={0}", rtn);
64
65 Console.WriteLine("\n========== Stationary Track Test Complete ==========");
66 return 0;
67}
11.33. Drive Belt Parameter Configuration
1/**
2* @brief Drive belt parameter configuration
3* @param [in] para[0] Encoder channel 1~2
4* @param [in] para[1] Number of pulses per encoder revolution
5* @param [in] para[2] Conveyor belt travel distance per encoder revolution
6* @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
7* @param [in] para[4] Whether to configure vision 0: No configuration 1: Configuration
8* @param [in] para[5] Speed ratio for conveyor belt tracking and grasping options (1-100). Other options default to 1.
9* @return Error code
10*/
11int ConveyorSetParam(int encChannel, int resolution, double lead, int wpAxis, int vision, double speedRadio, int followType, int startDis=0, int endDis=100);
11.34. Set conveyor belt pickup point compensation
1/**
2* @brief Set conveyor belt catch point compensation
3* @param [in] cmp Compensation position double[3]{x, y, z}
4* @return Error code
5*/
6int ConveyorCatchPointComp(double[] cmp);
11.35. Conveyor belt tracking linear motion
1/**
2* @brief Conveyor belt tracking linear motion
3* @param [in] name Motion point name
4* @param [in] tool Tool coordinate number, range [0~14]
5* @param [in] wobj Workpiece coordinate number, range [0~14]
6* @param [in] vel Velocity percentage, range [0~100]
7* @param [in] acc Acceleration percentage, range [0~100], currently unavailable
8* @param [in] ovl Velocity scaling factor, range [0~100]
9* @param [in] blendR [-1.0] - move to position (blocked), [0~1000.0] - smooth radius (unblocked), unit mm
10* @return Error code
11*/
12int ConveyorTrackMoveL(string name, int tool, int wobj, float vel, float acc, float ovl, float blendR);
11.36. Conveyor communication input detection
1/**
2* @brief Conveyor communication input detection
3* @param [in] timeout Wait timeout in ms
4* @return Error code
5*/
6public int ConveyorComDetect(int timeout)
11.37. Conveyor Communication Input Detection Trigger
1/**
2* @brief Conveyor Communication Input Detection Trigger
3* @return Error code
4*/
5int ConveyorComDetectTrigger();
11.38. Conveyor Communication Input Detection Trigger Example Program
1private void button3_Click(object sender, EventArgs e)
2{
3
4 // Disable the button to prevent repeated clicks
5 button3.Enabled = false;
6
7 // Execute time-consuming operations in a background thread
8 Thread conveyorThread = new Thread(ConveyorTest);
9 conveyorThread.IsBackground = true;
10 conveyorThread.Start();
11}
12
13private void button4_Click(object sender, EventArgs e)
14{
15 // Get user input
16 string input = texBox.Text;
17 Console.WriteLine($"please input a number to trigger:{input}");
18
19 int rtn = robot.ConveyorComDetectTrigger();
20 Console.WriteLine($"ConveyorComDetectTrigger return value: {rtn}");
21
22}
23
24private void ConveyorTest()
25{
26 // Use Invoke to update controls on the UI thread
27 this.Invoke((MethodInvoker)delegate {
28 Console.WriteLine( "Starting conveyor test...");
29 });
30
31 int retval = 0;
32 int index = 1;
33 int max_time = 30000;
34 bool block = false;
35 retval = 0;
36
37 /* Conveyor belt grabbing process */
38 DescPose startdescPose = new DescPose(139.176f, 4.717f, 9.088f, -179.999f, -0.004f, -179.990f);
39 JointPos startjointPos = new JointPos(-34.129f, -88.062f, 97.839f, -99.780f, -90.003f, -34.140f);
40
41 DescPose homePose = new DescPose(139.177f, 4.717f, 69.084f, -180.000f, -0.004f, -179.989f);
42 JointPos homejointPos = new JointPos(-34.129f, -88.618f, 84.039f, -85.423f, -90.003f, -34.140f);
43
44 ExaxisPos exaxisPos = new ExaxisPos(0, 0, 0, 0);
45 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
46
47 // Move to a safe position
48 retval = robot.MoveL(homejointPos, homePose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);
49 Console.WriteLine($"MoveL to safe position return value: {retval}");
50
51 // Conveyor detection
52 retval = robot.ConveyComDetect(1000 * 10);
53 Console.WriteLine($"ConveyorComDetect return value: {retval}");
54
55 // Get tracking data
56 retval = robot.ConveyorGetTrackData(2);
57 Console.WriteLine($"ConveyorGetTrackData return value: {retval}");
58
59 // Start tracking
60 retval = robot.ConveyorTrackStart(2);
61 Console.WriteLine($"ConveyorTrackStart return value: {retval}");
62
63 // Move to the starting position
64 robot.MoveL(startjointPos, startdescPose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);
65 robot.MoveL(startjointPos, startdescPose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);
66
67 // End tracking
68 retval = robot.ConveyorTrackEnd();
69 Console.WriteLine($"ConveyorTrackEnd return value: {retval}");
70
71 // Return to safe position
72 robot.MoveL(homejointPos, homePose, 1, 1, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 1, 1);
73
74 this.Invoke((MethodInvoker)delegate {
75 Console.WriteLine( "Conveyor belt test completed!");
76 button3.Enabled = true;
77 });
78}
11.39. Robot Conveyor Belt Operation Example Program
1private void btnConvert_Click(object sender, EventArgs e)
2{
3 // Conveyor belt tracking
4 DescPose pos1 = new DescPose(-354.549, 63.914, 270.176, -179.679, -0.134, 2.468);
5 DescPose pos2 = new DescPose(-351.203, -213.393, 351.054, -179.932, -0.508, 2.472);
6
7 double[] cmp = { 0.0, 0.0, 0.0 };
8 int rtn = robot.ConveyorCatchPointComp(cmp); // Set conveyor pick-up point compensation
9 if (rtn != 0)
10 {
11 return;
12 }
13 Console.WriteLine("ConveyorCatchPointComp: rtn " + rtn);
14
15 rtn = robot.MoveCart(pos1, 1, 0, (float)30.0, (float)180.0, (float)100.0, (float)-1.0, -1);
16 Console.WriteLine("MoveCart: rtn " + rtn);
17
18 rtn = robot.ConveyorIODetect(10000); // Conveyor workpiece I/O detection
19 Console.WriteLine("ConveyorIODetect: rtn " + rtn);
20
21 robot.ConveyorGetTrackData(1); // Configure conveyor tracking for picking
22 rtn = robot.ConveyorTrackStart(1); // Start tracking
23 Console.WriteLine("ConveyorTrackStart: rtn " + rtn);
24
25 rtn = robot.ConveyorTrackMoveL("cvrCatchPoint", 1, 0, (float)100.0, (float)0.0, (float)100.0, (float)-1.0, 0, 0);
26 Console.WriteLine("ConveyorTrackMoveL: rtn " + rtn);
27
28 rtn = robot.MoveGripper(2, 30, 60, 30, 30000, 0, 0, 0, 50, 50);
29 Console.WriteLine("ConveyorTrackMoveL: rtn " + rtn);
30
31
32 rtn = robot.ConveyorTrackMoveL("cvrRaisePoint", 1, 0, (float)100.0, (float)0.0, (float)100.0, (float)-1.0, 0, 0);
33 Console.WriteLine("ConveyorTrackMoveL: rtn " + rtn);
34
35 rtn = robot.ConveyorTrackEnd(); // Stop conveyor tracking
36 Console.WriteLine("ConveyorTrackEnd: rtn " + rtn);
37
38 rtn = robot.MoveCart(pos2, 1, 0, (float)30.0, (float)180.0, (float)100.0, (float)-1.0, -1);
39 Console.WriteLine("MoveCart: rtn " + rtn);
40
41 rtn = robot.MoveGripper(2, 100, 60, 30, 30000, 0,0,0,50,50);
42 Console.WriteLine("MoveGripper: rtn " + rtn);
43
44}
11.40. End Sensor Configuration
1/**
2* @brief End Sensor Configuration
3* @param [in] idCompany Manufacturer, 18-JUNKONG; 25-HUIDE
4* @param [in] idDevice Type, 0-JUNKONG/RYR6T.V1.0
5* @param [in] idSoftware Software version, 0-J1.0/HuiDe1.0 (not yet available)
6* @param [in] idBus Mounting location, 1-End 1 port; 2-End 2 port... 8-Endpoint 8 port (not yet available)
7* @return Error code
8*/
9int AxleSensorConfig(int idCompany, int idDevice, int idSoftware, int idBus);
11.41. Get endpoint sensor configuration
1/**
2* @brief Get terminal sensor configuration
3* @param [out] idCompany Manufacturer, 18-JUNKONG; 25-HUIDE
4* @param [out] idDevice Type, 0-JUNKONG/RYR6T.V1.0
5* @return Error code
6*/
7int AxleSensorConfigGet(ref int idCompany, ref int idDevice);
11.42. End-of-line sensor activation
1/**
2* @brief End-of-line sensor activation
3* @param [in] actFlag 0-reset; 1-activate
4* @return Error code
5*/
6int AxleSensorActivate(int actFlag);
11.43. End Sensor Register Write
1/**
2* @brief End Sensor Register Write
3* @param [in] devAddr Device Address Number 0-255
4* @param [in] regHAddr High 8 bits of the register address
5* @param [in] regLAddr Low 8 bits of the register address
6* @param [in] regNum Number of registers 0-255
7* @param [in] data1 Value to write to the register 1
8* @param [in] data2 Value to write to the register 2
9* @param [in] isNoBlock 0-blocking; 1-non-blocking
10* @return Error code
11*/
12 int AxleSensorRegWrite(int devAddr, int regHAddr, int regLAddr, int regNum, int data1, int data2, int isNoBlock);
11.44. End Sensor Code Example
1private void button2_Click_1(object sender, EventArgs e)
2{
3 robot.AxleSensorConfig(18, 0, 0, 1);
4 int company = -1;
5 int type = -1;
6 robot.AxleSensorConfigGet(ref company, ref type);
7 Console.WriteLine( "company is " + company + ", type is " + type);
8
9 int rtn = robot.AxleSensorActivate(1);
10 Console.WriteLine( "AxleSensorActivate rtn is " + rtn);
11
12 Thread.Sleep(1000);
13
14 rtn = robot.AxleSensorRegWrite(1, 4, 6, 1, 0, 0, 0);
15 Console.WriteLine( "AxleSensorRegWrite rtn is " + rtn);
16}
11.45. Obtain robot peripheral protocol
Added in version C#SDK-v1.0.6.
1/**
2* @brief Get robot peripheral protocol
3* @param [out] protocol Robot peripheral protocol number 4096-Extended Axle Control Card; 4097-ModbusSlave; 4098-ModbusMaster
4* @return Error code
5*/
6int GetExDevProtocol(ref int protocol);
11.46. Set robot peripheral protocol
Added in version C#SDK-v1.0.6.
1/**
2* @brief Set robot peripheral protocol
3* @param [in] protocol Robot peripheral protocol number 4096-Extended Axis Control Card; 4097-Modbus Slave; 4098-Modbus Master
4* @return Error code
5*/
6int SetExDevProtocol(int protocol);
11.47. Example program for setting robot peripheral protocol
1private void btnSetProto_Click(object sender, EventArgs e)
2{
3 int protocol = 4096;
4 int rtn = robot.SetExDevProtocol(protocol);
5
6 Console.WriteLine( "SetExDevProtocol rtn " + rtn);
7 rtn = robot.GetExDevProtocol(ref protocol);
8 Console.WriteLine( "GetExDevProtocol rtn " + rtn + " protocol is: " + protocol);
9}
11.48. Get end-point communication parameters
1/**
2* @brief Get terminal communication parameters
3* @param param Terminal communication parameters
4* @return Error code
5*/
6int GetAxleCommunicationParam(ref AxleComParam getParam);
11.49. Set terminal communication parameters
1/**
2* @brief Set terminal communication parameters
3* @param param Terminal communication parameters
4* @return Error code
5*/
6int SetAxleCommunicationParam(AxleComParam param);
11.50. Set terminal file transfer type
1/**
2* @brief Set the terminal file transfer type
3* @param type 1-MCU upgrade file; 2-LUA file
4* @return Error code
5*/
6int SetAxleFileType(int type);
11.51. Set enable terminal LUA execution
1/**
2* @brief Enable LUA execution at the end
3* @param enable 0-Disabled; 1-Enabled
4* @return Error code
5*/
6int SetAxleLuaEnable(int enable);
11.52. End LUA file exception error recovery
1/**
2* @brief End-of-file LUA file exception error recovery
3* @param status 0-do not recover; 1-recover
4* @return Error code
5*/
6int SetRecoverAxleLuaErr(int status);
11.53. Get the enable status of the terminal LUA execution
1/**
2* @brief Get the enable status of the terminal LUA execution
3* @param [out] status 0-disabled; 1-enabled
4* @return Error code
5*/
6int GetAxleLuaEnableStatus(ref int status);
11.54. Set the enabled device types for the end-effector LUA
1/**
2* @brief Set the enabled device types for the end-effector LUA
3* @param [in] forceSensorEnable Force sensor enable status, 0-disabled; 1-enabled
4* @param [in] gripperEnable Gripper enable status, 0-disabled; 1-enabled
5* @param [in] IOEnable IO device enable status, 0-disabled; 1-enabled
6* @param [in] dexhandEnable Dexterous hand enable status, 0-disabled; 1-enabled
7* @return Error code
8*/
9public int SetAxleLuaEnableDeviceType(int forceSensorEnable, int gripperEnable, int IOEnable, int dexhandEnable)
11.55. Get the enabled device types for the end-effector LUA
1/**
2* @brief Get the enabled device types for the end-effector LUA
3* @param [out] forceSensorEnable Force sensor enable status, 0-disabled; 1-enabled
4* @param [out] gripperEnable Gripper enable status, 0-disabled; 1-enabled
5* @param [out] IOEnable IO device enable status, 0-disabled; 1-enabled
6* @param [out] dexhandEnable Dexterous hand enable status, 0-disabled; 1-enabled
7* @return Error code
8*/
9public int GetAxleLuaEnableDeviceType(ref int forceSensorEnable, ref int gripperEnable, ref int IOEnable, ref int dexhandEnable)
11.56. Get the currently configured end-effector devices
1/**
2* @brief Get the currently configured end-effector devices
3* @param [out] forceSensorEnable Force sensor enabled device number, 0-disabled; 1-enabled
4* @param [out] gripperEnable Gripper enabled device number, 0-disabled; 1-enabled
5* @param [out] IODeviceEnable IO device enabled device number, 0-disabled; 1-enabled
6* @param [out] decHandEnable Dexterous hand enabled device number, 0-disabled; 1-enabled
7* @return Error code
8*/
9public int GetAxleLuaEnableDevice(ref int[] forceSensorEnable, ref int[] gripperEnable, ref int[] IODeviceEnable, ref int[] decHandEnable)
11.57. Set the enabled gripper action control functions
1/**
2* @brief Set the enabled gripper action control functions
3* @param [in] id Gripper device number
4* @param [in] func func[0]-gripper enable; func[1]-gripper initialization; func[2]-position setting; func[3]-speed setting; func[4]-torque setting; func[6]-read gripper status;
5 func[7]-read initialization status; func[8]-read fault code; func[9]-read position; func[10]-read speed; func[11]-read torque; func[12]-set rotation count for rotary gripper;
6 func[13]-set rotation speed for rotary gripper; func[14]-set rotation torque for rotary gripper; func[15]-read rotary gripper status; func[16]-read rotary gripper initialization status;
7 func[17]-read rotary gripper rotation count; func[18]-read rotary gripper speed; func[19]-read rotary gripper torque; func[20]-multi-axis synchronous motion setting; func[21]-fault clear command;
8 func[22]-single-axis running status; func[23]-all-axis running status;
9* @return Error code
10*/
11public int SetAxleLuaGripperFunc(int id, int[] func)
11.58. Get the enabled gripper action control functions
1/**
2* @brief Get the enabled gripper action control functions
3* @param [in] id Gripper device number
4* @param [out] func func[0]-gripper enable; func[1]-gripper initialization; func[2]-position setting; func[3]-speed setting; func[4]-torque setting; func[6]-read gripper status;
5 func[7]-read initialization status; func[8]-read fault code; func[9]-read position; func[10]-read speed; func[11]-read torque; func[12]-set rotation count for rotary gripper;
6 func[13]-set rotation speed for rotary gripper; func[14]-set rotation torque for rotary gripper; func[15]-read rotary gripper status; func[16]-read rotary gripper initialization status;
7 func[17]-read rotary gripper rotation count; func[18]-read rotary gripper speed; func[19]-read rotary gripper torque; func[20]-multi-axis synchronous motion setting; func[21]-fault clear command;
8 func[22]-single-axis running status; func[23]-all-axis running status;
9* @return Error code
10*/
11public int GetAxleLuaGripperFunc(int id, ref int[] func)
11.59. Writing robot Ethercat slave file
1/**
2* @brief Writing robot Ethercat slave file
3* @param [in] type Slave file type, 1-upgrade slave file; 2-upgrade slave configuration file
4* @param [in] slaveID Slave ID
5* @param [in] fileName Upload file name
6* @return Error code
7*/
8int SlaveFileWrite(int type, int slaveID, string fileName);
11.60. Upload terminal Lua open protocol file
1/**
2* @brief Upload end Lua open protocol file
3* @param filePath Local lua file path name ".../AXLE_LUA_End_DaHuan.lua"
4* @return Error code
5*/
6int AxleLuaUpload(string filePath);
11.61. Robot Ethercat slave enters boot mode
1/**
2* @brief Robot Ethercat slave enters boot mode
3* @return Error code
4*/
5int SetSysServoBootMode();
11.62. Robot End-of-Arm LUA File Operation Code Example
1private void button41_Click(object sender, EventArgs e)
2{
3 ROBOT_STATE_PKG pkg = new ROBOT_STATE_PKG();
4 robot.AxleLuaUpload("D://zUP/AXLE_LUA_End_JunDuo_V0.4_20260602.lua");
5
6 AxleComParam param = new AxleComParam(7, 8, 1, 0, 5, 3, 1);
7 robot.SetAxleCommunicationParam(param);
8
9 AxleComParam getParam = new AxleComParam();
10 robot.GetAxleCommunicationParam(ref getParam);
11 Console.WriteLine("GetAxleCommunicationParam param is {0} {1} {2} {3} {4} {5} {6}",
12 getParam.baudRate, getParam.dataBit, getParam.stopBit, getParam.verify,
13 getParam.timeout, getParam.timeoutTimes, getParam.period);
14
15 robot.SetAxleLuaEnable(1);
16 int luaEnableStatus = 0;
17 robot.GetAxleLuaEnableStatus(ref luaEnableStatus);
18 robot.SetAxleLuaEnableDeviceType(0, 1, 0, 0);
19
20 int forceEnable = 0;
21 int gripperEnable = 0;
22 int ioEnable = 0;
23 int dexhandEnable = 0;
24 robot.GetAxleLuaEnableDeviceType(ref forceEnable, ref gripperEnable, ref ioEnable, ref dexhandEnable);
25 Console.WriteLine("GetAxleLuaEnableDeviceType param is {0} {1} {2}", forceEnable, gripperEnable, ioEnable);
26
27 int[] func = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
28 robot.SetAxleLuaGripperFunc(1, func);
29
30 int[] getFunc = new int[32];
31 robot.GetAxleLuaGripperFunc(1, ref getFunc);
32 int[] getforceEnable = new int[16];
33 int[] getgripperEnable = new int[16];
34 int[] getioEnable = new int[16];
35 int[] dexhandEnable1 = new int[16];
36 robot.GetAxleLuaEnableDevice(ref getforceEnable, ref getgripperEnable, ref getioEnable,ref dexhandEnable1);
37 Console.WriteLine("\ngetforceEnable status : ");
38 foreach (int i in getforceEnable)
39 {
40 Console.Write(i + ",");
41 }
42 Console.WriteLine("\ngetgripperEnable status : ");
43 foreach (int i in getgripperEnable)
44 {
45 Console.Write(i + ",");
46 }
47 Console.WriteLine("\ngetioEnable status : ");
48 foreach (int i in getioEnable)
49 {
50 Console.Write(i + ",");
51 }
52 Console.WriteLine();
53 robot.ActGripper(1, 0);
54 Thread.Sleep(3000);
55 robot.ActGripper(1, 1);
56 Thread.Sleep(4000);
57 robot.MoveGripper(1, 50, 10, 100, 50000, 0, 0, 0, 0, 0);
58 int pos = 0;
59 while (true)
60 {
61 robot.GetRobotRealTimeState(ref pkg);
62 Console.WriteLine("gripper pos is " + pkg.gripper_position);
63 Thread.Sleep(100);
64 }
65}
11.64. Code example
Added in version C#SDK-V1.1.3: Web-3.8.2
1private void button11_Click(object sender, EventArgs e)
2{
3
4 ROBOT_STATE_PKG pkg = new ROBOT_STATE_PKG();
5 int state = 0;
6 while (true)
7 {
8 int rtn = robot.GetSmarttoolBtnState(ref state);
9 string binaryString = Convert.ToString(state, 2).PadLeft(32, '0');
10 Console.WriteLine($"GetSmarttoolBtnState rtn (binary): {binaryString}");
11 Thread.Sleep(100);
12 }
13
14}
11.65. Upload Open Protocol Lua File
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Upload Open Protocol Lua File
3* @param filePath Local open protocol lua file path name
4* @return Error code
5*/
6public int OpenLuaUpload(String filePath)
11.66. Get Slave Board Parameters
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Get Slave Board Parameters
3* @param type 0-Ethercat, 1-CClink, 3-Ethercat, 4-EIP
4* @param version Protocol version
5* @param connState 0-Disconnected 1-Connected
6* @return Error code
7*/
8public int GetFieldBusConfig(int[] type, int[] version, int[] connState)
11.67. Write Slave DO
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Write Slave DO
3* @param DOIndex DO number
4* @param wirteNum Number to write
5* @param status Value to write, max 8
6* @return Error code
7*/
8public int FieldBusSlaveWriteDO(int DOIndex, int wirteNum, int[] status)
11.68. Write Slave AO
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Write slave station AO
3* @param [in] AOIndex AO number
4* @param [in] writeNum Number of values to write
5* @param [in] status Array of values to write (maximum 8), AO0~AO15 are integer type, AO16~AO31 are floating point type
6* @return Error code
7*/
8public int FieldBusSlaveWriteAO(int AOIndex, int writeNum, double[] status)
11.69. Read Slave DI
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Read Slave DI
3* @param DOIndex DI number
4* @param readNum Number to read
5* @param status Read value, max 8
6* @return Error code
7*/
8public int FieldBusSlaveReadDI(int DOIndex, int readNum, int[] status)
11.70. Read Slave AI
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Read Slave AI
3* @param AIIndex AI number
4* @param readNum Number to read
5* @param status Read value, max 8
6* @return Error code
7*/
8public int FieldBusSlaveReadAI(int AIIndex, int readNum, double[] status)
11.71. Wait for Extended DI Input
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Wait for Extended DI Input
3* @param DIIndex DI number
4* @param status 0-Low level; 1-High level
5* @param waitMs Max waiting time (ms)
6* @return Error code
7*/
8public int FieldBusSlaveWaitDI(int DIIndex, int status, int waitMs)
11.72. Wait for Extended AI Input
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Wait for Extended AI Input
3* @param AIIndex AI number
4* @param waitType 0-Greater than; 1-Less than
5* @param value AI value
6* @param waitMs Max waiting time (ms)
7* @return Error code
8*/
9public int FieldBusSlaveWaitAI(int AIIndex, int waitType, double value, int waitMs)
11.74. Control Array Sucker
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Control Array Sucker
3* @param slaveID Slave ID
4* @param len Length
5* @param ctrlValue Control value 1-Suction at max vacuum; 2-Suction at set vacuum; 3-Stop suction
6* @return Error code
7*/
8public int SetSuckerCtrl(int slaveID, int len, int[] ctrlValue)
11.75. Get Array Sucker Status
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Get Array Sucker Status
3* @param slaveID Slave ID
4* @param state Adsorption state 0-Release object; 1-Workpiece detected and adsorbed successfully; 2-No object adsorbed; 3-Object detached
5* @param pressValue Current vacuum degree Unit kpa
6* @param error Sucker current error code
7* @return Error code
8*/
9public int GetSuckerState(int slaveID, int[] state, int[] pressValue, int[] error)
11.76. Wait for Sucker Status
Added in version C#SDK-V1.1.7: Web-3.8.5
1/**
2* @brief Wait for Sucker Status
3* @param slaveID Slave ID
4* @param state Adsorption state 0-Release object; 1-Workpiece detected and adsorbed successfully; 2-No object adsorbed; 3-Object detached
5* @param ms Max waiting time
6* @return Error code
7*/
8public int WaitSuckerState(int slaveID, int state, int ms)
11.77. Array Sucker Control Command Code Example
1private void TestSucker(Robot robot)
2{
3
4 int[] ctrl = new int[20];
5 int state=0;
6 int pressValue=0;
7 int error=0;
8 int rtn;
9
10
11 // Upload and load open protocol file
12 robot.OpenLuaUpload(@"C:\SDK\CtrlDev_sucker.lua");
13 Thread.Sleep(2000);
14 robot.UnloadCtrlOpenLUA(1);
15 robot.LoadCtrlOpenLUA(1);
16 Thread.Sleep(1000);
17
18 // Control sucker in broadcast mode with maximum adsorption capacity
19 ctrl[0] = 1;
20 robot.SetSuckerCtrl(0, 1, ctrl);
21
22 // Monitor states of sucker 1 and sucker 12 in a loop
23 for (int i = 0; i < 100; i++)
24 {
25 robot.GetSuckerState(1, ref state, ref pressValue, ref error);
26 Console.WriteLine($"sucker1 state is {state}, pressValue is {pressValue}, error num is {error}");
27 robot.GetSuckerState(12, ref state, ref pressValue, ref error);
28 Console.WriteLine($"sucker12 state is {state}, pressValue is {pressValue}, error num is {error}");
29 Thread.Sleep(100);
30 }
31 // Wait for sucker 1 to reach adsorbed state, timeout 100ms
32 int ret = robot.WaitSuckerState(1, 1, 100);
33 Console.WriteLine($"WaitSuckerState result is {ret}");
34
35 // Unicast mode to turn off sucker 1 and 12
36 ctrl[0] = 3;
37 robot.SetSuckerCtrl(1, 1, ctrl);
38 robot.SetSuckerCtrl(12, 1, ctrl);
39
40 robot.CloseRPC();
41}
11.78. Laser peripheral on/off function
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser peripheral on/off function
3* @param [in] OnOff 0-off 1-on
4* @param [in] weldId Weld seam ID, default is 0
5* @return Error code
6*/
7public int LaserTrackingLaserOnOff(int OnOff, int weldId)
11.79. Laser tracking start/stop function
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser tracking start/stop function
3* @param [in] OnOff 0-stop 1-start
4* @param [in] coordId Laser peripheral tool coordinate system number
5* @return Error code
6*/
7public int LaserTrackingTrackOnOff(int OnOff, int coordId)
11.80. Laser positioning - fixed direction
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser positioning - fixed direction
3* @param [in] direction 0-x+ 1-x- 2-y+ 3-y- 4-z+ 5-z-
4* @param [in] vel Speed in %
5* @param [in] distance Maximum positioning distance in mm
6* @param [in] timeout Positioning timeout in ms
7* @param [in] posSensorNum Laser calibrated tool coordinate number
8* @return Error code
9*/
10public int LaserTrackingSearchStart_xyz(int direction, int vel, int distance, int timeout, int posSensorNum)
11.81. Laser positioning - arbitrary direction
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser positioning - arbitrary direction
3* @param [in] directionPoint XYZ coordinates of the positioning input point
4* @param [in] vel Speed in %
5* @param [in] distance Maximum positioning distance in mm
6* @param [in] timeout Positioning timeout in ms
7* @param [in] posSensorNum Laser calibrated tool coordinate number
8* @return Error code
9*/
10public int LaserTrackingSearchStart_point(DescTran directionPoint, int vel, int distance, int timeout, int posSensorNum)
11.82. Laser positioning stop
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser positioning stop
3* @return Error code
4*/
5public int LaserTrackingSearchStop()
11.83. Laser IP configuration
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser IP configuration
3* @param [in] ip IP address of the laser peripheral
4* @param [in] port Port number of the laser peripheral
5* @return Error code
6*/
7public int LaserTrackingSensorConfig(string ip, int port)
11.84. Laser peripheral sampling period configuration
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser peripheral sampling period configuration
3* @param [in] period Laser peripheral sampling period in ms
4* @return Error code
5*/
6public int LaserTrackingSensorSamplePeriod(int period)
11.85. Laser peripheral driver loading
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser peripheral driver loading
3* @param [in] type Laser peripheral driver protocol type 101-Ruiniu 102-Chuangxiang 103-Quanshi 104-Tongzhou 105-Aotai
4* @return Error code
5*/
6public int LoadPosSensorDriver(int type)
11.86. Laser Peripheral Driver Unloading
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser peripheral driver unloading
3* @return Error code
4*/
5public int UnLoadPosSensorDriver()
11.87. Laser Weld Seam Trajectory Recording
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser weld seam trajectory recording
3* @param [in] status 0-stop recording 1-real-time tracking 2-start recording
4* @param [in] delayTime Delay time in ms
5* @return Error code
6*/
7public int LaserSensorRecord1(int status, int delayTime)
11.88. Laser Weld Seam Trajectory Replay
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser weld seam trajectory replay
3* @param [in] delayTime Delay time in ms
4* @param [in] speed Speed in %
5* @return Error code
6*/
7public int LaserSensorReplay(int delayTime, double speed)
11.89. Laser Tracking Replay
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Laser tracking replay
3* @return Error code
4*/
5public int MoveLTR()
11.90. Laser Weld Seam Trajectory Recording and Replay
1/**
2* @brief Laser Seam Trajectory Recording and Replay
3* @param [in] delayMode Mode 0-Delay Time 1-Delay Distance
4* @param [in] delayTime Delay time in milliseconds (ms)
5* @param [in] delayDisExAxisNum Extended Axis Number
6* @param [in] delayDis Delay distance in millimeters (mm)
7* @param [in] sensitivePara Compensation Sensitivity Coefficient
8* @param [in] trackMode Fixed-point Tracking Type. 0-Extended Axis Asynchronous Motion; 1-Robot
9* @param [in] triggerMode Fixed-point Tracking Trigger Method. 0-Tracking Duration; 1-IO
10* @param [in] runTime Robot Fixed-point Tracking Duration in seconds (s)
11* @param [in] speed Speed in percentage (%)
12* @return Error Code
13*/
14public int LaserSensorRecordandReplay(int delayMode, int delayTime, int delayDisExAxisNum,double delayDis, double sensitivePara, int trackMode, int triggerMode,double runTime, double speed)
11.91. Move to Laser Record Start Point
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Move to laser record start point
3* @param [in] moveType 0-PTP 1-LIN
4* @param [in] ovl Speed in %
5* @return Error code
6*/
7public int MoveToLaserRecordStart(int moveType, double ovl)
11.92. Move to Laser Record End Point
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Move to laser record end point
3* @param [in] moveType 0-PTP 1-LIN
4* @param [in] ovl Speed in %
5* @return Error code
6*/
7public int MoveToLaserRecordEnd(int moveType, double ovl)
11.93. Move to Laser Sensor Positioning Point
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Move to laser sensor positioning point
3* @param [in] moveFlag Motion type: 0-PTP; 1-LIN
4* @param [in] ovl Speed scaling factor, 0-100
5* @param [in] dataFlag Weld seam cache data selection: 0-execute planning data; 1-execute recorded data
6* @param [in] plateType Plate type: 0-corrugated plate; 1-corrugated cardboard; 2-fence plate; 3-oil drum; 4-corrugated shell steel
7* @param [in] trackOffectType Laser sensor offset type: 0-no offset; 1-base coordinate system offset; 2-tool coordinate system offset; 3-laser sensor raw data offset
8* @param [in] offset Offset value
9* @return Error code
10*/
11public int MoveToLaserSeamPos(int moveFlag, double ovl, int dataFlag, int plateType, int trackOffectType, DescPose offset)
11.94. Get laser sensor positioning point coordinate information
Added in version C#SDK-V1.1.8: Web-3.8.6
1/**
2* @brief Get laser sensor positioning point coordinate information
3* @param [in] trackOffectType Laser sensor offset type: 0-no offset; 1-base coordinate system offset; 2-tool coordinate system offset; 3-laser sensor raw data offset
4* @param [in] offset Offset value
5* @param [out] jPos Joint position [°]
6* @param [out] descPos Cartesian position [mm]
7* @param [out] tool Tool coordinate system
8* @param [out] user Workpiece coordinate system
9* @param [out] exaxis Extended axis position [mm]
10* @return Error code
11*/
12public int GetLaserSeamPos(int trackOffectType, DescPose offset, ref JointPos jPos, ref DescPose descPos, ref int tool, ref int user, ref ExaxisPos exaxis)
11.95. Laser Peripheral Sensor Parameter Configuration and Debugging Code Example
Added in version C#SDK-V1.1.8: Web-3.8.6
1void testLaserConfig()
2{
3 int[] ctrl = new int[20];
4 int state;
5 int pressValue;
6 int error;
7 robot.LaserTrackingSensorConfig("192.168.58.20", 5020);
8 robot.LaserTrackingSensorSamplePeriod(20);
9 robot.LoadPosSensorDriver(101);
10 robot.LaserTrackingLaserOnOff(0, 0);
11 System.Threading.Thread.Sleep(3000);
12 robot.LaserTrackingLaserOnOff(1, 0);
13}
11.96. Laser Trajectory Scanning and Trajectory Replay Code Example
Added in version C#SDK-V1.1.8: Web-3.8.6
1void testLaserRecordAndReplay()
2{
3 int[] ctrl = new int[20];
4 int state;
5 int pressValue;
6 int error;
7 robot.OpenLuaUpload("D://zUP/CtrlDev_laser_ruiniu-0117.lua");
8 System.Threading.Thread.Sleep(2000);
9 robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua");
10 robot.UnloadCtrlOpenLUA(0);
11 robot.LoadCtrlOpenLUA(0);
12 System.Threading.Thread.Sleep(8000);
13 for (int i=0;i<10;++i)
14 {
15 JointPos startjointPos = new JointPos(56.205, -117.951, 141.872, -118.149, -94.217, -122.176);
16 DescPose startdescPose = new DescPose(-97.552, -282.855, 26.675, 174.182, -1.338, -91.707);
17 ExaxisPos exaxisPos = new ExaxisPos(0, 0, 0, 0);
18 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
19
20 robot.MoveL(startjointPos, startdescPose, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0);
21 robot.LaserSensorRecord1(2, 10);
22
23 JointPos endjointPos = new JointPos(68.809, -87.100, 121.120, -127.233, -95.038, -109.555);
24 DescPose enddescPose = new DescPose(-103.555, -464.234, 13.076, 174.179, -1.344, -91.709);
25 robot.MoveL(endjointPos, enddescPose, 1, 0, 50, 100, 100, -1, exaxisPos, 0, 0, offdese, 0);
26
27 robot.LaserSensorRecord1(0, 10);
28 robot.MoveToLaserRecordStart(1, 30);
29 robot.LaserSensorReplay(10, 100);
30 robot.MoveLTR();
31 robot.LaserSensorRecord1(0, 10);
32 Console.WriteLine($"Number of completions : {i+1} ");
33 }
34
35}
11.97. Laser Positioning and Real-time Tracking Code Example
Added in version C#SDK-V1.1.8: Web-3.8.6
1public static void testLasertrack()
2{
3 int[] ctrl = new int[20];
4 int state;
5 int pressValue;
6 int error;
7 robot.OpenLuaUpload("D://zUP/CtrlDev_laser_ruiniu-0117.lua");
8 System.Threading.Thread.Sleep(2000);
9 robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua");
10 robot.UnloadCtrlOpenLUA(0);
11 robot.LoadCtrlOpenLUA(0);
12 System.Threading.Thread.Sleep(8000);
13 for (int i = 0; i < 10; ++i)
14 {
15 JointPos startjointPos = new JointPos(56.205, -117.951, 141.872, -118.149, -94.217, -122.176);
16 DescPose startdescPose = new DescPose(-97.552, -282.855, 26.675, 174.182, -1.338, -91.707);
17 ExaxisPos exaxisPos = new ExaxisPos(0, 0, 0, 0);
18 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
19 DescTran directionPoint = new DescTran();
20
21 robot.MoveL(startjointPos, startdescPose, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0);
22 robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 3);
23 robot.LaserTrackingSearchStop();
24 robot.MoveToLaserSeamPos(1, 30, 0, 0, 0, offdese);
25
26 robot.LaserTrackingTrackOnOff(1, 3);
27
28 JointPos endjointPos = new JointPos(68.809, -87.100, 121.120, -127.233, -95.038, -109.555);
29 DescPose enddescPose = new DescPose(-103.555, -464.234, 13.076, 174.179, -1.344, -91.709);
30 robot.MoveL(endjointPos, enddescPose, 1, 0, 20, 100, 100, -1, exaxisPos, 0, 0, offdese, 0);
31 robot.LaserTrackingTrackOnOff(0, 3);
32 Console.WriteLine($"Number of completions : {i + 1} ");
33 }
34}
11.98. Extended Axis and Robot Synchronized Laser Tracking Code Example
Added in version C#SDK-V1.1.8: Web-3.8.6
1public void TestLaserTrackAndExitAxis()
2{
3 ExaxisPos startexaxisPos = new ExaxisPos(0, 0, 0, 0);
4 ExaxisPos seamexaxisPos = new ExaxisPos(-10, 0, 0, 0);
5 ExaxisPos endexaxisPos = new ExaxisPos(-30, 0, 0, 0);
6 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
7 JointPos startjointPos = new JointPos(58.337, -119.628, 146.037, -116.358, -92.224, -117.654);
8 DescPose startdescPose = new DescPose(-53.375, -255.363, 0.919, 178.054, 1.077, -94.026);
9 for (int i=0;i<10;++i)
10 {
11 robot.ExtAxisSyncMoveJ(startjointPos, startdescPose, 1, 0, 100, 100, 100, startexaxisPos, -1, 0, offdese);
12 Console.WriteLine("11111");
13 int ret = robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 2);
14 robot.LaserTrackingSearchStop();
15 Console.WriteLine("2222");
16 int tool = 0;
17 int user = 0;
18 JointPos seamjointPos = new JointPos();
19 DescPose seamdescPose = new DescPose();
20 robot.GetLaserSeamPos(0, offdese, ref seamjointPos, ref seamdescPose, ref tool, ref user, ref startexaxisPos);
21 Console.WriteLine($"{seamjointPos.jPos[0]}, {seamjointPos.jPos[1]}, {seamjointPos.jPos[2]}, " +
22 $"{seamjointPos.jPos[3]}, {seamjointPos.jPos[4]}, {seamjointPos.jPos[5]}, " +
23 $"{seamdescPose.tran.x}, {seamdescPose.tran.y}, {seamdescPose.tran.z}, " +
24 $"{seamdescPose.rpy.rx}, {seamdescPose.rpy.ry}, {seamdescPose.rpy.rz}");
25 if (ret == 0)
26 {
27 robot.ExtAxisSyncMoveJ(seamjointPos, seamdescPose, 1, 0, 100, 100, 100, seamexaxisPos, -1, 0, offdese);
28 Console.WriteLine("3333");
29 robot.LaserTrackingTrackOnOff(1, 2);
30 JointPos endjointPos = new JointPos(70.580, -90.918, 126.593, -125.154, -92.162, -105.403);
31 DescPose enddescPose = new DescPose(-53.375, -419.020, 0.920, 178.054, 1.076, -94.026);
32 robot.ExtAxisSyncMoveL(endjointPos, enddescPose, 1, 0, 20, 100, 100, -1, endexaxisPos, 0, offdese);
33 robot.LaserTrackingTrackOnOff(0, 2);
34 }
35 Console.WriteLine($"Number of completions : {i + 1} ");
36 }
37}
11.99. Laser Recording Replay + Regular Weave Code Example
1void TestLaserReproduceNormalWeave()
2{
3 JointPos startjointPos = new JointPos(69.655, -71.524, -119.568, -76.454, 91.188, 138.014);
4 DescPose startdescPose = new DescPose(214.765, 311.139, 41.255, 7.693, -0.287, 37.080);
5 JointPos endjointPos = new JointPos(58.803, -79.528, -113.688, -74.599, 91.637, 127.167);
6 DescPose enddescPose = new DescPose(294.942, 311.153, 41.302, 7.701, -0.283, 37.081);
7 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
8 int rtn = 0;
9
10 // WaitMs(1000)
11 Thread.Sleep(1000);
12
13 // MoveL to start position (extended axis 0,174.957,0,0)
14 rtn = robot.MoveL(startjointPos, startdescPose, 5, 0, 100, 100, 100, -1, 0, new ExaxisPos(0, 174.957, 0, 0), 0, 0, offdese, 100, 0, 0, 10);
15
16 Console.WriteLine($"MoveL start: {rtn}");
17
18 // Start laser recording
19 rtn = robot.LaserSensorRecord1(2, 10);
20 Console.WriteLine($"LaserSensorRecord start: {rtn}");
21
22 // MoveL to end position
23 rtn = robot.MoveL(endjointPos, enddescPose, 5, 0, 100, 100, 100, -1, 0, new ExaxisPos(0, 174.957, 0, 0), 0, 0, offdese, 100, 0, 0, 10);
24 Console.WriteLine($"MoveL end: {rtn}");
25
26 // Stop laser recording
27 rtn = robot.LaserSensorRecord1(0, 10);
28 Console.WriteLine($"LaserSensorRecord stop: {rtn}");
29
30 // MoveL back to start position
31 rtn = robot.MoveL(startjointPos, startdescPose, 5, 0, 100, 100, 100, -1, 0, new ExaxisPos(0, 174.957, 0, 0), 0, 0, offdese, 100, 0, 0, 10);
32 Console.WriteLine($"MoveL back: {rtn}");
33
34 // LIN motion to the start of the laser record path
35 rtn = robot.MoveToLaserRecordStart(1, 30);
36 Console.WriteLine($"MoveToLaserRecordStart: {rtn}");
37
38 // Start regular weaving
39 rtn = robot.WeaveStart(0);
40 Console.WriteLine($"WeaveStart: {rtn}");
41
42 // Start replay recording
43 rtn = robot.LaserSensorRecord1(3, 10);
44 Console.WriteLine($"LaserSensorRecord replay: {rtn}");
45
46 // Laser tracking replay motion
47 rtn = robot.MoveLTR();
48 Console.WriteLine($"MoveLTR: {rtn}");
49 Thread.Sleep(3000);
50
51 // Stop replay recording
52 rtn = robot.LaserSensorRecord1(0, 10);
53 Console.WriteLine($"LaserSensorRecord stop: {rtn}");
54
55 // End regular weaving
56 rtn = robot.WeaveEnd(0);
57 Console.WriteLine($"WeaveEnd: {rtn}");
58}
11.100. Laser Recording Replay + Extended Axis Asynchronous Motion + Fixed-Point Weave Code Example
1void TestLaserRecordReplayExaxisWithWave()
2{
3 JointPos startjointPos = new JointPos(106.245, -63.397, -93.331, -80.809, 80.389, 134.561);
4 DescPose startdescPose = new DescPose(33.534, 516.527, 371.029, 14.712, -31.379, 71.734);
5 JointPos endjointPos = new JointPos(105.534, -64.685, -93.681, -79.071, 80.772, 133.952);
6 DescPose enddescPose = new DescPose(33.536, 528.536, 364.924, 14.712, -31.379, 71.734);
7 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
8 int rtn = 0;
9
10 // MoveJ to safe point (extended axis 0,174.957,0,0)
11 rtn = robot.MoveJ(startjointPos, startdescPose, 5, 0, 100, 100, 50, new ExaxisPos(0, 174.957, 0, 0), -1, 0, offdese);
12 Console.WriteLine($"MoveJ start: {rtn}");
13
14 // Extended axis asynchronous motion to starting point 105.003
15 rtn = robot.ExtAxisMove(new ExaxisPos(0, 105.003, 0, 0), 50, -1);
16 Console.WriteLine($"ExtAxisMove 105.003: {rtn}");
17 Thread.Sleep(3000);
18
19 // MoveL to starting point
20 rtn = robot.MoveL(endjointPos, enddescPose, 5, 0, 100, 100, 50, -1, 0, new ExaxisPos(0, 105.003, 0, 0), 0, 0, offdese, 100, 0, 0, 10);
21 Console.WriteLine($"MoveL end: {rtn}");
22
23 // Start laser recording
24 rtn = robot.LaserSensorRecord1(2, 10);
25 Console.WriteLine($"LaserSensorRecord start: {rtn}");
26
27 // Extended axis moves to 174.957 during recording
28 rtn = robot.ExtAxisMove(new ExaxisPos(0, 174.957, 0, 0), 50, -1);
29 Console.WriteLine($"ExtAxisMove 174.957: {rtn}");
30 Thread.Sleep(3000);
31
32 // Stop laser recording
33 rtn = robot.LaserSensorRecord1(0, 10);
34 Console.WriteLine($"LaserSensorRecord stop: {rtn}");
35
36
37 // Extended axis returns to 105.003, MoveL back to starting point
38 rtn = robot.ExtAxisMove(new ExaxisPos(0, 105.003, 0, 0), 50, -1);
39 Console.WriteLine($"ExtAxisMove back: {rtn}");
40
41 // MoveL to starting point
42 rtn = robot.MoveL(endjointPos, enddescPose, 5, 0, 100, 100, 50, -1, 0, new ExaxisPos(0, 105.003, 0, 0), 0, 0, offdese, 100, 0, 0, 10);
43 Console.WriteLine($"MoveL back: {rtn}");
44
45 // PTP motion to the start of the laser record path
46 rtn = robot.MoveToLaserRecordStart(0, 30);
47 Console.WriteLine($"MoveToLaserRecordStart: {rtn}");
48
49 // Start replay
50 rtn = robot.LaserSensorRecord1(3, 10);
51 Console.WriteLine($"LaserSensorRecord replay: {rtn}");
52
53 // Start fixed-point weaving
54 DescPose refPoint = new DescPose(61.087, 512.431, 370.523, 14.335, -31.333, 69.014);
55 rtn = robot.OriginPointWeaveStart(0, 1, refPoint, 5);
56 Console.WriteLine($"OriginPointWeaveStart: {rtn}");
57
58 // Extended axis moves to 174.957 during weaving
59 rtn = robot.ExtAxisMove(new ExaxisPos(0, 174.957, 0, 0), 50, -1);
60 Console.WriteLine($"ExtAxisMove replay: {rtn}");
61
62 // End weaving
63 rtn = robot.OriginPointWeaveEnd();
64 Console.WriteLine($"OriginPointWeaveEnd: {rtn}");
65
66 // Stop replay
67 rtn = robot.LaserSensorRecord1(0, 10);
68 Console.WriteLine($"LaserSensorRecord stop: {rtn}");
69}
11.101. End-Effector Transparent Transmission Function Enable/Disable
1/**
2* @brief Enable end-effector general transparent transmission function
3* @param [in] enable, 0-disable, 1-enable
4* @return Error code
5*/
6public int SetAxleGenComEnable(int mode)
11.102. End-Effector Transparent Transmission Function Non-Periodic Data Transmission and Reception
1/**
2* @brief End-effector sends non-periodic data and waits for response
3* @param [in] len_snd, length of data to send
4* @param [in] sndBuff[], data to send
5* @param [in] len_rcv, length of data to receive
6* @param [out] rcvBuff[], response data
7* @return Error code
8*/
9public int SndRcvAxleGenComCmdData(int len_snd, int[] sndBuff, int len_rcv, ref int[] rcvdata)
11.103. Code Example for Non-Periodic Data Communication of DIO Health Care Moxibustion Head Based on End-Effector Transparent Transmission Function
1void testAxleGenCom()
2{
3 int[] led_on = new int[6] { 0xAB, 0xBA, 0x12, 0x01, 0x01, 0x79 };
4 int[] led_off = new int[6] { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
5 int[] version = new int[5]{ 0xAB, 0xBA, 0x11, 0x00, 0x76 };
6 int[] state = new int[6] { 0xAB, 0xBA, 0x1B,0x01, 0xAA, 0x2B };
7 int[] cycleState = new int[6] { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
8
9 int[] rcvdata = new int[16];
10 int ret = 0;
11 int cnt = 1;
12
13 JointPos p1Joint = new JointPos(88.708, -86.178, 140.989, -141.825, -89.162, -49.879);
14 DescPose p1Desc = new DescPose(188.007, -377.850, 260.207, 178.715, 2.823, -131.466);
15
16 JointPos p2Joint = new JointPos(112.131, -75.554, 126.989, -139.027, -88.044, -26.477);
17 DescPose p2Desc = new DescPose(368.003, -377.848, 260.211, 178.715, 2.823, -131.465);
18
19 ExaxisPos exaxisPos = new ExaxisPos(0, 0, 0, 0);
20 DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
21
22 //Enable end-effector transparent transmission function
23 robot.SetAxleGenComEnable(1);
24 robot.SetAxleLuaEnable(1);
25
26 while(cnt<=10)
27 {
28 //Read version number
29 ret = robot.SndRcvAxleGenComCmdData(5, version, 10, ref rcvdata);
30 Console.WriteLine($" hard version : {rcvdata[4]},hard code:{rcvdata[5]}, soft version:{rcvdata[6]} {rcvdata[7]}, soft code:{rcvdata[8]}");
31 if (ret != 0)
32 {
33 break;
34 }
35 Thread.Sleep(1000);
36 //Read moxibustion head presence status
37 ret = robot.SndRcvAxleGenComCmdData(6, state, 6, ref rcvdata);
38 Console.WriteLine($" state : {rcvdata[4]}");
39 Thread.Sleep(1000);
40 //Turn on moxibustion head laser
41 ret = robot.SndRcvAxleGenComCmdData(6, led_on, 6, ref rcvdata);
42 Console.WriteLine($"led on rcv data is: {rcvdata[0]},{rcvdata[1]}, {rcvdata[2]}, {rcvdata[3]}, {rcvdata[4]}, {rcvdata[5]}");
43 robot.MoveJ(p1Joint, p1Desc, 0, 0, 100, 100, 100, exaxisPos, -1, 0, offdese);
44 Thread.Sleep(4000);
45 //Turn off moxibustion head laser
46 ret = robot.SndRcvAxleGenComCmdData(6, led_off, 6, ref rcvdata);
47 Console.WriteLine($"led off rcv data is: {rcvdata[0]},{rcvdata[1]}, {rcvdata[2]}, {rcvdata[3]}, {rcvdata[4]}, {rcvdata[5]}");
48 robot.MoveJ(p2Joint, p2Desc, 0, 0, 100, 100, 100, exaxisPos, -1, 0, offdese);
49 Thread.Sleep(1000);
50 Console.WriteLine($"***********************complate No. {cnt} SDK test*****************************");
51 cnt++;
52 }
53
54}
11.104. Download Open Protocol Lua File
1/**
2* @brief Download open protocol Lua file
3* @param [in] fileName Open protocol file name "CtrlDev_XXX.lua"
4* @param [in] savePath Path to save the open protocol file
5* @return Error code
6*/
7public int OpenLuaDownload(string fileName, string savePath)
11.105. Delete Open Protocol Lua File
1/**
2* @brief Delete open protocol Lua file
3* @param [in] fileName Name of the open protocol Lua file to delete "CtrlDev_XXX.lua"
4* @return Error code
5*/
6public int OpenLuaDelete(string fileName)
11.106. Delete All Open Protocol Lua Files
1/**
2* @brief Delete all open protocol Lua files
3* @return Error code
4*/
5public int AllOpenLuaDelete()
11.107. SDK Code Example for Open Protocol Lua File Operations
1public int TestCtrlOpenLuaOperate()
2{
3 int rtn;
4
5 // Upload Lua file to robot
6 rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_WELDING_A.lua");
7 Console.WriteLine($"OpenLuaUpload rtn is {rtn}");
8 rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_SWDPOLISH.lua");
9 Console.WriteLine($"OpenLuaUpload rtn is {rtn}");
10
11 // Download Lua file from robot
12 rtn = robot.OpenLuaDownload("CtrlDev_WELDING_A.lua", "D://zDOWN/");
13 Console.WriteLine($"OpenLuaDownload rtn is {rtn}");
14 rtn = robot.OpenLuaDownload("CtrlDev_SWDPOLISH.lua", "D://zDOWN/");
15 Console.WriteLine($"OpenLuaDownload rtn is {rtn}");
16
17 // Set control open protocol Lua name
18 rtn = robot.SetCtrlOpenLUAName(0, "CtrlDev_WELDING_A.lua");
19 Console.WriteLine($"SetCtrlOpenLUAName rtn is {rtn}");
20 rtn = robot.SetCtrlOpenLUAName(1, "CtrlDev_SWDPOLISH.lua");
21 Console.WriteLine($"SetCtrlOpenLUAName rtn is {rtn}");
22
23 // Get control open protocol Lua name
24 string[] name = new string[4];
25 rtn = robot.GetCtrlOpenLUAName(ref name);
26 Console.WriteLine($"ctrl open lua names : {name[0]}, {name[1]}, {name[2]}, {name[3]}");
27
28 // Load and unload open protocol Lua
29 rtn = robot.LoadCtrlOpenLUA(1);
30 Console.WriteLine($"LoadCtrlOpenLUA rtn is {rtn}");
31 robot.Sleep(2000);
32 rtn = robot.UnloadCtrlOpenLUA(1);
33 Console.WriteLine($"UnloadCtrlOpenLUA rtn is {rtn}");
34
35 // Delete specified Lua file and all Lua files
36 rtn = robot.OpenLuaDelete("CtrlDev_WELDING_A.lua");
37 Console.WriteLine($"OpenLuaDelete rtn is {rtn}");
38 rtn = robot.AllOpenLuaDelete();
39 Console.WriteLine($"AllOpenLuaDelete rtn is {rtn}");
40
41 return 0;
42}
11.108. Control Dexterous Hand Motion
1/**
2* @brief Control dexterous hand motion
3* @param [in] idstart Starting slave station number
4* @param [in] slaveNum Number of slaves
5* @param [in] pos[16] Position (-360~360)
6* @param [in] speed[16] Speed percentage, range [0~100]
7* @param [in] force[16] Torque percentage, range [0~100]
8* @param [in] max_time Maximum wait time, range [0~30000], unit ms
9* @return Error code
10*/
11public int SetDexterousHandsMove(int idstart, int slaveNum, double[] pos, int[] speed, int[] force, int max_time)
11.109. Control Dexterous Hand Reset and Activation
1/**
2* @brief Control dexterous hand reset and activation
3* @param [in] id Slave station number
4* @param [in] act 0-reset 1-activate
5* @return Error code
6*/
7public int SetDexterousHandsAct(int id, int act)
11.110. Clear Dexterous Hand Error
1/**
2* @brief Clear dexterous hand error
3* @return Error code
4*/
5public int ClearDexterousHandsError()
11.111. Set Enabled Dexterous Hand Action Control Functions
1/**
2* @brief Set enabled dexterous hand action control functions
3* @param [in] id Dexterous hand slave station number
4* @param [in] func 0-grip trigger, 1-gripper initialization, 2-position setting, 3-speed setting, 4-torque setting, 6-read gripper status, 7-read initialization status, 8-read fault code, 9-read position, 10-read speed, 11-read torque, 12-rotation count setting, 13-rotation speed setting, 14-rotation torque setting, 15-read rotary gripper status, 16-read rotary initialization status, 17-read rotation count, 18-read rotation speed, 19-read rotation torque, 20-multi-axis synchronous motion setting, 21-fault clear command, 22-single-axis running status, 23-all-axis running status
5* @return Error code
6*/
7public int SetDexterousHandsFunc(int id, int[] func)
11.112. Get Enabled Dexterous Hand Action Control Functions
1/**
2* @brief Get enabled dexterous hand action control functions
3* @param [in] id Dexterous hand device number
4* @param [out] func 0-grip trigger, 1-gripper initialization, 2-position setting, 3-speed setting, 4-torque setting, 6-read gripper status, 7-read initialization status, 8-read fault code, 9-read position, 10-read speed, 11-read torque, 12-rotation count setting, 13-rotation speed setting, 14-rotation torque setting, 15-read rotary gripper status, 16-read rotary initialization status, 17-read rotation count, 18-read rotation speed, 19-read rotation torque, 20-multi-axis synchronous motion setting, 21-fault clear command, 22-single-axis running status, 23-all-axis running status
5* @return Error code
6*/
7public int GetDexterousHandsFunc(int id, ref int[] func)
11.113. End-Effector Dexterous Hand Configuration and Motion Code Example
1private void button105_Click(object sender, EventArgs e)
2{
3 int id = 1; // Slave station number
4 int slaveNum = 4; // Control 4 fingers
5 int max_time = 8000; // Maximum wait time 8 seconds
6 int[] speed = new int[16]; // Speed array, all 0 means use default speed
7 int[] force = new int[16]; // Torque array
8
9 // Initialize torque array: first 4 fingers set to 50%, the rest 0 (values sent via Move command)
10 for (int i = 0; i < 16; i++)
11 force[i] = (i < 4) ? 50 : 0;
12
13 // Helper function: set position array (only first 4 fingers are effective)
14 double[] pos = new double[16];
15 void SetPositions(double v1, double v2, double v3, double v4)
16 {
17 for (int i = 0; i < 16; i++)
18 pos[i] = 0;
19 pos[0] = v1;
20 pos[1] = v2;
21 pos[2] = v3;
22 pos[3] = v4;
23 }
24
25 JointPos j1 = new JointPos(-91.876, -85.920, 109.279, -86.239, -96.664, -28.563);
26 JointPos j2 = new JointPos(-40.954, -85.920, 109.279, -86.239, -96.664, -28.563);
27 ExaxisPos epos = new ExaxisPos(0, 0, 0, 0);
28 DescPose offset_pos = new DescPose(0, 0, 0, 0, 0, 0);
29
30 Console.WriteLine("===== Dexterous Hand Full Function Test Started =====");
31
32 // 1. Clear error
33 int ret = robot.ClearDexterousHandsError();
34 Console.WriteLine($"ClearDexterousHandsError -> {ret}");
35
36 // ========== 2. Set function switches ==========
37 int[] setFunc = new int[32];
38 setFunc[2] = 1; // Enable position setting function
39 setFunc[4] = 1; // Enable torque setting function
40 setFunc[9] = 1; // Read position
41 setFunc[10] = 1; // Read torque
42 setFunc[11] = 1; // Read status
43 setFunc[22] = 1; // Single-axis motion status
44
45 ret = robot.SetDexterousHandsFunc(id, setFunc);
46 Console.WriteLine($"SetDexterousHandsFunc(enable init + position/torque functions) -> {ret}");
47
48 // ========== 3. Read function status (verify settings took effect) ==========
49 int[] getFunc = new int[32]; // GetDexterousHandsFunc returns 32 integers
50 ret = robot.GetDexterousHandsFunc(id, ref getFunc);
51 Console.WriteLine($"GetDexterousHandsFunc -> {ret}");
52 if (ret == 0)
53 {
54 // Print all 32 values
55 Console.WriteLine("All 32 values returned by GetDexterousHandsFunc:");
56 for (int i = 0; i < getFunc.Length; i++)
57 {
58 Console.Write($" [{i}]={getFunc[i]}");
59 if ((i + 1) % 8 == 0)
60 Console.WriteLine(); // New line every 8 items
61 else if (i < getFunc.Length - 1)
62 Console.Write(", ");
63 }
64 if (getFunc.Length % 8 != 0)
65 Console.WriteLine(); // Add newline if last line has fewer than 8 items
66 }
67
68 // ========== 4. Activate dexterous hand ==========
69 ret = robot.SetDexterousHandsAct(id, 1);
70 Console.WriteLine($"SetDexterousHandsAct(activate) -> {ret}");
71 if (ret != 0)
72 {
73 Console.WriteLine("Activation failed, test aborted");
74 return;
75 }
76
77 // ========== 5. Initial move to 20° (send position and torque values via Move command) ==========
78 SetPositions(20, 20, 20, 20);
79 ret = robot.SetDexterousHandsMove(id, slaveNum, pos, speed, force, max_time);
80 Console.WriteLine($"Initial move to 20° -> {ret}");
81 robot.Sleep(5000);
82
83 // ========== 6. Reciprocating motion 10 times (10° ↔ 50°) ==========
84 Console.WriteLine("Starting 10 reciprocating motions...");
85 for (int iteration = 1; iteration <= 10; iteration++)
86 {
87 robot.MoveJ(j1, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
88
89 SetPositions(10, 10, 10, 10);
90 ret = robot.SetDexterousHandsMove(id, slaveNum, pos, speed, force, max_time);
91 Console.WriteLine($"[{iteration}] Move to 10° -> {ret}");
92 robot.Sleep(1000);
93
94 robot.MoveJ(j2, 0, 0, 100, 100, 100, epos, -1, 0, offset_pos);
95
96 SetPositions(50, 50, 50, 50);
97 ret = robot.SetDexterousHandsMove(id, slaveNum, pos, speed, force, max_time);
98 Console.WriteLine($"[{iteration}] Move to 50° -> {ret}");
99 robot.Sleep(1000);
100 }
101
102 Console.WriteLine("Test completed (function switch set/read + activation + 10 reciprocating motions).");
103}