Skip to main content

Append mode related

Turn on append mode

Turn on the append run mode by calling the function NRC_OpenInstrAppendRunMode(). After turning on the append run mode, add the run queue to run directly in response. After successfully calling this function, the robot is automatically powered on, so please pay attention to safety. The append run mode can only be enabled when the servo is in the ready state, i.e. NRC_GetServoStatus() == 1.

If servo error, run error or parse error occurs in the append run mode, the robot will automatically exit the append run mode and power off. If you switch between teach and auto mode in the append run mode, the robot will automatically exit the append run mode and power off.

Turn off append mode

Turn off the append run mode by calling the function NRC_CloseInstrAppendRunMode(). After a successful call to this function, the robot will automatically power off. The append run mode can only be turned off if there is no run queue or if the entire run queue has been run, i.e. when NRC_GetProgramRunStatus() == 0.

Get the remaining number of append run

Call the function NRC_GetRestAppendInstrNum() to get the current number of remaining instructions for the append run. The return value is the current number of remaining instructions. It should be noted that for MOVC instructions, two are a pair, and when inserting instructions, two are inserted, but when running, it is recorded as one.

Add motion queue in append mode

Call the function NRC_AppendRunInstr(std::vector<NRC_InstrDataBase*>& instrVec) to add a run queue in append run mode. The parameter instrVec is a set of instruction data to be inserted. After adding the run queue, the robot will immediately execute the added queue, so please be careful. The added run queue can only be robot movement instructions.

Example: Turn on the append run mode, and the robot is automatically powered on

NRC_OpenInstrAppendRunMode();
std::vector<NRC_InstrDataBase*> instrVec;
instrVec.push_back(new NRC_InstrDataMOVJ(50, 50,50,pos1, 5));
instrVec.push_back(new NRC_InstrDataMOVL(30, 50,50,pos2, 2));
//After adding the queue, the robot runs directly
NRC_AppendRunInstr(instrVec);
......
instrVec.clear();
instrVec.push_back(new NRC_InstrDataMOVC(20,50,50, pos0, 3));
instrVec.push_back(new NRC_InstrDataMOVC(20,50,50, pos1, 3));
//After the robot finishes running the queue added before, it will continue to run the queue added this time
NRC_AppendRunInstr(instrVec);
......
NRC_PauseInstrAppendRun();//Pause
......
instrVec.clear();
instrVec.push_back(new NRC_InstrDataMOVJ(50,50,50, pos1, 5));
instrVec.push_back(new NRC_InstrDataMOVL(30,50,50, pos2, 2));
The queue added during pause can also run normally after calling restart
NRC_AppendRunInstr(instrVec);
......
NRC_RestartInstrAppendRun();//Restart
......
Stop running, the robot stops, and all queues are cleared
NRC_StopInstrAppendRun();
Turn off the append run mode, and the robot is automatically powered off
NRC_CloseInstrAppendRunMode();

Call the function NRC_PauseInstrAppendRun() to pause the append run. After a successful call to this function, the robot will pause. Call NRC_RestartInstrAppendRun() to continue the run. The run queue added while paused will not run immediately, but will be put into a cache queue, which will be run only after calling restart.

Call the function NRC_RestartInstrAppendRun() to restart the append run. When the robot is about to pause, call this function to make the robot continue running.

Call the function NRC_StopInstrAppendRun() to stop the append run. After a successful call to this function, the robot will stop running, and all run queues will be cleared, if you continue to add run queues afterwards, the robot will run the added instructions directly.

Determine whether it is append mode

Call the function NRC_GetIsInstrAppendRunMode() to get whether the current mode is append mode or not. The return value indicates whether the current mode is append mode. retval = 0 means the current mode is not append mode, retval = 1 means the current mode is append mode.

#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
int main()
{
SystemStartup();//System startup, see section 3.3 for details
SetServoMap();//Set servo mapping relationship, see section 3.5 for details
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 S-shaped interpolation mode, 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 auto run speed to 80, see section 3.11 for details
NRC_Delayms(1000);//Delay 1000ms
//Set four points (using the new definition method)
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 };
NRC_OpenInstrAppendRunMode();//After the append mode is turned on, the motion queue can be run directly after being added
std::vector<NRC_InstrDataBase*>inexbot;//Automatically create queues
inexbot.push_back(new NRC_InstrDataMOVJ(50,50,50,inexbot1, 5));//Move to inexbot1 in a point-to-point manner
inexbot.push_back(new NRC_InstrDataMOVL(30,50,50, inexbot2, 2));//Move to inexbot2 in a straight line
std::vector<NRC_InstrDataBase*>inexbot6;
inexbot6.push_back(new NRC_InstrDataMOVJ(50,50,50,inexbot3, 5));//Move to inexbot3 in a point-to-point manner
inexbot6.push_back(new NRC_InstrDataMOVC(50,50,50,inexbot2, 5));
inexbot6.push_back(new NRC_InstrDataMOVC(50,50,50,inexbot1, 5));//Move to inexbot1 in a circular arc
NRC_AppendRunInstr(inexbot);//A set of instruction data to be inserted into the queue. After adding the queue, the robot runs directly.
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(1000); //Delay 1000ms
}
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,%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 current Cartesian coordinate position
inexbot.clear();
inexbot.push_back(new NRC_InstrDataMOVC(20,50,50, inexbot3, 3));
inexbot.push_back(new NRC_InstrDataMOVC(20,50,50, inexbot4, 3));//Move to inexbot4 in a circular arc
//After the robot finishes running the queue added before, it will continue to run the queue added this time
NRC_AppendRunInstr(inexbot);//A set of instruction data to be inserted into the queue. After adding the queue, the robot runs directly.
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(1000); //Delay 1000ms
}
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
NRC_AppendRunInstr(inexbot6);
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(1000); //Delay 1000ms
}
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

NRC_PauseInstrAppendRun();//Pause. The queue added during pause can also run normally after calling restart
inexbot6.clear();
inexbot6.push_back(new NRC_InstrDataMOVL(30,50,50, inexbot2, 2));//Move to inexbot2 using linear interpolation

NRC_AppendRunInstr(inexbot6);
NRC_RestartInstrAppendRun();//Restart
while(NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(1000); //Delay 1000ms
}
NRC_Position inexbot10;//Define the robot position structure object inexbot10
NRC_GetCurrentPos(NRC_MCS, inexbot10);//Assign the Cartesian coordinate position of the current robot to inexbot9
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
NRC_CloseInstrAppendRunMode();//Turn off the append run mode, and the robot is automatically powered off
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}