Show / Hide Table of Contents

RsMoveInstruction Movement Methods Example

This example creates two joint targets and jumps to them. It also creates a path with one of the join targets and moves along that path.

Compiling the Code

Note

This examples requires a station containing an IRB140 and a running VC!

Example

// NOTE: This example requires a station containing an IRB_140 and a running VC.
Project.UndoContext.BeginUndoStep("RsMoveInstructionMovementMethods");
try
{
    Station station = Station.ActiveStation;

    // Create a PathProcedure to add the move instructions to.
    RsPathProcedure myPath = new RsPathProcedure("myPath");
    station.ActiveTask.PathProcedures.Add(myPath);

    // Create a joint target corresponding to the robots home position.
    RsJointTarget myHomeJointTarget = new RsJointTarget();
    myHomeJointTarget.Name = "myHomeJT";
    station.ActiveTask.DataDeclarations.Add(myHomeJointTarget);

    // Set the robot axis values.
    RobotAxisValues rbHomeAxis = new RobotAxisValues();
    rbHomeAxis.Rax_1 = 0;
    rbHomeAxis.Rax_2 = 0;
    rbHomeAxis.Rax_3 = 0;
    rbHomeAxis.Rax_4 = 0;
    rbHomeAxis.Rax_5 = 30;
    rbHomeAxis.Rax_6 = 0;
    myHomeJointTarget.SetRobotAxes(rbHomeAxis, false);

    // Create another joint target to jump and move to.
    RsJointTarget myJointTarget = new RsJointTarget();
    myJointTarget.Name = "myJointTarget";
    station.ActiveTask.DataDeclarations.Add(myJointTarget);

    // Set the robot axis values.
    RobotAxisValues rbAxis = new RobotAxisValues();
    rbAxis.Rax_1 = 70.0000000000001;
    rbAxis.Rax_2 = -30;
    rbAxis.Rax_3 = 30;
    rbAxis.Rax_4 = -55.0000000000001;
    rbAxis.Rax_5 = 40;
    rbAxis.Rax_6 = 10;
    myJointTarget.SetRobotAxes(rbAxis, false);

    // Create a move instruction.
    RsMoveInstruction myMoveAbsJ = new RsMoveInstruction(station.ActiveTask, "MoveAbs", "Default", "myJointTarget");
    myPath.Instructions.Add(myMoveAbsJ);

    // Jump to the move instruction 'myMoveAbsJ'.
    if (myMoveAbsJ.JumpTo())
    {
        Logger.AddMessage(new LogMessage("The robot jumped successfully!"));
    }
    else
    {
        Logger.AddMessage(new LogMessage("The JumpTo command failed!"));
    }

    // Jump the robot to its home postition.
    myHomeJointTarget.JumpTo();

    // Move to the move instruction 'myMoveAbsJ'
    if (myMoveAbsJ.MoveTo())
    {
        Logger.AddMessage(new LogMessage("The robot moved successfully!"));
    }
    else
    {
        Logger.AddMessage(new LogMessage("The MoveTo command failed!"));
    }
}
catch
{
    Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
    throw;
}
finally
{
    Project.UndoContext.EndUndoStep();
}

See Also

  • RsPathProcedure
  • RsJointTarget
  • RobotAxisValues
  • RsMoveInstruction
  • RobotStudio Community
In this article
Back to top Copyright © 2025 ABB