Skip to main content

Run fileless instruction

Create, run, pause, and delete run queues

Create

Before inserting the fileless instruction, first call the function NRC_CreateNoFlieRunqueue() to create a fileless run queue. Then, after calling relevant functions for inserting instructions into the run queue, call the NRC_StartRunNoFlieRunqueue() function to execute the run queue containing one or multiple instructions.

Run

Call the function NRC_StartRunNoFlieRunqueue() to start running the fileless run queue. After starting running, if you want to add a new run instruction, please recreate a fileless run queue after the end of this run. After this function is successfully called, the robot will start moving. Please pay attention to safety.

Pause

Call the function NRC_PauseRunNoFlieRunqueue() to pause the fileless run queue. Calling NRC_StartRunNoFlieRunqueue(); will resume the execution.

Stop

Call the function NRC_StopRunNoFlieRunqueue() to stop running the fileless run queue. After stopping, unlike pausing the fileless run queue, if you want to continue running, please recreate a fileless run queue.

Stop without powering off

Call the function NRC_StopRunNoFlieRunqueueNotPoweroff() to stop running the fileless run queue without powering off. After stopping, if you want to continue running, please recreate a fileless run queue.

The line number of the currently executing instruction in the run queue

Call the function NRC_GetRunqueueCurrentRunLine() to get the line number of the currently executing instruction in the run queue. This function will return the line number of the currently executing instruction in the run queue.

Insert motion control instructions in the run queue

Insert MOVJ

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. 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_RunqueueInsertMOVJ(int vel, int acc, int dec, const NRC_Position& target, int pl=0) to insert the MOVJ instruction in the run queue.

  • The parameter "vel" is the running speed of the robot, expressed as a percentage of the maximum speed of the robot. The range of the parameter is 0 < vel <= 100
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint of the robot. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint of the robot. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5.

Insert MOVL

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. 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_RunqueueInsertMOVL(int vel, int acc, int dec, const NRC_Position& target, int pl=0) to insert the MOVL instruction in the run queue.

  • The parameter 'vel' represents the running speed of the robot, which is the absolute running speed of the robot TCP, with the unit of millimeters per second (mm/s). The range of the parameter is vel > 1.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint of the robot. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint of the robot. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5.

Insert MOVC

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. Call the function NRC_RunqueueInsertMOVC(int vel, int acc, int dec, const NRC_Position& target,int pl = 0) to insert the MOVC instruction in the run queue.

  • The parameter 'vel' represents the running speed of the robot, which is the absolute speed of the robot TCP, with the unit of millimeters per second (mm/s). The range of the parameter is vel > 1.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint of the robot. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint of the robot. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5.

Example of inserting MOVC instruction in the run queue:

//Go through pos1 and reach pos2 by means of circular interpolation at a speed of 100mm/s
NRC_RunqueueInsertMOVC(100,50,50,pos1, 0);
NRC_RunqueueInsertMOVC(100,50,50,pos2, 0);

Insert IMOV

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. The IMOV instruction is to move from the current position according to the set incremental distance in the way of joint or linear interpolation. Call the function NRC_RunqueueInsertIMOV(int vel, int acc, int dec, const NRC_Position& deviation, int pl=0) to insert the IMOV instruction in the run queue. When the deviation.coord is NRC_ACS, the instruction will use the joint interpolation method, and when the deviation.coord is other values, the linear interpolation method will be used.

  • The parameter "vel" is the running speed of the robot. When the deviation.coord is NRC_ACS, it is a percentage of the robot's maximum speed with a range of 0 < vel <= 100. When the deviation.coord is not NRC_ACS, it is the absolute running speed of the robot TCP in millimeters per second (mm/s), with a range of vel > 1.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint of the robot. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint of the robot. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5.

Insert input and output instructions in the run queue

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. In order to make a digital output port output a certain state, realize the corresponding control. Call the function NRC_RunqueueInsertDOUT(int port, int value) to insert the DOUT instruction in the run queue. The parameter "port" indicates the number of the digital output port to output the level, and the range of the parameter is port > 0. The parameter "value" indicates the port output status, return value 0 means low level, and the return value 1 means high level.

Insert timing instructions in the run queue

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. Sometimes the execution process of the program in the run queue needs to be delayed for a certain period of time, then you can call the function NRC_RunqueueInsertTIMER(double timeSec) to insert the TIMER instruction in the run queue. The parameter "timeSec" indicates the time to be delayed, the unit is seconds, and the parameter range is timeSec > 0.

Insert conditional control instructions in the run queue

Insert WAIT

