Skip to main content

Set robot-related parameters

Setting the basic robot parameters is a prerequisite and foundation for the robot to run correctly. By importing the robot joint parameters and DH parameters into the controller beforehand, the step of repeatedly filling in the parameters can be saved. The settings mainly include robot DH parameter configuration, robot joint parameter configuration, robot Cartesian parameter configuration, and robot range limit configuration.

Robot DH parameter configuration

Define an object config using the struct class NRC_RobotDHConfig, and then set the robot DH parameters using the interface, which is achieved through the function NRC_SetRobotDHConfig(NRC_RobotDHConfig config). Please note that when setting the DH parameters, the servo should be stopped or in a ready state. There are two ways to define this structure, please fill in the DH parameters according to the actual parameters of the robot.

struct NRC_RobotDHConfig
{
double L1; ///<L1 length
double L2; ///<L2 length
double L3; ///<L3 length
double L4; ///<L4 length
double L5; ///<L5 length
double L6; ///<L6 length
double L7; ///<L7 length
double theta; ///<Axis 5 direction, only valid for 6-axis robots, parameter options: 0, 90
double CoupleCoe12; ///<1/2 coupling ratio
double CoupleCoe23; ///<2/3 coupling ratio
double CoupleCoe32; ///<3/2 coupling ratio
double CoupleCoe34; ///<3/4 coupling ratio
double CoupleCoe45; ///<4/5 coupling ratio
double CoupleCoe46; ///<4/6 coupling ratio
double CoupleCoe56; ///<5/6 coupling ratio
double dynamicLimitMax; ///Dynamic limit maximum, suitable for 4-axis palletizing robots
double dynamicLimitMin; ///Dynamic limit minimum, suitable for 4-axis palletizing robots
double ConversionRatio2; ///Axis 2 conversion ratio
double ConversionRatio3; ///Axis 3 conversion ratio
double ConversionRatio4; ///Axis 4 conversion ratio
double Pitch = 0; ///scara lifter pitch
NRC_RobotDHConfig(double l1, double l2, double l3, double l4, double l5, double l6, double l7, double l8, double l9, double l10, double l11, double l12, double l13, double l14, double l15)
{
L1 = l1;
L2 = l2;
L3 = l3;
L4 = l4;
L5 = l5;
L6 = l6;
L7 = l7;
theta = l8;
CoupleCoe12 = l9;
CoupleCoe23 = l10;
CoupleCoe32 = l11;
CoupleCoe34 = l12;
CoupleCoe45 = l13;
CoupleCoe46 = l14;
CoupleCoe56 = l15;
dynamicLimitMax = 0;
dynamicLimitMin = 0;
ConversionRatio2 = 0;
ConversionRatio3 = 0;
ConversionRatio4 = 0;
Pitch = 0;
}
NRC_RobotDHConfig(double l1, double l2,double l3,double l4, double l5, double l6, double l7, double l8, double l9, double l10,double l11, double l12, double l13, double l14, double l15, double l16,double l17, double l18, double l19, double l20, double l21)
{
L1 = l1;
L2 = l2;
L3 = l3;
L4 = l4;
L5 = l5;
L6 = l6;
L7 = l7;
theta = l8;
CoupleCoe12 = l9;
CoupleCoe23 = l10;
CoupleCoe32 = l11;
CoupleCoe34 = l12;
CoupleCoe45 = l13;
CoupleCoe46 = l14;
CoupleCoe56 = l15;
dynamicLimitMax = l16;
dynamicLimitMin = l17;
ConversionRatio2 = l18;
ConversionRatio3 = l19;
ConversionRatio4 = l20;
Pitch = l21;
}
};

Robot joint parameter configuration

struct NRC_RobotJointConfig
{
double reducRatio; ///<Reduction ratio
int encoderResolution; ///<Encoder bits
double posSWLimit; ///<Axis positive limit, unit: degree
double negSWLimit; ///<Axis negative limit, unit: degree
double ratedRotSpeed; ///<Motor rated positive RPM, unit: rev/min
double ratedDeRotSpeed; ///<Motor rated reverse RPM, unit: rev/min
double maxRotSpeed; ///<Motor maximum positive RPM, as a multiple of the motor rated positive RPM, unit: multiple
double maxDeRotSpeed; ///<Motor maximum reverse RPM, as a multiple of the motor rated reverse RPM, unit: multiple
double maxAcc; ///<Maximum acceleration, as a multiple of the rated positive speed, unit: multiple, rated positive speed = Motor rated positive RPM/reduction ratio * 6
double maxDecel; ///<Maximum deceleration, as a multiple of the rated reverse speed, unit: multiple, rated reverse speed = motor rated reverse RPM/reduction ratio * 6
bool direction; ///<Direction, true: positive, false: reverse
};

