Servo enable and status view
Servo status refers to whether the servo driver is ready to drive the motor to perform robot actions. The servo status can be set by calling the function NRC_SetServoReadyStatus(int status)
, where status=0 means servo stop and status=1 means servo ready. Servo enable (servo power on) can be achieved by calling the function NRC_ServoEnable(). Servo enable can be achieved in both teach mode and run mode.
Call the function NRC_GetServoStatus()
to get the servo status, and the return value of the function indicates the servo status.
- retval=0 means servo stop
- retval=1 means servo ready
- retval = 2 means servo alarm
- retval=3 means servo running
Demo program for system servo enable and status view
#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
void msgHook() {
NRC_Messsage tmp; //Define a message structure object, see section 3.7 for details
NRC_GetMesssage(1, tmp); //Assign the earliest message in the message queue to the object tmp
printf("msgHooklocalTime=%d:%d::%d,0x%x,0x%x,0x%x,text=%s,size=%d\n",tmp.localTime.minute,tmp.localTime.second,tmp.localTime.milliseconds,tmp.kind,tmp.code,tmp.robot,tmp.text.c_str(),NRC_GetMesssageSize()); NRC_Delayms(200);
}
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 settings, see section 3.6 for details
//////The above call functions can be found in Appendix I/////
NRC_SetServoReadyStatus(1);//Set servo ready status
cout<< "Set servo ready successfully"<<endl;
int inexbot=NRC_GetServoStatus();
if(inexbot=0)cout<<"Servo stop";
else if(inexbot=1)cout<<"Servo ready";
else if(inexbot=2)cout<<"Servo alarm";
else cout <<"Servo running";
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}