跳到主要内容

当前位置获取

首先定义一个对象来接收位置的值。

NRC_Position inexbot

NRC_Position 在 nrcAPI.h 中可以查到该位置结构体定义。

struct NRC_Position
{
std::vector<double> v;
NRC_COORD coord; ///< 位置的坐标系
int usrNum; ///用户坐标系
int toolNum; ///工具坐标系
int configuration; ///形态值
/**
* @brief 位置的值
* - 关节坐标系下,pos[0]到pos[6]分别对于机器人的1到7轴
* - 其他坐标系下,pos[0]到pos[6]分别对于机器人的x轴、y轴、z轴、A轴、B轴、C轴、臂角(七轴机器人)
*/
double pos[7];
};

然后在代码中加入

NRC_GetCurrentPos(NRC_ACS, inexbot); //获取当前位置
printf("inexbot.pos=%f,%f,%f,,%f,%f,%f,%f,\n",inexbot.pos[0],inexbot.pos[1],inexbot.pos[2],inexbot.pos[3],inexbot.pos[4],inexbot.pos[5],inexbot.pos[6]); //输出当前位置

意为获取关节坐标系的数据,并将数据存入 inexbot 对象,然后打印出来。

NRC_GetCurrentPos 定义如下

/**
* @brief 获取当前位置
* @note 该函数可以获取在 coord 坐标系下点机器人位置,位置数据由参数引用 position 返回
* @see NRC_COORD
* @see NRC_Position
*/
int NRC_GetCurrentPos(NRC_COORD coord, NRC_Position& position);