# nPose Computer Commands

Pose computer command is used to trigger the vision system to compute target pose for motion device to move, so that when the part is aligned or assembled, the alignment or assembly characteristics can be achieved. Pose computer command has two types: GP/GPA, MGP/MGPA. GP and GPA are for single part alignment or two parts assembly applications, MGP and MGPA are for multi-part pickup applications. GP and MGP request task to run in synchronous mode, whereas GPA and MGPA request run in asynchronous mode.

## GP/GPA

Computes the destination pose from all the feature finding steps(triggered "LF" or "LFA" commands) which share the same PartID. This is the last command in a multi-step alignment sequence, and it assumes all features have been located successfully with preceding “LF”/"LFA" commands.

GP and GPA commands share the same command format. The only difference between them are that GP command will run the requested task synchronously, whereas GPA command runs task asynchronously.

Command string for GP command:

GP,<EncodedID>,<ProductID>,<ResultMode>,<X>,<Y>,<Z>,<A>,<B>,<C>

Command string for GPA command:

GPA,<EncodedID>,<ProductID>,<ResultMode>,<X>,<Y>,<Z>,<A>,<B>,<C>

Field | Arguments
--- | ---
<EncodedID> | Alignment task + Process Tag(2000)
<PartID> | Serial number of part if it has, or any string as long as it is consistent for one part (PartID used here should be the same as used in LF commands if they are from the same part)
<ResultMode> | Abs (absolute value) or Off (offset from the current pose)
<X> | The X-coordinate of the current position of the motion system
<Y> | The Y-coordinate of the current position of the motion system
<Z> | 0 (not used)
<A> | The theta(in degrees) of the current position of the motion system
<B> | 0 (not used)
<C> | 0 (not used)
[,<UserString>] | Optional, for user to customize some extra data

Result String

When task runs successfully:

GP/GPA,<Status>,<Token>,<PartID>,<X>,<Y>,<Z>,<A>,<B>,<C>CR/LF

Field | Arguments
--- | ---
<Status> | 1
<Token> | The Token identifying the corresponding command
<PartID> | PartID provided by command string
<X> | The X-coordinate of the destination position for the motion system
<Y> | The Y-coordinate of the destination position for the motion system
<Z> | 0 (not used)
<A> | The theta(in degrees) of the destination position for the motion system
<B> | 0 (not used)
<C> | 0 (not used)

When task fails:

GP/GPA,<Status>,<Token>,<PartID>CR/LF

Field | Arguments
--- | ---
<Status> | ErrorCode
<Token> | The Token identifying the corresponding command
<PartID> | PartID provided by command string

## MGP/MGPA

Runs multi-part pickup. This is the last command in a multi-step alignment sequence, and it assumes all features have been located successfully with preceding “LF” commands.

### Command string

MGP and MGPA commands share the same command format. The only difference between them are that MGP command will run the requested task synchronously, whereas MGPA command runs task asynchronously.

Command string for MGP command:

MGP,<EncodedID>,<PartID>,<StatusOnly>,<ResultMode>,<X>,<Y>,<Z>,<A>,<B>,<C>,<UserString>,<MainIndex>[,<Index2>]...[,<IndexN>]

Command string for MGPA command:

MGPA,<EncodedID>,<PartID>,<StatusOnly>,<ResultMode>,<X>,<Y>,<Z>,<A>,<B>,<C>,<UserString>,<MainIndex>[,<Index2>]...[,<IndexN>]

Field | Arguments
--- | ---
<EncodedID> | Alignment task + Process Tag(2000)
<PartID> | Serial number of part if it has, or any string if it is consistent for one part (PartID used here should be the same as used in LF commands if they are from the same part)
<StatusOnly> | 0: return string feedback OK/NG information as well as target X,Y,Theta for each sub-region. 1: return string only feedback OK/NG for each sub-region
<ResultMode> | Abs (absolute value) or Off (offset from the current pose)
<X> | The X-coordinate of the current position of the motion system
<Y> | The Y-coordinate of the current position of the motion system
<Z> | 0 (not used)
<A> | The theta(in degrees) of the current position of the motion system
<B> | 0 (not used)
<C> | 0 (not used)
,<UserString> | For user to customize some extra data(required field, not optional)
<MainIndex>[,<Index2>]...[,<IndexN>] | Indexes of sub-regions of parts that needs pose computation. MainIndex is required, Index2,...,IndexN are optional. If MainIndex is -1, command will compute all sub-regions' results If MainIndex is specific index, such as 5, and there are no other indexes, command will compute that specific sub-region(5) only If MainIndex, Index1, Index2, ..., IndexN are a serial of indexes(such as 1, 4, 7), command will only compute those given sub-regions(1,4,7).

### Result String

When task runs successfully with StatusOnly as 0:

MGP/MGPA,<Status>,<Token>,<PartID>,<ResultCount>,<Status1>,<X1>,<Y1>,<T1>[,<Status2>][,<X2>][,<Y2>][,<T2>]...[,<StatusN>][,<Xn>][,<Yn>][,<Tn>]CR/LF

Field | Arguments
--- | ---
<Status> | 1: Task run successfully
<Token> | The Token identifying the corresponding command
<PartID> | PartID provided by command string
<ResultCount> | The count of requested sub-regions
<Status1>,[,<Status2>]...[,<StatusN>] | 1: Pose computation runs successfully ErrorCode: Pose computation of given sub-region fails, by default ErrorCode = 0, but it can be other negative integers that defined by user in Custom Tool Block for feature finding
<X1>,[,<X2>]...[,<Xn>] | X component of target pose of requested sub-region
<Y1>,[,<Y2>]...[,<Yn>] | Y component of target pose of requested sub-region
<T1>,[,<T2>]...[,<Tn>] | Theta component of target pose of requested sub-region

When task runs successfully with StatusOnly as 1:

MGP/MGPA,<Status>,<Token>,<PartID>,<ResultCount>,<Status1>[,<Status2>]...[,<StatusN>]CR/LF

When task fails:

MGP/MGPA,<Status>,<Token>,<PartID>CR/LF

Field | Arguments
--- | ---
<Status> | ErrorCode: Task fails
<Token> | The Token identifying the corresponding command
<PartID> | PartID provided by command string

Note:

Before GP/GPA/MGP/MGPA command is sent, the external device needs to make sure all related LF/LFA commands have already finished execution. Otherwise the calculated result of x, y, theta by GP/GPA/MGP/MGPA command would be based on last time's run time feature result. In order to confirm that, the external device can compare the <Token> in the acknowledge signal with the <Token> in the received result string to see if they are the same after a LF/LFA command is sent out. If so, it means that the LF/LFA command has finished execution, otherwise, the feature finding task is still running.