Show / Hide Table of Contents

Creating RsMoveInstruction

This example provides information on loading a mechanism (a robot) into the current station, and setting it as the active task. It creates a work object for the active task and tool data for the robot. It creates a RsRobTarget and a RsTarget, which is the RsRobTarget's graphical representation. Finally, it creates a path and adds some move instructions to it.

Solution

  1. Get the active station object.

    Station station = Station.ActiveStation;
    
  2. Load IRB140_5_81__01 robot (a mechanism) in readonly mode and add it to the station.

    GraphicComponentLibrary mechLib = GraphicComponentLibrary.Load("IRB140_6_81_C_G_03.rslib", true);
    Mechanism mechGfx = (Mechanism)mechLib.RootComponent.CopyInstance();
    mechGfx.Name = "IRB140_6_81_C_G_03";
    station.GraphicComponents.Add(mechGfx);
    
  3. Set the active task to the mechanism task.

    station.ActiveTask = mechGfx.Task;
    
  4. Create a RsWorkObject object and add it to the ActiveTask.

    RsWorkObject myWobj = new RsWorkObject();
    myWobj.Name = station.ActiveTask.GetValidRapidName("myWobj", "_", 1);
    station.ActiveTask.DataDeclarations.Add(myWobj);
    
  5. Create a RsToolData object and add it to the ActiveTask.

    RsToolData myTool = new RsToolData();
    myTool.Name = station.ActiveTask.GetValidRapidName("myTool", "_", 1);
    station.ActiveTask.DataDeclarations.Add(myTool);
    
  6. Create a new RsRobTarget and add it to the ActiveTask.

    RsRobTarget toPoint = new RsRobTarget();
    toPoint.Name = station.ActiveTask.GetValidRapidName("myRobTarget", "_", 1);
    station.ActiveTask.DataDeclarations.Add(toPoint);
    
  7. Create a graphic representation of the RobTarget and RsTarget.

    RsTarget myRsTarget = new RsTarget(myWobj, toPoint);
    myRsTarget.Name = toPoint.Name;
    station.ActiveTask.Targets.Add(myRsTarget);
    
  8. Create RsPathProcedure object and add it to the ActiveTask.

    RsPathProcedure myPath = new RsPathProcedure("myPath");
    station.ActiveTask.PathProcedures.Add(myPath);
    
  9. Create a linear move instruction using the move definition and the default template.

    RsMoveInstruction myMoveL = new RsMoveInstruction
        (station.ActiveTask, "Move", "Default",
        MotionType.Linear, myWobj.Name, toPoint.Name, myTool.Name);
    myPath.Instructions.Add(myMoveL);
    
  10. Create a new RobTarget to use as cirPoint and add it to the ActiveTask.

    RsRobTarget cirPoint = new RsRobTarget();
    cirPoint.Name = station.ActiveTask.GetValidRapidName("myRobTarget", "_", 1);
    cirPoint.Frame.X = cirPoint.Frame.X + 0.10;
    cirPoint.Frame.Z = cirPoint.Frame.Z + 0.10;
    station.ActiveTask.DataDeclarations.Add(cirPoint);
    
  11. Create a graphic representation of the RobTarget and RsTarget.

    RsTarget myRsTarget_2 = new RsTarget(myWobj, cirPoint);
    myRsTarget_2.Name = cirPoint.Name;
    station.ActiveTask.Targets.Add(myRsTarget_2);
    
  12. Create a circular move instruction.

    RsMoveInstruction myMoveCirc = new RsMoveInstruction(station.ActiveTask,
        "Move", "Default", myWobj.Name, cirPoint.Name, toPoint.Name, myTool.Name);
    myPath.Instructions.Add(myMoveCirc);
    
  13. Create a joint target and add it to the ActiveTask.

    RsJointTarget myJointTarget = new RsJointTarget();
    myJointTarget.Name = station.ActiveTask.GetValidRapidName("myJointTarget", "_", 1);
    station.ActiveTask.DataDeclarations.Add(myJointTarget);
    
  14. 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);
    
  15. Create a MoveAbsJ move instruction passing the joint target object in step 13 as a parameter (this only makes sense if there is a mechanism in the station).

    RsMoveInstruction myMoveAbsJ =
        new RsMoveInstruction(station.ActiveTask, "MoveAbs", "Default", myJointTarget.Name);
    myPath.Instructions.Add(myMoveAbsJ);
    

Example

This example provides information on loading a mechanism (a robot) to the current station, and sets it as the active task.

