# How to get stage's current pose for manual buttons

By default, manual trigger HMI controller assumes current stage is always at its origin by setting X, Y, Theta parameters in commands as 0. This works well if the purpose of manual trigger is to configure vision tasks or test program workflow, but not when the purpose is to further test align accuracy since stage's current pose is not involved in pose calculation. However, manual trigger HMI controller also provides a callback function which allows user to acquire stage pose before sending the manual triggered command out to program. The callback function is named "GetStagePosition", and here is the workflow of manual trigger process wherein GetStagePosition is positioned.

Once any button on manual trigger HMI is clicked in run time mode, the manual trigger HMI controller will first call GetStagePosition where stage pose can be obtained and sent back to manual trigger controller. Following that, the controller will send the command with updated X, Y, Theta parameters of stage pose to CommandHanlder to let the program finish the rest of the vision task. Meanwhile, manual trigger controller will also call another callback function named "CommandSentCallback" where user can get the sent-out command string. CommandSentCallback can be used for logging purpose or user can just leave it as it is since it has no effects on the main process.

The two callback functions can be found under "Scripts" option of context menu by right-clicking the manual trigger HMI controller in test mode.

### GetStagePosition

The signature of GetStagePosition is as below:

public System.Tuple<double, double, double> GetStagePosition(int StepID, string ButtonName, string CommandKey)

Inputs

Item | Type | Description
--- | --- | ---
StepID | Integer | The StepID of requested task
ButtonName | String | The name of button that has been triggered
CommandKey | String | The Command Key that of the command that sent by the triggered button

Output

The output is x, y, theta values in Tuple format.

Note: All buttons on the same manual trigger HMI share the same GetStagePosition callback function, user can decide which stage's pose is to return depending on input StepID.

### CommandSentCallBack

The signature of CommandSentCallBack is as below:

public void CommandSentCallBack(int StepID, string cmdSent)

Inputs

Item | Type | Description
--- | --- | ---
StepID | Integer | The StepID of requested task behind the triggered button
cmdSent | String | The final command string sent to CommandHandler which later calls corresponding task