Tutorial 6: PTP Motion¶
This part covers the following.
Perform PtpMotion (Pos, Mov, Jog) of RobotMotion.
Perform PTP motion based on each Joint and PTP motion based on the Cartesian coordinate system.
1. Sample Code
SamplePtpMotionPosJoint
Performs Point To Point motion for each Joint that constitutes the robot.
int SamplePtpMotionPosJoint(wmx3Api::RobotMotion& robot, wmx3Api::RobotMotionParam& robotMotionParam)
{
int ret = 0;
// Point To Point Position Command(Parameter)
wmx3Api::PtpMotionParam::PtpPosParam ptpParam(robotMotionParam.robotParam,
robotMotionParam.profile, { 0,0,0,0,0,0 }); // UserUnit
// Set new joint position(degree)
ptpParam.targetJointPosition[0] += 5;
ptpParam.targetJointPosition[1] += 10;
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam);
// Wait until motion finished
ret = robot.mKinematics.Wait(robotMotionParam.robotParam.robotId);
return ret;
}
Creates a PtpPosParam (Point To Point Parameter) class.
Passes the robot’s parameters, profile information, and the target position of each Joint as arguments.
The targetJointPosition of PtpPosParam indicates the target position (degree or mm) of each Joint.
The StartPTPPos function performs PTP motion.
Waits until the motion is complete.

SamplePtpMotionPosCartesian
Achieves the Pose of the robot’s End effector in the Cartesian coordinate system.
int SamplePtpMotionPosCartesian(wmx3Api::RobotMotion& robot, wmx3Api::RobotMotionParam& robotMotionParam)
{
int ret = 0;
wmx3Api::RobotStatus robotStatus;
// Point To Point Position Command(Parameter)
wmx3Api::PtpMotionParam::PtpPosParam ptpParam(robotMotionParam.robotParam,
robotMotionParam.profile);
// Set 'target pose'
ret = robot.UpdateRobotStatus(robotMotionParam.robotParam.robotId, robotStatus);
wmx3Api::coordinate::CartesianPose targetPose = robotStatus.stateCommand.toolPose;
targetPose.point.x -= 25;
targetPose.point.z += 10;
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam, targetPose);
// Wait until motion finished
ret = robot.mKinematics.Wait(robotMotionParam.robotParam.robotId);
return ret;
}
Creates a PtpPosParam (Point To Point Parameter) class.
Passes the robot’s parameters and profile information as arguments.
Acquires the current posture of the robot’s End effector from the GetCurrentToolPose function defined in RobotSystem.
The target coordinates were changed by increasing or decreasing the coordinates of the targetPose indicating the current posture.
The StartPTPPos function performs PTP motion.
Passes targetPose (CartesianPose) as an argument to ‘explicitly indicate CartesianPose’.
Waits until the motion is complete.

SamplePtpMotionMovJoint
Performs Point To Point motion for each Joint that constitutes the robot. Performs relative movement, not absolute position.
int SamplePtpMotionMovJoint(wmx3Api::RobotMotion& robot, wmx3Api::RobotMotionParam& robotMotionParam)
{
int ret = 0;
// Set joint relative angle(degree) of each joint to mov
double movDegreeArray[6] = { 5,-5,0,10,-10,0 };
int length = sizeof(movDegreeArray) / sizeof(movDegreeArray[0]);
// Point To Point Mov(Relative) Command(Parameter)
wmx3Api::PtpMotionParam::PtpMovParam ptpParam(robotMotionParam.robotParam,
robotMotionParam.profile,
movDegreeArray);
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam);
// Wait until motion finished
ret = robot.mKinematics.Wait(robotMotionParam.robotParam.robotId);
// Set joint to go back
for (int idx = 0; idx < length; idx++) {
ptpParam.targetJointPosition[idx] *= -1.0;
}
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam);
// Wait until motion finished
ret = robot.mKinematics.Wait(robotMotionParam.robotParam.robotId);
return ret;
}
moveDegreeArray indicates the amount of movement of each joint (User unit).
Creates a PtpMovParam (Point To Point Parameter) class.
Passes the robot’s parameters, profile information, and the target movement amount of each Joint as arguments.
The StartPTPPos function performs PTP motion.
Waits until the motion is complete.
The targetJointPosition of PtpMovParam indicates the target movement amount of each Joint.
Therefore, if the movement amount of each Joint is reversed, it moves to the original position.
The StartPTPPos function performs PTP motion.
Waits until the motion is complete.

