Skip to main content

Get current position

First define an object to receive the value of the position.

NRC_Position inexbot

You can find the definition of the position structure NRC_Position in nrcAPI.h.

struct NRC_Position
{
std::vector<double> v;
NRC_COORD coord; ///< Coordinate system of position
int usrNum; ///User coordinate system
int toolNum; ///Tool coordinate system
int configuration; ///Form value
/**
* @brief Value of position
* - In the joint coordinate system, pos[0] to pos[6] correspond to robot axis 1 to 7 respectively.
* - In other coordinate systems, pos[0] to pos[6] correspond to robot X-axis, Y-axis, Z-axis, A-axis, B-axis, C-axis, and arm angle (for 7-axis robots) respectively.
*/
double pos[7];
};

Then add

NRC_GetCurrentPos(NRC_ACS, inexbot); //Get current position
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]); //Output current position

to the code to obtain the data of joint coordinate system, store the data into the inexbot object, and then print it out.

NRC_GetCurrentPos is defined as follows

/**
* @brief Get current position
* @note This function can get the position of the robot in the coord coordinate system, and the position data is returned by the parameter reference position
* @see NRC_COORD
* @see NRC_Position
*/
int NRC_GetCurrentPos(NRC_COORD coord, NRC_Position& position);