Before calling this function, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. If you want to determine the waiting time by detecting the input state of a certain digital input port, you can insert the WAIT instruction into the run queue by calling the function NRC_RunqueueInsertWAIT( int port, int value, double timeoutSec, bool now=false).

  • The parameter "port" represents the digital input port number to be detected, and the parameter range is port > 0.
  • The parameter "value" indicates the input state to wait for, the return value 0 means low level, and the return value 1 means high level.
  • The parameter "timeoutSec" represents the timeout duration in seconds, with a parameter range of "timeoutSec >= 0". If the requirement is not met after waiting for "timeoutSec" seconds, the instruction will stop waiting and end. If the value is 0, it will wait indefinitely until the condition is met.

Insert UNTIL, ENDUNTIL

Before calling these two functions, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. Call the function NRC_RunqueueInsertUNTIL( int port, int value) to insert the UNTIL instruction in the run queue. The parameter "port" represents the digital input port number to be detected, and the parameter range is port > 0. The parameter "value" indicates the input state to wait for, the return value 0 means low level, and the return value 1 means high level. This function needs to be used in conjunction with NRC_RunqueueInsertENDUNTIL().

Call the function NRC_RunqueueInsertENDUNTIL() to insert the ENDUNTIL instruction in the run queue. This function needs to be used in conjunction with NRC_RunqueueInsertUNTIL( int port, int value).

Example of inserting UNTIL instruction in the run queue:

The functions that need to be called are as follows:

//While running between UNTIL and ENDUNTIL, if the condition of UNTIL is met, the program will immediately interrupt the current running instruction and jump to ENDUNTIL for execution.
NRC_RunqueueInsertUNTIL(5,1);
NRC_RunqueueInsertMOVJ(100,50,50,pos1,0);
NRC_RunqueueInsertMOVL(100,50,50,pos2,0);
NRC_RunqueueInsertDOUT(1,0);
NRC_RunqueueInsertTIMER(0.5);
NRC_RunqueueInsertENDUNTIL();

Insert IF, ELSE, ENDIF

Before calling these three functions, please call NRC_CreateNoFlieRunqueue() to create a fileless run queue. Call the function NRC_RunqueueInsertIF( int port, int value) to insert the IF instruction in the run queue. The parameter "port" represents the digital input port to be detected, and the parameter range is port > 0. The parameter "value" indicates the input state to wait for, the return value 0 means low level, and the return value 1 means high level. This function needs to be used in conjunction with NRC_RunqueueInsertENDIF().

Call the function NRC_RunqueueInsertELSE() to insert the ELSE instruction in the run queue. This function needs to be used in conjunction with NRC_RunqueueInsertIF( int port, int value);NRC_RunqueueInsertENDIF().

Call the function NRC_RunqueueInsertENDIF() to insert the ENDIF instruction in the run queue. This function needs to be used in conjunction with NRC_RunqueueInsertIF( int port, int value).

Example of inserting IF instruction in the run queque:

//If the IF condition is met, execute the IF code block, otherwise execute the ELSE code block; if there is no ELSE instruction and the IF condition is not met, the IF code block will be skipped, and the instruction after ENDIF will be executed directly
NRC_RunqueueInsertIF(5,1);
NRC_RunqueueInsertMOVJ(100,50,50,pos1,0);
NRC_RunqueueInsertDOUT(1,0);
NRC_RunqueueInsertELSE();
NRC_RunqueueInsertMOVL(100,50,50,pos2,0);
NRC_RunqueueInsertTIMER(0.5);
NRC_JobfileInsertENDIF();

Insert instruction data in the run queue

Insert a set of instruction data into the run queue by calling the function NRC_InsertNoFlieRunqueue(std::vector<NRC_InstrDataBase*>& instrVec), and the parameter "instrVec" is a set of instruction data to be inserted.

Example std::vector<NRC_InstrDataBase*> instrVec//You don't need to create a queue, it will be created automatically

