Wait¶
The Wait function is a function that temporarily stops (blocks) the execution of the API call thread in the control flow of a robot or automation equipment until a specified wait condition is met. This function is used in situations that require precise synchronization and sequential control with other robots or external events.
After being called, the Wait function waits in a stopped state until the specified condition is satisfied, and immediately executes the next command as soon as the condition is met.
The conditions supported by the Wait function are as follows.
Waits until the robot’s current motion is completely finished. This is the default setting of the Wait function and ensures a stable operation flow in most cases.
Waits until the motion of another robot starts. Be careful not to set the
Trigger Robot IDitem to the same robot.
Waits until the remaining travel distance of the currently executing motion is less than or equal to the specified reference value. This allows for preliminary preparation for the next task. The unit is mm. Both CP motion and PTP motion calculate the remaining distance based on the Cartesian coordinate system of the robot’s end effector.
Waits until the remaining execution time of the current motion is reduced to a specific threshold or less. It is mainly used to synchronize operations at the point just before the motion ends. The unit is msec.
Wait Function Example with Motion End Trigger Condition
wmx3Api::RobotMotion robotMotion;
wmx3Api::RobotMotionParam robotMotionParam;
// Case 1
{
int errCode = robotMotion.mKinematics.Wait(robotMotionParam.robotParam.robotId);
}
// Case 2
{
wmx3Api::kinematics::KinematicsEventInput trigger = wmx3Api::kinematics::KinematicsEventInput();
trigger.robotId = robotMotionParam.robotParam.robotId;
trigger.triggerType = wmx3Api::kinematics::KinematicsEventData::EventTriggerType::EventTriggerMotionEnd;
int errCode = robotMotion.mKinematics.Wait(trigger);
}
Wait Function Example with Motion Start Trigger Condition
// Thread A
{
wmx3Api::RobotMotion robotMotion;
wmx3Api::kinematics::KinematicsEventInput triggerInput = wmx3Api::kinematics::KinematicsEventInput();
triggerInput.robotId = triggerRobotId;
triggerInput.triggerType = wmx3Api::kinematics::KinematicsEventData::EventTriggerType::EventTriggerMotionStart;
int errCode = robotMotion.mKinematics.Wait(&triggerInput);
}
// Thread B
{
wmx3Api::RobotMotion triggerRobotMotion;
wmx3Api::RobotMotionParam triggerRobotMotionParam;
wmx3Api::PtpMotionParam::PtpPosParam triggerPTPParam(triggerRobotMotionParam.robotParam, triggerRobotMotionParam.profile, testJointAngle);
int errCode = triggerRobotMotion.mKinematics.StartPTPPos(triggerPTPParam);
}
Wait Function Example with Remained Distance Trigger Condition
wmx3Api::RobotMotion robotMotion;
wmx3Api::RobotMotionParam robotMotionParam;
wmx3Api::kinematics::KinematicsEventInput trigger = wmx3Api::kinematics::KinematicsEventInput();
trigger.robotId = robotMotionParam.robotParam.robotId;
trigger.triggerType = wmx3Api::kinematics::KinematicsEventData::EventTriggerType::EventTriggerMotionRemainedDistance;
trigger.data.remainedDistance = 10;
int errCode = robotMotion.mKinematics.Wait(trigger);
Wait Function Example with Remained Time Trigger Condition
wmx3Api::RobotMotion robotMotion;
wmx3Api::RobotMotionParam robotMotionParam;
wmx3Api::kinematics::KinematicsEventInput trigger = wmx3Api::kinematics::KinematicsEventInput();
trigger.robotId = robotMotionParam.robotParam.robotId;
trigger.triggerType = wmx3Api::kinematics::KinematicsEventData::EventTriggerType::EventTriggerMotionRemainingTime;
trigger.data.remainingTimeMillisecond = 10;
int errCode = robotMotion.mKinematics.Wait(trigger);