Skip to main content

Robot coordinate system

Set zero point

Call the function NRC_SetCurrentPosToZeroPos(int axisNum, bool mod) to set the current position to zero point. The parameter "axisNum" represents the number of the axis to be operated on. When "axisNum" is 0, it indicates all axes. The parameter range is: 0 <= axisNum <= total number of robot axes. The parameter "mod" means "Set zero" or "Clear multi-turn value": 0 - Set zero; 1 - Clear multi-turn value. This parameter needs to be set when the servo is stopped or in ready state, and it takes about two to three seconds to execute the function. For most types of servos, executing this function will power on the servo. Please pay attention to safety.

Demo program for setting zero point

#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
int main()
{
SystemStartup();//System startup, see section 3.3 for details
RobotMsg();//Get robot configuration, see section 3.4 for details
SetServoMap();//Set the servo mapping relationship, see section 3.5 for details
SettingofRobotRelatedParameters();//Robot-related parameter setting, see section 3.6 for details
//////The above call functions can be found in Appendix I/////
NRC_SetServoReadyStatus(1);//Set servo ready status, see section 3.8 for details
NRC_SetCurrentPosToZeroPos(0,0) ;//Set current position to zero point
NRC_Position inexbot7;//Define the robot position structure object inexbot7
NRC_GetCurrentPos(NRC_MCS, inexbot7);//Assign the Cartesian coordinate system of the robot to inexbot7
printf("inexbot7.pos=%f,%f,%f,,%f,%f,%f,%f,\n",inexbot7.pos[0],inexbot7.pos[1],inexbot7.pos[2],inexbot7.pos[3],inexbot7.pos[4],inexbot7.pos[5],inexbot7.pos[6]);//Output the initial Cartesian coordinate position of the robot
NRC_Delayms(1000);//Delay 100ms
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}

User coordinate system

In the user coordinate system, the XYZ Cartesian coordinates are defined at any position. The TCP moves parallel to the coordinates.

Set user coordinate system parameters

Set the deviation of the origin of the user coordinate system relative to the origin of the robot's Cartesian coordinate system, so as to determine the user coordinate system. Call the function NRC_SetUserCoordParm(int userNum, NRC_Position& deviation) to set the user coordinate parameters.

  • The parameter "userNum" is the number of the user coordinate system to be set, and its range is: 0 < userNum < 10.
  • The parameter "deviation" is the deviation of the origin of the user coordinate system relative to the origin of the robot's Cartesian coordinate system.
  • The parameter "deviation.coord" is useless.
  • Deviation.pos[0]-deviation.pos[2] are the deviations of the positions on the x, y, and z axes respectively, unit: mm.
  • Deviation.pos[3]-deviation.pos[5] are the rotation angles around the x, y, and z axes respectively, unit: radian. Since it is difficult to measure the deviation in the direction in practice, this function is rarely used. We usually use the NRC_CalibrationUserCoord(int userNum, NRC_Position& origin, NRC_Position& X_Axis, NRC_Position& XOY_Plane) function to calibrate the user coordinates and automatically calculate the deviation.

Calibrate user coordinate system

Call the function NRC_CalibrationUserCoord(int userNum, NRC_Position& origin, NRC_Position& X_Axis, NRC_Position& XOY_Plane) to calibrate the user coordinates and automatically calculate the deviation of the origin of the user coordinate system relative to the origin of the robot's Cartesian coordinate system, thereby determining the user coordinate system.

  • The parameter "userNum" is the number of the user coordinate system to be calibrated, and its range is: 0 < userNum < 10.
  • The parameter "origin" is the position of the origin of the user coordinate system in the robot's Cartesian coordinate system.
  • The parameter "X_Axis" represents the position of any point on the user coordinate system's X-axis in the robot's Cartesian coordinate system, while the parameter "XOY_Plane" represents the position of any point on the user coordinate system's XOY plane in the robot's Cartesian coordinate system.

Switch current user coordinate system

Call the function NRC_SwitchUserCoord(int tagetUser) to switch the current user coordinate system, the parameter "tagetUser" is the number of the target user coordinate system to switch to, and its range is: 0 < tagetUser < 10. Call the function NRC_GetCurrentUserCoord() to get the number of current user coordinate system, the return value is the number of the current user coordinate system, and the initial default value of the user coordinate system is 1.

Set tool hand

In the tool coordinate system, the robot moves parallel to the X, Z, and Y axes defined at the TCP. The tool coordinate system takes the effective direction of the tool installed on the robot wrist flange as the Z axis, and defines the origin of the coordinate system at the TCP. As a result, the direction of the tool coordinate axis changes with the movement of the wrist. The motion of the tool coordinate is not affected by changes in the robot's position or attitude, and it primarily moves based on the effective direction of the tool.