instrVec.push_back(new NRC_InstrDataMOVJ(50,50,50, pos1, 5));
instrVec.push_back(new NRC_InstrDataMOVL(30,50,50, pos2, 2));
instrVec.push_back(new NRC_InstrDataMOVC(20, 50,50,pos0, 3));
instrVec.push_back(new NRC_InstrDataMOVC(20,50,50, pos1, 3));
NRC_InsertNoFlieRunqueue(instrVec);
//They can be divided into multiple groups and inserted in separate batches, with the later insertions being appended after the previous ones
instrVec.clear();
instrVec.push_back(new NRC_InstrDataIMOV(40,50,50, dev1, 0));
instrVec.push_back(new NRC_InstrDataDOUT(5, 1));
instrVec.push_back(new NRC_InstrDataTIMER(3.3));
instrVec.push_back(new NRC_InstrDataWAIT(new NRC_ConditionJudge(NRC_ConditionJudge::INT_, 3, NRC_ConditionJudge::LESS, NRC_ConditionJudge::DOUBLE_, 5), 2.2));
instrVec.push_back(new NRC_InstrDataWAIT(new NRC_ConditionJudge(NRC_ConditionJudge::DIN_, 2, NRC_ConditionJudge::EQUAL_TO, NRC_ConditionJudge::CONST_, 1), 0));
instrVec.push_back(new NRC_InstrDataMOVJ(30,50,50, pos1, 1));
NRC_InsertNoFlieRunqueue(instrVec);
//Start executing the queue
NRC_StartRunNoFlieRunqueue();
#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
SettingofRobotRelatedParameters();//Robot-related parameter settings, see section 3.6 for details
NRC_SetServoReadyStatus(1);//Set servo ready status, see section 3.8 for details
NRC_SetInterpolationMethod(1);//Set to S-shaped interpolation, see section 3.12 for details
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 (using the new version of definition)
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.0000 };
double pos3[7] = { 315.4386, 21.1369, 595.0522, 3.1006, 0.1196, -0.4678,0.0000 };
double pos4[7] = { 315.6836, -16.5291, 595.0751, 3.0866, 0.1140, -0.3479,0.0000 };
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 };
double devPos1[7] = { 10, 20, -10, 10, 0, 0 };
double devPos2 [7]= { -50, 50, 10, 0, 0, 0.1 };
NRC_Position dev1 = { NRC_ACS,0,0,0,devPos1}; //Set the deviation of dev1
NRC_Position dev2 = { NRC_MCS,0,0,0,devPos2 }; //Set the deviation of dev2
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
//Motion queue
NRC_ServoEnable() ;//Servo power on
NRC_CreateNoFlieRunqueue();//Create a fileless run queue
NRC_RunqueueInsertDOUT(3, 1);//Digital output port 3 outputs high level
NRC_RunqueueInsertMOVJ(50,50,50, inexbot1, 4);//Move to inexbot1 in a point-to-point manner
NRC_RunqueueInsertMOVC(300,50,50, inexbot2, 5);
NRC_RunqueueInsertMOVC(300,50,50, inexbot3, 5);//Move from inexbot2 to inexbot3 in a circular arc
NRC_RunqueueInsertMOVL(500,50,50, inexbot4, 1);//Move to inexbot4 in a straight line
NRC_RunqueueInsertWAIT(3, 1, 3.3);//Wait for the digital input port 3 to input a high level, if the condition is still not met after 3.3 seconds, the instruction ends
NRC_RunqueueInsertTIMER(5.5);//Delay 5.5s
NRC_StartRunNoFlieRunqueue();//Start running the fileless run queue
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(100); //Delay 100ms
printf("line=%d,time=%d\n",NRC_GetRunqueueCurrentRunLine(),NRC_GetCycleTimeSec());
}
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,,%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
//While running between UNTIL and ENDUNTIL, if the condition of UNTIL is met, the program will immediately interrupt the current running instruction and jump to ENDUNTIL for execution
NRC_ServoEnable() ;//Servo power on
NRC_CreateNoFlieRunqueue();
NRC_RunqueueInsertUNTIL(5, 1);
NRC_RunqueueInsertMOVJ(50,50,50, inexbot1, 4);//Move to inexbot1 in a point-to-point manner
NRC_RunqueueInsertMOVC(100,50,50, inexbot2, 0);
NRC_RunqueueInsertMOVC(100,50,50, inexbot3, 0);//Move from inexbot2 to inexbot3 in a circular arc
NRC_RunqueueInsertDOUT(1, 0);//Digital output port 1 outputs low level
NRC_RunqueueInsertTIMER(0.5);//Wait 0.5s
NRC_RunqueueInsertENDUNTIL();
NRC_StartRunNoFlieRunqueue();//Start running the fileless run queue
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(100); //Delay 100ms
printf("line=%d,time=%d\n",NRC_GetRunqueueCurrentRunLine(),NRC_GetCycleTimeSec());
}
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
//If the IF condition is met, execute the IF code block, otherwise execute the ELSE code block; if there is no ELSE instruction and the IF condition is not met, the IF code block will be skipped, and the instruction after ENDIF will be executed directly
NRC_ServoEnable() ;//Servo power on
NRC_CreateNoFlieRunqueue();//Create a fileless run queue
NRC_RunqueueInsertIF(5, 1);//When the digital input port 5 inputs high level, the condition is met
NRC_RunqueueInsertMOVJ(100,50,50, inexbot1, 0);//Move to inexbot1 in a point-to-point manner
NRC_RunqueueInsertDOUT(1, 0);//Digital output port 1 outputs low level
NRC_RunqueueInsertELSE();//Execute the following instructions when the condition is not met
NRC_RunqueueInsertMOVJ(100,50,50, inexbot4, 0);//Move to inexbot4 in a point-to-point manner
NRC_RunqueueInsertTIMER(0.5);//Wait 0.5s
NRC_RunqueueInsertENDIF();
NRC_RunqueueInsertIMOV(50,50,50, dev1, 3);//Robot motion deviation
NRC_RunqueueInsertIMOV(500,50,50, dev2, 0);//Robot motion deviation
NRC_StartRunNoFlieRunqueue();//Start running the fileless run queue
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(100); //Delay 100ms
printf("line=%d,time=%d\n",NRC_GetRunqueueCurrentRunLine(),NRC_GetCycleTimeSec());
}
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot7;//Define the robot position structure object inexbot7
NRC_GetCurrentPos(NRC_MCS, inexbot7);//Assign the Cartesian coordinate system of the current robot to inexbot7
printf("inexbot7.pos=%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]);//Output the current Cartesian coordinate position
//Insert a set of instruction data into the run queue, the parameter "inexbot" is a set of instruction data to be inserted
NRC_ServoEnable() ;//Servo power on
std::vector<NRC_InstrDataBase*>inexbot;//Define the instance "inexbot" of the vector class
inexbot.push_back(new NRC_InstrDataMOVJ(100,50,50, inexbot1, 5));//Move to inexbot1 in a point-to-point manner
inexbot.push_back(new NRC_InstrDataIF(new NRC_ConditionJudge(NRC_ConditionJudge::INT_, 2, NRC_ConditionJudge::EQUAL_TO, NRC_ConditionJudge::CONST_, 5)));
inexbot.push_back(new NRC_InstrDataMOVC(50,50,50,inexbot3, 3));
inexbot.push_back(new NRC_InstrDataMOVC(50,50,50, inexbot4, 3));//Move from inexbot3 to inexbot4 in a circular arc
inexbot.push_back(new NRC_InstrDataELSE());
inexbot.push_back(new NRC_InstrDataMOVL(100,50,50,inexbot2, 2));//Move to inexbot2 in a straight line
inexbot.push_back(new NRC_InstrDataENDIF());
NRC_InsertNoFlieRunqueue(inexbot);//Insert instruction data into a fileless run queue
NRC_StartRunNoFlieRunqueue();//Start running the fileless run queue
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(100); //Delay 100ms
}
NRC_Delayms(1000);
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot8;//Define the robot position structure object inexbot8
NRC_GetCurrentPos(NRC_MCS, inexbot8);//Assign the Cartesian coordinate system of the current robot to inexbot8
printf("inexbot8.pos=%f,%f,%f,,%f,%f,%f,%f,\n",inexbot8.pos[0],inexbot8.pos[1],inexbot8.pos[2],inexbot8.pos[3],inexbot8.pos[4],inexbot8.pos[5],inexbot8.pos[6]);//Output the current Cartesian coordinate position
inexbot.clear();
inexbot.push_back(new NRC_InstrDataDOUT(5, 1));//Digital output port outputs high level
inexbot.push_back(new NRC_InstrDataWAIT(new NRC_ConditionJudge(NRC_ConditionJudge::DIN_,5,NRC_ConditionJudge::EQUAL_TO,NRC_ConditionJudge::CONST_, 0), 5));
inexbot.push_back(new NRC_InstrDataTIMER(5));
inexbot.push_back(new NRC_InstrDataMOVJ(30,50,50, inexbot1, 1));//Move to inexbot1 in a point-to-point manner
NRC_InsertNoFlieRunqueue(inexbot);//Insert instruction data into a fileless run queue
NRC_StartRunNoFlieRunqueue();//Start running the fileless run queue
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(100); //Delay 100ms
}
NRC_Delayms(1000);//Delay 1000ms
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot10;//Define the robot position structure object inexbot10
NRC_GetCurrentPos(NRC_MCS, inexbot10);//Assign the Cartesian coordinate system of the current robot to inexbot10
printf("inexbot10.pos=%f,%f,%f,,%f,%f,%f,%f,\n", inexbot10.pos[0], inexbot10.pos[1], inexbot10.pos[2], inexbot10.pos[3], inexbot10.pos[4], inexbot10.pos[5],inexbot10.pos[6]);//Output the current Cartesian coordinate position
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}