Skip to main content

Robot direct trajectory movement (point to point, linear, circular)

Motion class instructions

Point to point

Move to the target point using joint interpolation. This instruction is used in the section where the robot is not constrained by trajectory in moving to the target point.

Call the function NRC_RobotMoveJoint(int vel, const NRC_Position& target int acc, int dec) to make the robot perform PTP motion. Before calling this function, please power on the servo by using the NRC_ServoEnable() function, as described in section 3.8. Once this function is successfully called, the robot will start moving. Please pay attention to safety.

  • "vel" represents the operating speed of a robot, expressed as a percentage of its maximum speed. The parameter range is 0 < vel <= 100.
  • "target" refers to the desired position of a robot's movement, as specified in NRC_Position.
  • The parameters "acc" and "dec" represent the acceleration and deceleration of a robot's motion, respectively. They are expressed as a percentage of the maximum acceleration and deceleration values for each joint of the robot. The valid range for these parameters is 0 < acc/dec <= 100.

Point-to-point (PTP) motion is a commonly used form of motion where the target position is given through the API interface provided by inexbot. The motion control module performs relevant speed curve planning according to relevant parameters.

You can call the function NRC_GetProgramRunStatus() to detect whether the program has finished running.

Linear

Move to the target point using linear interpolation. During the robot's movement to the target point, the end effector's attitude remains unchanged. Call the function NRC_RobotMoveLinear(int vel, const NRC_Position& target, int acc, int dec) to make the robot perform linear motion. Before calling this function, please power on the servo by using the NRC_ServoEnable() function, as described in section 3.8. The robot will move at a velocity of 'vel' from its current position to the target position in a straight line. Once this function is successfully called, the robot will start moving. Please pay attention to safety.

  • "vel" is the operating speed of the robot, which is the absolute operating speed of the robot TCP, in mm/s. The parameter range is vel > 1.
  • "target" refers to the desired position of a robot's movement, as specified in NRC_Position.
  • The parameters "acc" and "dec" represent the acceleration and deceleration of a robot's motion, respectively. They are expressed as a percentage of the maximum acceleration and deceleration values for each joint of the robot. The valid range for these parameters is 0 < acc/dec <= 100.

Circular

Circular motion can be implemented using job files (or through fileless run queues), see section 3.13 for details.

Interpolation method

The interpolation method for the robot's motion can be set by calling the function NRC_SetInterpolationMethod(int method). The parameter "method" represents the interpolation method, where a value of 0 indicates S-curve interpolation. In this mode, the robot's acceleration and deceleration are smoother, but relatively slower compared to trapezoidal interpolation. This method is commonly used for larger robots. A value of 1 represents trapezoidal interpolation, where the robot's acceleration and deceleration are faster, but it may lead to issues like robot jitter or overload. This method is typically used for smaller robots. It is important to note that this parameter should be set when the servo is stopped or in a servo-ready state.

C++ demo program for robot point-to-point, linear, and circular motion

#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
int main()
{
SystemStartup();//System startup, see section 3.3 for details
SetServoMap();//Set the servo mapping relationship, see section 3.5 for details
SettingofRobotRelatedParameters();//Robot-related parameter settings, 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_SetInterpolationMethod(1);//Set to S-shaped interpolation method
NRC_SetOperationMode(NRC_RUN_);//Set the operation mode to run mode, see section 3.11 for details
NRC_SetAutoRunSpeedPer(80);//Set the auto-run speed to 80, see section 3.11 for details
NRC_Delayms(1000);//Delay 1000ms
//Set four points (in the latest API, the length of NRC_Position.pos is increased from 6 to 7)
double pos1[7]={ 296.71, -66.12, 606.38, 3.06, 0.15, -0.18,0.00} ;
double pos2[7]={ 303.3191, 20.0862, 606.3863, 3.1038, 0.1630, -0.4658,0.000};
double pos3[7]={ 315.4386, 21.1369, 595.0522, 3.1006, 0.1196, -0.4678,0.000};
double pos4[7]={ 315.6836, -16.5291, 595.0751, 3.0866, 0.1140, -0.3479,0.000};
NRC_Position inexbot1 = { NRC_MCS,0,0,0,pos1};
NRC_Position inexbot2 = { NRC_MCS,0,0,0,pos2};
NRC_Position inexbot3 = { NRC_MCS,0,0,0,pos3};
NRC_Position inexbot4= { NRC_MCS,0,0,0,pos4};
//Point to 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_ServoEnable();//Servo power on
NRC_RobotMoveJoint(50, inexbot1,80,80); //Move to inexbot1 using point-to-point method at a speed of 50%
while (NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(500); //Delay 100ms
}
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot6;//Define the robot position structure object inexbot6
NRC_GetCurrentPos(NRC_MCS, inexbot6);//Assign the Cartesian coordinate system of the current robot to inexbot6
printf("inexbot6.pos=%f,%f,%f,%f,%f,%f,%f,\n",inexbot6.pos[0],inexbot6.pos[1],inexbot6.pos[2],inexbot6.pos[3],inexbot6.pos[4],inexbot6.pos[5],inexbot6.pos[6]);//Output the current Cartesian coordinate position
//Linear
NRC_ServoEnable();//Servo power on
NRC_RobotMoveLinear(50, inexbot2,80,80); //Move linearly to inexbot2 at a speed of 50mm/s
while (NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(100); //Delay 100ms
}
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot5;//Define the robot position structure object inexbot5
NRC_GetCurrentPos(NRC_MCS, inexbot5);//Assign the Cartesian coordinate system of the current robot to inexbot5
printf("inexbot5.pos=%f,%f,%f,s%f,%f,%f%f,\n",inexbot5.pos[0],inexbot5.pos[1],inexbot5.pos[2],inexbot5.pos[3],inexbot5.pos[4],inexbot5.pos[5],inexbot5.pos[6]);//Output the current Cartesian coordinate position

//Circular motion can be implemented using job files (or through fileless run queues), see section 3.13 for details
if (NRC_JudgeJobIsExist("INEXBOT1") == 0)
{
cout << "Job file does not exist" << endl;
NRC_CreateJobfile("INEXBOT1");//Create job file INEXBOT1
}
else
NRC_OpenJobfile("INEXBOT1");//Open job file INEXBOT1
NRC_JobfileInsertMOVL(1, 500, 50, 50, inexbot2, 1);
NRC_JobfileInsertMOVC(2, 300, 50, 50, inexbot3, 5);
NRC_JobfileInsertMOVC(3, 300, 50, 50, inexbot4, 5);//The robot moves from inexbot3 to inexbot4 in a circular arc
cout << "file line sum is " << NRC_GetJobfileLineSum() << endl;
NRC_ServoEnable(); //Servo power on
NRC_StartRunJobfile("INEXBOT1");//Start running the job file
while (NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(500); //Delay 100ms
printf("line=%d,time=%d\n",
NRC_GetJobfileCurrentRunLine(), NRC_GetCycleTimeSec());
}//Get the line number of the currently running job file, get the running time of the current job file
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot9;//Define the robot position structure object inexbot9
NRC_GetCurrentPos(NRC_MCS, inexbot9);//Assign the Cartesian coordinate system of the current robot to inexbot9
printf("inexbot9.pos=%f,%f,%f,%f,%f,%f%f,\n",inexbot9.pos[0],inexbot9.pos[1],inexbot9.pos[2],inexbot9.pos[3],inexbot9.pos[4],inexbot9.pos[5],inexbot9.pos[6]);//Output the current Cartesian coordinate position
while (1)//Keep the program running
{
NRC_Delayms(1000);
}
}