Set tool hand parameters

You can use the function NRC_SetToolCoordParm(int toolNum,NRC_Position& deviation) to set the parameters of the tool. It is used to set the deviation of the tool end position relative to the robot end position, so as to determine the tool coordinate system.

  • The parameter "toolNum" is the number of the tool to be set, and its range is: 0 < toolNum < 10.
  • The parameter "deviation" is the deviation of the tool end position relative to the robot end position.
  • The parameter "deviation.coord" is useless.
  • Deviation.pos[0]-deviation.pos[2] are the deviations of the positions on the x, y, and z axes respectively, unit: mm.
  • Deviation.pos[3]-deviation.pos[5] are the rotation angles around the x, y, and z axes respectively, unit: radian. This parameter is not applicable for a 4-axis SCARA robot. It should be noted that in practical use, this parameter is usually directly filled in based on the design size chart of the tool hand.

Calibrate tool hand

Automatically calculate the deviation of the tool end position relative to the robot end position, so as to determine the tool coordinate system. The tool calibration utilizes the 7-point calibration method, which is only effective for 6-axis serial robots. This function is implemented by calling the function NRC_CalibrationToolCoord_7Pos(int toolNum, NRC_Position& pos1, NRC_Position& pos2, NRC_Position& pos3, NRC_Position& pos4, NRC_Position& pos5, NRC_Position& pos6, NRC_Position& pos7).

  • The parameter "toolNum" is the number of the tool hand to be set, and its range is: 0 < toolNum < 10.
  • pos1 is a position where the tool end is aligned with a fixed tip and the tool hand is kept perpendicular.
  • pos2 is a position where the tool end is aligned with a fixed tip, it cannot be the same as pos1, pos3, and pos4.
  • pos3 is a position where the tool end is aligned with a fixed tip, it cannot be the same as pos1, pos2, and pos4.
  • pos4 is a position where the tool end is aligned with a fixed tip, it cannot be the same as pos1, pos2, and pos3.
  • pos5 is a position where the tool hand is kept perpendicular, it can be the same as pos1.
  • pos6 is a position on the positive X-axis relative to pos5, and pos7 is a position on the positive Y-axis relative to pos6.

Switch tool hand

Sometimes previously calibrated tool hands can be directly switched and used, which can be achieved by calling the function NRC_SwitchToolCoord(int tagetTool). The parameter "tagetTool" is the number of the target tool hand to switch to, with 0 indicating no tool hand. The parameter range is: 0 <= tagetTool < 10. Call the function NRC_GetCurrentToolCoord() to get the current tool hand number. The initial default value of the tool hand number is 0, indicating no tool hand.

Switch coordinate system

The four coordinate systems used by robots are the joint coordinate system, Cartesian coordinate system, tool coordinate system, and user coordinate system. Joint coordinate system: Each joint axis of the robot moves independently. Cartesian coordinate system (referred to as the world coordinate system in the Inexbot API library): The front end of the robot moves parallel to the X, Y, and Z axes of the base. A, B, and C rotate around the X, Y, and Z axes respectively. Tool coordinate system: The effective direction of the robot's wrist tool is used as the Z-axis, and the origin of the coordinate system is defined at the TCP. The TCP moves parallel to the coordinates. TA, TB, and TC rotate around the TX, TY, and TZ axes respectively. User coordinate system: The X, Y, and Z Cartesian coordinates are defined at any position. The TCP moves parallel to the coordinates. Use an enumeration type to define four coordinate systems:

enum NRC_COORD
{
NRC_ACS = 0, ///< Joint coordinate system
NRC_MCS = 1, ///< Cartesian coordinate system
NRC_PCS = 2, ///< Tool coordinate system
NRC_UCS = 3 ///< User coordinate system
};

Call the function NRC_SetCurrentCoord(NRC_COORD coord) to switch the current coordinate system, where the parameter "coord" is an enumeration type enum NRC_COORD that specifies the coordinate system to switch to. Similarly, call the function NRC_COORD NRC_GetCurrentCoord() to get the current coordinate system.

Coordinate transformation

Joint to Cartesian

Call the function NRC_PositionACStoMCS(NRC_Position& posACS, NRC_Position& posMCS) to convert the joint coordinate value of the robot to Cartesian coordinate value, posACS is the joint coordinate value to be converted, and the conversion result is returned by posMCS.

Cartesian to joint

Similarly, you can call the function NRC_PositionMCStoACS(NRC_Position& posMCS, NRC_Position& posACS) to convert the Cartesian coordinate value of the robot to joint coordinate value, posMCS is the Cartesian coordinate value to be converted, and the conversion result is returned by posACS, retval = 0 means the conversion is successful, retval = -1 means the conversion is failed.