#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
void msgHook() {
NRC_Messsage tmp;
NRC_GetMesssage(1, 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);
}
void SystemStartup()
{
std::string NRC_GetNexMotionLibVersion();
cout << "库版本:" << NRC_GetNexMotionLibVersion() << endl;
NRC_StartController();
while (NRC_GetControlInitComplete() != 1)
{
NRC_Delayms(100);
}
NRC_ClearAllError();
cout << "StartController Success" << endl;
NRC_Delayms(200);
NRC_SetMsgHappenCallback(msgHook);
}
void SetServoMap()
{
std::vector<int> servoMap = {0,0,0,0,0,0};
int syncGroupNum = 1;
int syncType[]={0,0,0};
std::vector<std::vector<int>> syncServoMap={{0,0},{0,0},{0,0}};
NRC_SetAllServoMapRelation(servoMap,syncGroupNum, syncType, syncServoMap);
}
void SettingofRobotRelatedParameters()
{
NRC_RobotDHConfig robotDHConfig = {321.5, 270,70,299, 78.5, 50, 0, 90, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
NRC_SetRobotDHConfig(robotDHConfig );
NRC_RobotJointConfig robotJointConfig = {76.5, 17, 180, -180, 3000, -3000, 1, -1, 5, -5,1,1};
for (int i=1; i<7; i++)
{
NRC_SetRobotJointConfig(i,robotJointConfig );
}
NRC_RobotRangeLimit robotRangeLimit = { true, 1000, true, -500, false, 300, true, -1000, false, 0, false, 3000 };
NRC_SetRobotRangeLimit(robotRangeLimit);
NRC_RobotDecareConfig robotDecareConfig = {1000, 3, -3};
NRC_SetRobotDecareConfig(robotDecareConfig);
}
void RobotMsg()
{
int ioNum;
std::string type1,type2;
cout<<"机器人轴数:"<<NRC_GetRobotAxisSum()<<endl;
cout<<"外部轴数"<<NRC_GetSyncAxisSum()<<endl;
NRC_GetEthercatIOConfig(ioNum, type1, type2);
cout<<"扩展板数:"<<ioNum<<endl;
if(ioNum>0)
{
cout<<"扩展板类型:"<<type1<<" ,"<<type2<<endl;
}
}
void flicker(int j)
{
for (int i=j; i>0; i--)
{
NRC_DigOut(2, 1);
NRC_Delayms(1000);
NRC_DigOut(2, 0);
NRC_Delayms(1000);
}
}
int main()
{
SystemStartup();
RobotMsg();
SetServoMap();
SettingofRobotRelatedParameters();
}