Project.UndoContext.BeginUndoStep("RsMoveInstructionCreate");
try
{
    Station station = Station.ActiveStation;

    // First import a robot (a mechanism) and add it to the station.
    GraphicComponentLibrary mechLib = GraphicComponentLibrary.Load("IRB140_6_81_C_G_03.rslib", true);
    Mechanism mechGfx = (Mechanism)mechLib.RootComponent.CopyInstance();
    mechGfx.Name = "IRB140_6_81_C_G_03";
    station.GraphicComponents.Add(mechGfx);

    // Set the active task to the mechanism task.
    station.ActiveTask = mechGfx.Task;

    // Create a WorkObject and add it to the ActiveTask.
    RsWorkObject myWobj = new RsWorkObject();
    myWobj.Name = station.ActiveTask.GetValidRapidName("myWobj", "_", 1);
    station.ActiveTask.DataDeclarations.Add(myWobj);

    // Create a ToolData and add it to the ActiveTask.
    RsToolData myTool = new RsToolData();
    myTool.Name = station.ActiveTask.GetValidRapidName("myTool", "_", 1);
    station.ActiveTask.DataDeclarations.Add(myTool);

    // Create a new RobTarget and add it to the ActiveTask.
    RsRobTarget toPoint = new RsRobTarget();
    toPoint.Name = station.ActiveTask.GetValidRapidName("myRobTarget", "_", 1);
    station.ActiveTask.DataDeclarations.Add(toPoint);

    // Create a graphic representation of the RobTarget and RsTarget.
    RsTarget myRsTarget = new RsTarget(myWobj, toPoint);
    myRsTarget.Name = toPoint.Name;
    station.ActiveTask.Targets.Add(myRsTarget);

    // Create a PathProcedure.
    RsPathProcedure myPath = new RsPathProcedure("myPath");
    station.ActiveTask.PathProcedures.Add(myPath);

    // Create a linear move instruction using the move definition and the default template.
    RsMoveInstruction myMoveL = new RsMoveInstruction
        (station.ActiveTask, "Move", "Default",
        MotionType.Linear, myWobj.Name, toPoint.Name, myTool.Name);
    myPath.Instructions.Add(myMoveL);

    // Create a new RobTarget to use as cirPoint and add it to the ActiveTask.
    RsRobTarget cirPoint = new RsRobTarget();
    cirPoint.Name = station.ActiveTask.GetValidRapidName("myRobTarget", "_", 1);
    cirPoint.Frame.X = cirPoint.Frame.X + 0.10;
    cirPoint.Frame.Z = cirPoint.Frame.Z + 0.10;
    station.ActiveTask.DataDeclarations.Add(cirPoint);

    // Create a graphic representation of the RobTarget and RsTarget.
    RsTarget myRsTarget_2 = new RsTarget(myWobj, cirPoint);
    myRsTarget_2.Name = cirPoint.Name;
    station.ActiveTask.Targets.Add(myRsTarget_2);

    // Create a circular move instruction.
    RsMoveInstruction myMoveCirc = new RsMoveInstruction(station.ActiveTask,
        "Move", "Default", myWobj.Name, cirPoint.Name, toPoint.Name, myTool.Name);
    myPath.Instructions.Add(myMoveCirc);

    // Create a joint target to be able to create a MoveAbsJ move instruction.
    RsJointTarget myJointTarget = new RsJointTarget();
    myJointTarget.Name = station.ActiveTask.GetValidRapidName("myJointTarget", "_", 1);
    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 MoveAbsJ move instruction (this only makes sense if there is a mechanism in the station).
    RsMoveInstruction myMoveAbsJ =
        new RsMoveInstruction(station.ActiveTask, "MoveAbs", "Default", myJointTarget.Name);
    myPath.Instructions.Add(myMoveAbsJ);

    // Create a MoveAbsL move instruction (this only makes sense if there is a mechanism in the station).
    RsMoveInstruction myMoveAbsL =
        new RsMoveInstruction(station.ActiveTask, "MoveAbs", "Default", myJointTarget.Name, MotionType.Linear);
    myPath.Instructions.Add(myMoveAbsL);
}
catch
{
    Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
    throw;
}
finally
{
    Project.UndoContext.EndUndoStep();
}

Required Namespaces

ABB.Robotics.RobotStudio

ABB.Robotics.RobotStudio.Stations

See Also

  • Importing ActionInstruction
  • Importing MoveInstruction
In this article
Back to top Copyright © 2025 ABB