Other operations and status viewing during program execution
(1) Call the function NRC_GetCurrentInstrRestPosNum()
to get the remaining point number of the current running instruction. The return value is the remaining point number of the current running instruction. It should be noted that when the instruction has not been calculated, the return value is -1.
(2) Call the function NRC_SetCompleteOneInstrCallBack(void (*fun)(void))
to set the callback function to be called when one instruction is completed. When one instruction is completed, this callback function will be called. The parameter "fun" is the function pointer of the callback function. The callback function should not contain time-consuming operations, otherwise it will seriously affect the program's execution.
Example usage of callback function interface:
void msgHook()
{
NRC_Messsage tmp;//Define a message structure object
NRC_GetMesssage(1, tmp);//Assign the earliest message in the message queue to the object tmp
printf("msgHook localTime=%d:%d::%d, 0x%x,0x%x,text=%s,size=%d\n",tmp.localTime.minute, tmp.localTime.second,tmp.localTime.milliseconds,tmp.kind,tmp.type,tmp.text.c_str(),NRC_GetMesssageSize()
);
NRC_Delayms(200);
}
int main()
{
NRC_SetCompleteOneInstrCallBack(msgHook);
}
The message structure is:
struct NRC_Messsage
{
NRC_TIME localTime;///<System time when the message was generated
int kind; ///<Message level: 0: general message, 1: warning message, 2: error message, 3: important message
int code;///<Message code
int robot;///<Robot number
std::vector<int> param;///<Message content parameters, the number varies depending on the specific encoding, a total of 5 are reserved
std::string text;///<Message content
};
(3) Call the function NRC_GetProgramRunStatus()
to get the current running status of the program. The return value represents the current program running status of the robot: retval = 0 means the program is stopped, retval = 1 means the program is paused, retval = 2 means the program is running. This function can be used in conjunction with the loop function to wait for the program to finish running.
(4) Call the function int NRC_ModifyControllerIP(std::string name,std::string ip,std::string gateway,std::string dns)
to modify the controller's IP. The target IP should conform to the IP naming rules.
When restoring factory settings using the function NRC_RestoreFactorySettings()
, it is important to note that the controller will immediately restart. After restoring factory settings, all data in the controller will be cleared, so please use this function with caution.
(5) Call the function NRC_GetCurrentmMtorVel(double vel[])
to get the motor speed. The parameter "vel" is the motor speed, which will be returned through an array. The number of array elements should not be less than the number of robot axes.
Example usage of the motor speed interface function:
............
double vel[6];
NRC_GetCurrentmMtorVel( vel);
for(int i=0;i<6;i++)
{
cout<<"The motor speeds are:"<< vel[i]<< endl;
}
............