SamplePtpMotionMovMotionCartesian
Performs relative movement of the robot’s End effector in the Cartesian coordinate system.
int SamplePtpMotionMovMotionCartesian(wmx3Api::RobotMotion& robot, wmx3Api::RobotMotionParam& robotMotionParam)
{
int ret = 0;
// Point To Point Position Command(Parameter)
wmx3Api::PtpMotionParam::PtpMovParam ptpParam(robotMotionParam.robotParam,
robotMotionParam.profile);
// Set 'target pose'
wmx3Api::coordinate::CartesianPose targetPose;
targetPose.point.x = 50;
targetPose.point.y = 20;
targetPose.point.z = 10;
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam, targetPose);
// Wait until motion finished
ret = robot.mKinematics.Wait(robotMotionParam.robotParam.robotId);
// Set pose to go back
targetPose.point.x *= -1;
targetPose.point.y *= -1;
targetPose.point.z *= -1;
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam, targetPose);
// Wait until motion finished
ret = robot.mKinematics.Wait(robotMotionParam.robotParam.robotId);
return ret;
}
Creates a PtpMovParam (Point To Point Parameter) class. Passes the robot’s parameters and profile information as arguments.
Assigns the target movement amount to targetPose (CartesianPose).
The StartPTPPos function performs PTP motion.
Passes targetPose (CartesianPose) as an argument to ‘explicitly indicate CartesianPose’.
Waits until the motion is complete.
The targetPose passed to PtpMovParam indicates the amount of movement in the Cartesian coordinate system.
Therefore, if the value is reversed, it moves to the original position.
The StartPTPPos function performs PTP motion.
Passes targetPose (CartesianPose) as an argument to ‘explicitly indicate CartesianPose’.
Waits until the motion is complete.

SamplePtpMotionJog
Performs Jog motion for each Joint that constitutes the robot.
int SamplePtpMotionJog(wmx3Api::RobotMotion& robot, wmx3Api::RobotMotionParam& robotMotionParam)
{
int ret = 0;
// Set joint direction of each joint
double jogDirectionArray[6] = { 1,-1,1,0,0,0 };
int length = sizeof(jogDirectionArray) / sizeof(jogDirectionArray[0]);
// Point To Point Jog Command(Parameter)
wmx3Api::PtpMotionParam::PtpJogParam ptpParam(robotMotionParam.robotParam,
robotMotionParam.profile,
jogDirectionArray);
// Start PTP motion
ret = robot.mKinematics.StartPTPPos(ptpParam);
// Wait 1000 millisecond(Robot is moving)
Sleep(1000);
// Stop motion
ret = robot.mKinematics.StopMotion(robotMotionParam.robotParam.robotId);
return ret;
}
jogDirectionArray indicates the direction of movement of each joint.
A positive number indicates +/counterclockwise, a negative number indicates -/clockwise, and 0 indicates a stop.
Creates a PtpJogParam (Point To Point Parameter) class.
Passes the robot’s parameters, profile information, and the direction of movement of each Joint as arguments.
The StartPTPPos function performs PTP motion.
PtpJogMotion continues until the StopMotion function is called.
main
int main(int argc, const char* argv[])
{
int ret = 0;
wmx3Api::WMX3Api dev;
wmx3Api::RobotMotion robot(&dev);
wmx3Api::RobotMotionParam robotMotionParam;
const double initialJointDegree[] = { 0, 0, 0, 0, -90, 0 };
// Initialization
ret = InitWMX(dev);
ret = InitRobotSystem(robot, robotMotionParam);
ret = InitRobotPose(robot, robotMotionParam, initialJointDegree);
printf("Start PtpMotionPosJoint\n");
ret = SamplePtpMotionPosJoint(robot, robotMotionParam);
ret = InitRobotPose(robot, robotMotionParam, initialJointDegree);
printf("Start PtpMotionPosCartesian\n");
ret = SamplePtpMotionPosCartesian(robot, robotMotionParam);
ret = InitRobotPose(robot, robotMotionParam, initialJointDegree);
printf("Start PtpMotionMovJoint\n");
ret = SamplePtpMotionMovJoint(robot, robotMotionParam);
ret = InitRobotPose(robot, robotMotionParam, initialJointDegree);
printf("Start PtpMotionMovCartesian\n");
ret = SamplePtpMotionMovMotionCartesian(robot, robotMotionParam);
ret = InitRobotPose(robot, robotMotionParam, initialJointDegree);
printf("Start PtpMotionJog\n");
ret = SamplePtpMotionJog(robot, robotMotionParam);
ret = InitRobotPose(robot, robotMotionParam, initialJointDegree);
printf("End of program.\n");
return 0;
}
Calls the previously declared/defined function.