In the configuration structure for setting robot joint parameters, the axis positive limit refers to the maximum range in the positive direction of the joint, while the axis negative limitrefers to the maximum range in the negative direction of the joint (this value must be a negative number).

Same as the robot DH parameter configuration, use the structure class NRC_RobotJointConfig to define an object config, and write in the appropriate parameters.

Call the function NRC_SetRobotJointConfig(int axisNum, NRC_RobotJointConfig config) to set the robot joint parameters. The parameter "axisNum" is the number of the axis to be set, with a range of 1 <= axisNum <= the total number of robot axes. For the parameter configuration, please refer to the function NRC_RobotJointConfig. It is important to note that the joint parameters should be set when the servo is in a stopped or ready state.

When filling in the joint parameters, set the joint limit of each axis according to the actual working environment. Set the limit of each joint from -9999 to 9999, and then jog each axis of the robot individually to check whether the positive direction of each axis of the robot is correct.

Robot Cartesian parameter configuration

struct NRC_RobotDecareConfig
{
double maxVel; ///<Maximum velocity, unit: mm/s
double maxAcc; ///<Maximum acceleration, as a multiple of the maximum velocity, unit: multiple
double maxDec; ///<Maximum deceleration, as a multiple of the maximum velocity, unit: multiple
};

Same as the robot DH parameter configuration, use the structure class NRC_RobotDecareConfig to define an object config, and write in the appropriate parameters.

Call the function NRC_SetRobotDecareConfig(NRC_RobotDecareConfig config) to set the robot cartesian parameters. For the parameter configuration, please refer to the function NRC_RobotDecareConfig. It is important to note that the robot cartesian parameters should be set when the servo is in a stopped or ready state.

Robot range limit configuration

struct NRC_RobotRangeLimit
{
bool enableMaxX; ///<Enable X+ limit
double maxX; ///<X+ limit
bool enableMinX; ///<Enable X- limit
double minX; ///<X- limit
bool enableMaxY; ///<Enable Y+ limit
double maxY; ///<Y+ limit
bool enableMinY; ///<Enable Y- limit
double minY; ///<Y- limit
bool enableMaxZ; ///<Enable Z+ limit
double maxZ; ///<Z+ limit
bool enableMinZ; ///<Enable Z- limit
double minZ; ///<Z- limit
};

The robot range limit is used to limit the motion range of the robot in all states. There are two ways to set it up: "Manual filling" and "Calibration":

​ (1) When setting the range using the manual filling method, the maximum and minimum coordinate values that the robot can move on the X, Y, and Z axes can be set after clicking the "Modify" button.

​ (2) When setting the range using the range calibration method, you can move the robot and click the "Calibrate MX" and "Calibrate mX" buttons on the interface to record the value of the axis in the current robot position, making it the maximum and minimum value for that axis in its range of motion.

Same as the robot DH parameter configuration, use the structure class NRC_RobotRangeLimit to define an object range, and write in the appropriate parameters.

Call the function NRC_SetRobotRangeLimit(NRC_RobotRangeLimit range) to set the robot range limit. For the parameter configuration, please refer to the function NRC_RobotRangeLimit. This parameter also needs to be set when the servo is in a stopped or ready state.

Call the function NRC_SetAbsolutePosResolution(double resolution) to set the absolute position resolution of the robot. The parameter "resolution" is the resolution of the robot's absolute position. When the difference between two positions is less than this value, the robot will consider these two positions as the same position. The unit is degree, and the parameter range is 0.0001 <= sensitivity <= 0.1. It should be noted that this parameter should be set when the servo is in a stopped or ready state.

#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
void SettingofRobotRelatedParameters()
{
NRC_RobotDHConfig robotDHConfig = {321.5, 270,70,299, 78.5, 50, 0, 90, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};//DH parameter configuration
NRC_SetRobotDHConfig(robotDHConfig );//Set DH parameter configuration
NRC_RobotJointConfig robotJointConfig = {76.5, 17, 180, -180, 3000, -3000, 1, -1, 5, -5,1,1};//Joint parameter configuration
for (int i=1; i<7; i++)
{
NRC_SetRobotJointConfig(i,robotJointConfig );
}//Set joint parameter configuration
NRC_RobotRangeLimit robotRangeLimit = { true, 1000, true, -500, false, 300, true, -1000, false, 0, false, 3000 };//Range limit configuration
NRC_SetRobotRangeLimit(robotRangeLimit);//Set robot range limit
NRC_RobotDecareConfig robotDecareConfig = {1000, 3, -3};//Cartesian parameter configuration
NRC_SetRobotDecareConfig(robotDecareConfig);//Set Cartesian parameter configuration
}
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, for program simplicity, adopt a call form
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}