Class RsTask
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
sistent("RAPIDTask")]
public sealed class RsTask : ProjectObject, IGfxObject
Properties
ActivePathProcedure
Gets or sets the active RsPathProcedure.
Declaration
public RsPathProcedure ActivePathProcedure { get; set; }
Property Value
Type | Description |
---|---|
RsPathProcedure |
Remarks
The active path is used when adding new instructions, and for other operations in the GUI.
ActiveProcessDefinition
Gets or sets the active RsProcessDefinition, which is used when creating new instructions.
Declaration
public RsProcessDefinition ActiveProcessDefinition { get; set; }
Property Value
Type | Description |
---|---|
RsProcessDefinition |
ActiveTool
Gets or sets the active RsToolData.
Declaration
public RsToolData ActiveTool { get; set; }
Property Value
Type | Description |
---|---|
RsToolData |
Remarks
The active tool is used when creating new instructions and for other operations in the GUI.
ActiveWorkObject
Gets or sets the active RsWorkObject.
Declaration
public RsWorkObject ActiveWorkObject { get; set; }
Property Value
Type | Description |
---|---|
RsWorkObject |
Remarks
The active workobject is used when creating new instructions and for other operations in the GUI.
DataDeclarations
Gets the collection of RsDataDeclaration objects.
Declaration
public RsDataDeclarationCollection DataDeclarations { get; }
Property Value
Type | Description |
---|---|
RsDataDeclarationCollection |
Examples
Get DataDeclarations.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
DisplayName
Declaration
public override string DisplayName { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
EntryPoint
Gets or sets the entry point for this task in the active ABB.Robotics.RobotStudio.
Declaration
public string EntryPoint { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
This property is a shortcut to EntryPoint in the active ABB.Robotics.RobotStudio.
Frame
Gets the task frame in global coordinates.
Declaration
public Matrix4 Frame { get; }
Property Value
Type | Description |
---|---|
Matrix4 |
InstructionDescriptions
Gets the collection of RsInstructionDescription objects in this task.
Declaration
public RsInstructionDescriptionCollection InstructionDescriptions { get; }
Property Value
Type | Description |
---|---|
RsInstructionDescriptionCollection |
Examples
Get InstructionDescriptions.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
IsMotionTask
Returns true if this is a motion task.
Declaration
public bool IsMotionTask { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Non-motion task objects are only used to control simulation of the corresponding task in the controller. Only use the Simulate and EntryPoint properties on such objects.
Mechanism
Gets the Mechanism that corresponds to this task.
Declaration
public Mechanism Mechanism { get; }
Property Value
Type | Description |
---|---|
Mechanism |
Remarks
If the task contains multiple mechanical units, the TCP robot is returned. If there is no TCP robot, an arbitrary mechanism is returned.
MechanismMovingTaskFrame
ABB internal use
Declaration
public Mechanism MechanismMovingTaskFrame { get; set; }
Property Value
Type | Description |
---|---|
Mechanism |
Name
Gets or sets the name of the Task.
Declaration
public override string Name { get; set; }
Property Value
Type | Description |
---|---|
String |
Overrides
Examples
Get/Set Name.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Parent
The Parent property returns a reference to the parent RsIrc5Controller object.
Declaration
public override ProjectObject Parent { get; }
Property Value
Type | Description |
---|---|
ProjectObject |
Overrides
Remarks
You can use the Parent property to navigate up from the current object to the object one level higher.
Examples
Get Parent.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
PathProcedures
Gets the collection of RsPathProcedure objects in this task.
Declaration
public RsPathProcedureCollection PathProcedures { get; }
Property Value
Type | Description |
---|---|
RsPathProcedureCollection |
Examples
Get PathProcedures.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ProcessDefinitions
Gets the collection of RsProcessDefinition objects in this task.
Declaration
public RsProcessDefinitionCollection ProcessDefinitions { get; }
Property Value
Type | Description |
---|---|
RsProcessDefinitionCollection |
Simulate
Declaration
olete("Use TaskSimulationConfiguration.Active instead")]
public bool Simulate { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Targets
Gets the collection of RsTarget objects in this task.
Declaration
public RsTargetCollection Targets { get; }
Property Value
Type | Description |
---|---|
RsTargetCollection |
Visible
Gets or sets if the graphical objects in ths task (paths and frames) are visible in the graphics.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
AfterLoad(PimDocument)
Declaration
protected override void AfterLoad(PimDocument doc)
Parameters
Type | Name | Description |
---|---|---|
RobotStudio.API.Persistence.PimDocument | doc |
Overrides
FindDataDeclarationFromModuleScope(String, String)
Find the RsDataDeclaration from the specified module scope.
Declaration
public RsDataDeclaration FindDataDeclarationFromModuleScope(string name, string moduleName)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the RsDataDeclaration to find. |
String | moduleName | The name of the module, which look from. |
Returns
Type | Description |
---|---|
RsDataDeclaration | RsDataDeclaration if find, othererwise null. |
FindDataDeclarationsByType(String)
Finds the RsDataDeclarations matching the supplied RAPID data type.
Declaration
public RsDataDeclaration[] FindDataDeclarationsByType(string type)
Parameters
Type | Name | Description |
---|---|---|
String | type | "robtarget", "jointtarget", "wobjdata", "tooldata" or data type of generics. See DataType. |
Returns
Type | Description |
---|---|
RsDataDeclaration[] | An array containing the RsDataDeclarations matching the supplied type. |
FindDataDeclarationsByType(Type)
Finds the RsDataDeclarations matching the supplied object type.
Declaration
public RsDataDeclaration[] FindDataDeclarationsByType(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The Type of objects to find. |
Returns
Type | Description |
---|---|
RsDataDeclaration[] | An array containing the RsDataDeclarations matching the supplied type. |
Examples
FindDataDeclarationsByType.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindFirstDataDeclarationByType(Type)
Finds the first RsDataDeclaration methcing the supplied Type.
Declaration
public RsDataDeclaration FindFirstDataDeclarationByType(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The name of the RsWorkObject to find RsTarget for. |
Returns
Type | Description |
---|---|
RsDataDeclaration | The first RsDataDeclaration matching the supplied type. |
Examples
FindFirstDataDeclarationByType.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindFirstTargetByWorkObject(RsWorkObject)
Finds the first RsTarget for the supplied RsWorkObject.
Declaration
public RsTarget FindFirstTargetByWorkObject(RsWorkObject workObject)
Parameters
Type | Name | Description |
---|---|---|
RsWorkObject | workObject | The RsWorkObject to find RsTarget for. |
Returns
Type | Description |
---|---|
RsTarget | The first RsTarget matching the supplied work objects. |
Examples
FindFirstTargetByWorkObject.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindFirstTargetByWorkObject(String)
Finds the first RsTarget for the supplied name of a RsWorkObject.
Declaration
olete("Do not call this method, name is not unique. Use FindFirstTargetByWorkObject(RsWorkObject workObject)")]
public RsTarget FindFirstTargetByWorkObject(string workObjectName)
Parameters
Type | Name | Description |
---|---|---|
String | workObjectName | The name of the RsWorkObject to find RsTarget for. |
Returns
Type | Description |
---|---|
RsTarget | The first RsTarget matching the supplied names. |
FindPathProcedureFromModuleScope(String, String)
Find the RsPathProcedure from the specified module scope.
Declaration
public RsPathProcedure FindPathProcedureFromModuleScope(string name, string moduleName)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the RsPathProcedure to find. |
String | moduleName | The name of the module, which look from. |
Returns
Type | Description |
---|---|
RsPathProcedure | RsPathProcedure if find, othererwise null. |
FindTargets(RsWorkObject, RsRobTarget)
Finds the RsTargets for the supplied RsWorkObject and RsRobTarget.
Declaration
public RsTarget[] FindTargets(RsWorkObject workObject, RsRobTarget robTarget)
Parameters
Type | Name | Description |
---|---|---|
RsWorkObject | workObject | The RsWorkObject to find RsTargets for. |
RsRobTarget | robTarget | The RsRobTarget to find RsTargets for. |
Returns
Type | Description |
---|---|
RsTarget[] | An array containing the RsTargets matching the supplied names. |
Examples
FindTargets.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindTargets(String, String)
Finds the RsTargets for the supplied name of a RsWorkObject and the name of a RsRobTarget.
Declaration
olete("Do not call this method, name is not unique. Use RsTask.FindTargets(RsWorkobject workObject, RsRobTarget robTarget)")]
public RsTarget[] FindTargets(string workObjectName, string robTargetName)
Parameters
Type | Name | Description |
---|---|---|
String | workObjectName | The name of the RsWorkObject to find RsTargets for. |
String | robTargetName | The name of the RsRobTarget to find RsTargets for. |
Returns
Type | Description |
---|---|
RsTarget[] | An array containing the RsTargets matching the supplied names. |
FindTargetsByRobTarget(RsRobTarget)
Finds the RsTargets for the supplied RsRobTarget.
Declaration
public RsTarget[] FindTargetsByRobTarget(RsRobTarget robTarget)
Parameters
Type | Name | Description |
---|---|---|
RsRobTarget | robTarget | The RsRobTarget to find RsTargets for. |
Returns
Type | Description |
---|---|
RsTarget[] | An array containing the RsTargets for the supplied RsRobTarget. |
Examples
FindTargetsByRobTarget.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindTargetsByRobTarget(String)
Finds the RsTarget for the supplied name of a RsRobTarget.
Declaration
olete("Do not call this method, name is not unique. Use RsTask.FindTargetsByRobTarget(RsRobTarget robTarget)")]
public RsTarget[] FindTargetsByRobTarget(string robTargetName)
Parameters
Type | Name | Description |
---|---|---|
String | robTargetName | The name of the RsRobTarget to find RsTarget for. |
Returns
Type | Description |
---|---|
RsTarget[] | An array containing the RsTargets for the supplied name. |
FindTargetsByWorkObject(RsWorkObject)
Finds the RsTargets for the supplied RsWorkObject.
Declaration
public RsTarget[] FindTargetsByWorkObject(RsWorkObject workObject)
Parameters
Type | Name | Description |
---|---|---|
RsWorkObject | workObject | The RsWorkObject to find RsTargets for. |
Returns
Type | Description |
---|---|
RsTarget[] | An array containing the RsTargets for the supplied RsWorkObject. |
Examples
FindTargetsByWorkObject.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindTargetsByWorkObject(String)
Finds the RsTargets for the supplied name of a RsWorkObject.
Declaration
olete("Do not call this method, name is not unique. Use RsTask.FindTargetsByWorkObject(RsWorkObject workObject)")]
public RsTarget[] FindTargetsByWorkObject(string workObjectName)
Parameters
Type | Name | Description |
---|---|---|
String | workObjectName | The name of the RsWorkObject to find RsTargets for. |
Returns
Type | Description |
---|---|
RsTarget[] | An array containing the RsTargets for the supplied name. |
GetExternalAxisJointTypes()
Gets the JointTypes of the external axis joints in the Task.
Declaration
public JointType[] GetExternalAxisJointTypes()
Returns
Type | Description |
---|---|
JointType[] | An array of JointTypes values specifying the joint types of the exterenal axis joints. |
Examples
GetExternalAxisJointTypes.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
GetExternalAxisJointValues()
Gets the joint values of the external axis joints in the Task.
Declaration
public double[] GetExternalAxisJointValues()
Returns
Type | Description |
---|---|
Double[] | An array of joint values for the exterenal axis joints. |
Examples
GetExternalAxisJointValues.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
GetValidRapidName(String, String, Int32)
Gets a RAPID name that is valid within the scope of the Task.
Declaration
public string GetValidRapidName(string baseName, string separator, int stepRate)
Parameters
Type | Name | Description |
---|---|---|
String | baseName | The base of the name. |
String | separator | The separator to be used between base and counter. |
Int32 | stepRate | The step rate to be used for the counter part of the name. |
Returns
Type | Description |
---|---|
String | The valid name. |
Remarks
This method traverses the whole Task each time it is called, and may cause performance problems for complex tasks.
Examples
GetValidRapidName.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ImportProcessDefinitions(String)
Imports Process Definitions from the supplied xml file.
Declaration
public void ImportProcessDefinitions(string xmlFileName)
Parameters
Type | Name | Description |
---|---|---|
String | xmlFileName | The file name of the xml file to import Process Definitions from. |
Examples
ImportProcessDefinitions.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ImportProcessDefinitions(String, CollectionConflictPolicy)
Imports Process Definitions from the supplied xml file.
Declaration
public void ImportProcessDefinitions(string xmlFileName, CollectionConflictPolicy policy)
Parameters
Type | Name | Description |
---|---|---|
String | xmlFileName | The file name of the xml file to import Process Definitions from. |
CollectionConflictPolicy | policy | Specifies what to do if a Process Definition with the same name already exists in the task. |
ImportProcessDefinitions(XmlReader)
Imports Process Definitions from the supplied XmlReader.
Declaration
public void ImportProcessDefinitions(XmlReader xmlReader)
Parameters
Type | Name | Description |
---|---|---|
XmlReader | xmlReader | The XmlReader to import Process Definitions from. |
Examples
ImportProcessDefinitions.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ImportProcessDefinitions(XmlReader, CollectionConflictPolicy)
Imports Process Definitions from the supplied XmlReader.
Declaration
public void ImportProcessDefinitions(XmlReader xmlReader, CollectionConflictPolicy policy)
Parameters
Type | Name | Description |
---|---|---|
XmlReader | xmlReader | The XmlReader to import Process Definitions from. |
CollectionConflictPolicy | policy | Specifies what to do if a Process Definition with the same name already exists in the task. |
IsValidRapidCharacter(Char)
Checks if the specified character is valid in a RAPID name, according to RAPID syntax.
Declaration
public static bool IsValidRapidCharacter(char character)
Parameters
Type | Name | Description |
---|---|---|
Char | character | Character to check for validity. |
Returns
Type | Description |
---|---|
Boolean | true/false for a valid/non-valid RAPID character. |
Examples
IsValidRapidCharacter.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
IsValidRapidName(String)
Checks if the specified string is a valid RAPID name, according to RAPID syntax.
Declaration
public static bool IsValidRapidName(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name to check for validity. |
Returns
Type | Description |
---|---|
Boolean | true/false for a valid/non-valid RAPID name. |
Examples
IsValidRapidName.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
IsValidRapidNameInModuleScope(String, String)
Checks if the specified string is a valid RAPID name in the specified module scope.
Declaration
public bool IsValidRapidNameInModuleScope(string moduleName, string name)
Parameters
Type | Name | Description |
---|---|---|
String | moduleName | Name of module in which to check. |
String | name | Name to check for validity. |
Returns
Type | Description |
---|---|
Boolean | true/false for a valid/non-valid RAPID name. |
Examples
IsValidRapidNameInModuleScope.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
IsValidRapidNameInTaskScope(String)
Checks if the specified string is a valid RAPID name in the RsTask scope.
Declaration
public bool IsValidRapidNameInTaskScope(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name to check for validity. |
Returns
Type | Description |
---|---|
Boolean |
IsValidRapidNameInTaskScope(String, String)
Checks if the specified string is a valid RAPID name in the RsTask scope.
Declaration
public bool IsValidRapidNameInTaskScope(string name, string moduleName)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name to check for validity. |
String | moduleName | Name of module in which to check. |
Returns
Type | Description |
---|---|
Boolean | true/false for a valid/non-valid RAPID name. |
JumpHome()
Sets all axes of all mechanisms in the task to their corresponding home position.
Declaration
public bool JumpHome()
Returns
Type | Description |
---|---|
Boolean | true/false for allowed/not allowed to execute the operation. |
Examples
JumpHome.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException |
OnCreatingObject()
Declaration
protected override void OnCreatingObject()
Overrides
OnDelete()
Declaration
protected override void OnDelete()
Overrides
RemoveUnusedDataDeclarations(String[])
Removes data declarations not belonging to any instruction.
Declaration
public List<RsDataDeclaration> RemoveUnusedDataDeclarations(string[] types)
Parameters
Type | Name | Description |
---|---|---|
String[] | types | Array of declaration types to search for, "robtarget", "jointtarget", "wobjdata", "tooldata" and data type of generics. |
Returns
Type | Description |
---|---|
List<RsDataDeclaration> | An array containing the removed declarations. |
SetExternalAxisJointValues(Double[])
Sets the joint values of the external axis joints in the Task.
Declaration
public bool SetExternalAxisJointValues(double[] jointValues)
Parameters
Type | Name | Description |
---|---|---|
Double[] | jointValues | An array specifying the joint value to be set of the external axis joints. |
Returns
Type | Description |
---|---|
Boolean | True if the operation succeded, false otherwise. |
Examples
SetExternalAxisJointValues.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
SetExternalAxisJointValues(Double[], Boolean)
Sets the joint values of the external axis joints in the Task.
Declaration
public bool SetExternalAxisJointValues(double[] jointValues, bool notify)
Parameters
Type | Name | Description |
---|---|---|
Double[] | jointValues | An array specifying the joint value to be set of the external axis joints. |
Boolean | notify | A bool to specify if changes are notified or not. |
Returns
Type | Description |
---|---|
Boolean | True if the operation succeded, false otherwise. |
Examples
SetExternalAxisJointValues.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
SyncData(String, SyncDirection, List<SyncLogMessage>)
Declaration
olete("Use SyncDataAsync instead")]
public void SyncData(string dataId, SyncDirection direction, List<SyncLogMessage> logMessageList)
Parameters
Type | Name | Description |
---|---|---|
String | dataId | |
SyncDirection | direction | |
List<SyncLogMessage> | logMessageList |
SyncDataAsync(String, SyncDirection, List<SyncLogMessage>)
Synchronizes the specified DataDeclaration to or from the controller/file.
Declaration
public Task SyncDataAsync(string dataId, SyncDirection direction, List<SyncLogMessage> logMessageList)
Parameters
Type | Name | Description |
---|---|---|
String | dataId | The dataId consists of two parts, the module name and the DataDeclaration name seperated by a slash or the dataId consists of a file description, as follows appearance 'file://full-path/dataDeclaration-name'. |
SyncDirection | direction | Specified the synchronization direction, to or from the VC. |
List<SyncLogMessage> | logMessageList | A list that will contain the log messages after method has returned. |
Returns
Type | Description |
---|---|
Task |
Examples
SyncData.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException |
SynchronizeAsync(IEnumerable<String>, IEnumerable<String>, SyncDirection, List<SyncLogMessage>, ProgressNotification)
Synchronizes multiple paths and data as a single operation.
Declaration
public Task<bool> SynchronizeAsync(IEnumerable<string> pathProcedureIds, IEnumerable<string> dataIds, SyncDirection direction, List<SyncLogMessage> logMessageList, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<String> | pathProcedureIds | |
IEnumerable<String> | dataIds | |
SyncDirection | direction | |
List<SyncLogMessage> | logMessageList | |
ProgressNotification | progressDelegate |
Returns
Type | Description |
---|---|
Task<Boolean> | True if the operation succeded, false otherwise. |
SynchronizeModuleFileAsync(String, SyncDirection, IEnumerable<String>)
ABB Internal use only. Synchronizes all or specified Procedures belonging to a module (specified in the file) to or from the station.
Declaration
public Task<RapidSyncResult> SynchronizeModuleFileAsync(string filePath, SyncDirection direction, IEnumerable<string> procedureNames = null)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | The full path name to a module file. |
SyncDirection | direction | Specified the synchronization direction, to or from the station. |
IEnumerable<String> | procedureNames | Procedure names to be synchronized or null to syncrhonize all procedures in the module. |
Returns
Type | Description |
---|---|
Task<RapidSyncResult> | The result of the sync operation. |
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException |
SyncPathProcedure(String, SyncDirection, ArrayList)
Declaration
olete("Use SyncPathProcedureAsync instead")]
public bool SyncPathProcedure(string pathProcedureId, SyncDirection direction, ArrayList logMessageList)
Parameters
Type | Name | Description |
---|---|---|
String | pathProcedureId | |
SyncDirection | direction | |
ArrayList | logMessageList |
Returns
Type | Description |
---|---|
Boolean |
SyncPathProcedure(String, SyncDirection, ArrayList, ProgressNotification, Double, Double)
Declaration
olete("Use SyncPathProcedureAsync instead")]
public bool SyncPathProcedure(string pathProcedureId, SyncDirection direction, ArrayList logMessageList, ProgressNotification progressDelegate, double progressStart, double progressEnd)
Parameters
Type | Name | Description |
---|---|---|
String | pathProcedureId | |
SyncDirection | direction | |
ArrayList | logMessageList | |
ProgressNotification | progressDelegate | |
Double | progressStart | |
Double | progressEnd |
Returns
Type | Description |
---|---|
Boolean |
SyncPathProcedure(String, SyncDirection, List<SyncLogMessage>)
Declaration
olete("Use SyncPathProcedureAsync instead")]
public bool SyncPathProcedure(string pathProcedureId, SyncDirection direction, List<SyncLogMessage> logMessageList)
Parameters
Type | Name | Description |
---|---|---|
String | pathProcedureId | |
SyncDirection | direction | |
List<SyncLogMessage> | logMessageList |
Returns
Type | Description |
---|---|
Boolean |
SyncPathProcedure(String, SyncDirection, List<SyncLogMessage>, ProgressNotification, Double, Double)
Declaration
olete("Use SyncPathProcedureAsync instead")]
public bool SyncPathProcedure(string pathProcedureId, SyncDirection direction, List<SyncLogMessage> logMessageList, ProgressNotification progressDelegate, double progressStart, double progressEnd)
Parameters
Type | Name | Description |
---|---|---|
String | pathProcedureId | |
SyncDirection | direction | |
List<SyncLogMessage> | logMessageList | |
ProgressNotification | progressDelegate | |
Double | progressStart | |
Double | progressEnd |
Returns
Type | Description |
---|---|
Boolean |
SyncPathProcedureAsync(String, SyncDirection, List<SyncLogMessage>)
Synchronizes a RsPathProcedure in the station with a RAPID procedure in the controller. The controller or the station is the master.
Declaration
public Task<bool> SyncPathProcedureAsync(string pathProcedureId, SyncDirection direction, List<SyncLogMessage> logMessageList)
Parameters
Type | Name | Description |
---|---|---|
String | pathProcedureId | The pathProcedureId consists of two parts, the module name and the PathProcedure name separated by a slash. |
SyncDirection | direction | Specified the synchronization direction, to or from the controller. |
List<SyncLogMessage> | logMessageList | A list that will contain the log messages after method has returned. |
Returns
Type | Description |
---|---|
Task<Boolean> | True if the operation succeded, false otherwise. |
Examples
SyncPathProcedure.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException |
SyncPathProcedureAsync(String, SyncDirection, List<SyncLogMessage>, ProgressNotification, Double, Double)
Synchronizes a RsPathProcedure in the station with a RAPID procedure in the controller. The controller or the station is the master.
Declaration
public Task<bool> SyncPathProcedureAsync(string pathProcedureId, SyncDirection direction, List<SyncLogMessage> logMessageList, ProgressNotification progressDelegate, double progressStart, double progressEnd)
Parameters
Type | Name | Description |
---|---|---|
String | pathProcedureId | The pathProcedureId consists of two parts, the module name and the PathProcedure name separated by a slash. |
SyncDirection | direction | Specified the synchronization direction, to or from the controller. |
List<SyncLogMessage> | logMessageList | A list that will contain the log messages after method has returned. |
ProgressNotification | progressDelegate | A delegate that will handle the progress notifications. |
Double | progressStart | Defines the start value sent to the progress delegate. |
Double | progressEnd | Defines the end value sent to the progress delegate. |
Returns
Type | Description |
---|---|
Task<Boolean> | True if the operation succeded, false otherwise. |
Examples
SyncPathProcedure.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException |
SyncToController(ArrayList)
Declaration
olete("Use SyncToControllerAsync instead")]
public bool SyncToController(ArrayList logMessageList)
Parameters
Type | Name | Description |
---|---|---|
ArrayList | logMessageList |
Returns
Type | Description |
---|---|
Boolean |
SyncToController(ArrayList, ProgressNotification)
Declaration
olete("Use SyncToControllerAsync instead")]
public bool SyncToController(ArrayList logMessageList, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
ArrayList | logMessageList | |
ProgressNotification | progressDelegate |
Returns
Type | Description |
---|---|
Boolean |
SyncToController(List<SyncLogMessage>)
Declaration
olete("Use SyncToControllerAsync instead")]
public bool SyncToController(List<SyncLogMessage> logMessageList)
Parameters
Type | Name | Description |
---|---|---|
List<SyncLogMessage> | logMessageList |
Returns
Type | Description |
---|---|
Boolean |
SyncToController(List<SyncLogMessage>, ProgressNotification)
Declaration
olete("Use SyncToControllerAsync instead")]
public bool SyncToController(List<SyncLogMessage> logMessageList, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
List<SyncLogMessage> | logMessageList | |
ProgressNotification | progressDelegate |
Returns
Type | Description |
---|---|
Boolean |
SyncToControllerAsync(List<SyncLogMessage>, ProgressNotification)
Synchronizes all PathProcedures and DataDeclarations that have the Synchronize flag set.
Declaration
public Task<bool> SyncToControllerAsync(List<SyncLogMessage> logMessageList, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
List<SyncLogMessage> | logMessageList | A list that will contain the log messages after method has returned. |
ProgressNotification | progressDelegate | A delegate that will handle the progeress notifications. |
Returns
Type | Description |
---|---|
Task<Boolean> | True if the operation succeded, false otherwise. |
Examples
SyncToController.
Project.UndoContext.BeginUndoStep("RsTask");
try
{
//NOTE: This example requires a stataion with and IRB_140, a positioner and a running VC.
Station station = Station.ActiveStation;
// Get the active task
RsTask myTask = station.ActiveTask;
// Create a PathProcedure, add it to the task and set it as active.
RsPathProcedure myPath = new RsPathProcedure(myTask.GetValidRapidName("myPath", "_", 1));
myTask.PathProcedures.Add(myPath);
myTask.ActivePathProcedure = myPath;
// Create a workobject, add it to the task and set it to active.
RsWorkObject myWobj = new RsWorkObject();
myWobj.Name = myTask.GetValidRapidName("myWobj", "_", 1);
myTask.DataDeclarations.Add(myWobj);
myTask.ActiveWorkObject = myWobj;
// Create RsRobTarget.
RsRobTarget myTarget = new RsRobTarget();
myTarget.Name = myTask.GetValidRapidName("myTarget", "_", 10);
// Create a corresponding RsTarget.
RsTarget myRsTarget = new RsTarget(myWobj, myTarget);
myRsTarget.Name = myTarget.Name;
// Add it to the task.
myTask.DataDeclarations.Add(myTarget);
myTask.Targets.Add(myRsTarget);
// Create a move instruction and add it to the PathProcedure.
RsMoveInstruction myMove = new RsMoveInstruction(myTask, "Move", "Default", MotionType.Linear, myWobj.Name, myTarget.Name, myTask.ActiveTool.Name);
myPath.Instructions.Add(myMove);
// Set myPath as entrypoint.
myTask.EntryPoint = myPath.Name;
// Make sure that all the objects in the task are included in simulation.
myTask.Simulate = true;
// Make sure that the objects in the task are visible in the graphics.
myTask.Visible = true;
// Sync the RobTaget to the VC.
await myTask.SyncDataAsync("Module1/" + myTarget.Name, SyncDirection.ToController, new List<SyncLogMessage>());
// Sync the path to the VC.
if (await myTask.SyncPathProcedureAsync("Module1/" + myPath.Name, SyncDirection.ToController, new List<SyncLogMessage>()))
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncPathProcedure of path " + myPath.Name + " falied!"));
}
// Sync the complete task to the VC.
if (await myTask.SyncToControllerAsync(new List<SyncLogMessage>(), null))
{
Logger.AddMessage(new LogMessage("SyncToController succeded!"));
}
else
{
Logger.AddMessage(new LogMessage("SyncToController falied!"));
}
// Move along the path.
if (await myPath.MoveAlongAsync(null))
{
Logger.AddMessage(new LogMessage("The MoveAlong path command failed!"));
}
// Jump back to the home position.
if (!myTask.JumpHome())
{
Logger.AddMessage(new LogMessage("The JumpHome command failed!"));
}
// Find all RobTargets in the task.
RsDataDeclaration[] datadecls = myTask.FindDataDeclarationsByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("There are '" + datadecls.Length + "' in the task"));
// Find the first RobTarget in the task.
RsRobTarget robTrg = (RsRobTarget)myTask.FindFirstDataDeclarationByType(typeof(RsRobTarget));
Logger.AddMessage(new LogMessage("The first robtarget in the task is '" + robTrg.Name + "'"));
// Find the first RsTarget in the workobject myWobj.
RsTarget rsTrg = myTask.FindFirstTargetByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("The first RsTarget in WorkObject '" + myWobj.Name + "' is '" + rsTrg.Name + "'"));
// Find RsTargets matching myWobj and myTarget.
RsTarget[] rsTargets = myTask.FindTargets(myWobj, myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name + " and robTarget: " + myTarget.Name));
// Find RsTargets matching the RobTarget myTarget.
rsTargets = myTask.FindTargetsByRobTarget(myTarget);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching robTarget: " + myTarget.Name));
// Find RsTargets matching the workobject MyWobj.
rsTargets = myTask.FindTargetsByWorkObject(myWobj);
Logger.AddMessage(new LogMessage("There are '" + rsTargets.Length + "' matching wobj: " + myWobj.Name));
// Activate the first mechanical unit.
station.Irc5Controllers[0].MechanicalUnits[0].ActivationMode = MechanicalUnitActivationMode.Active;
// Get the JointTypes of the external axes in the task.
JointType[] myJT = myTask.GetExternalAxisJointTypes();
// Get the joint values of the external axes in the task.
double[] eaValues = myTask.GetExternalAxisJointValues();
// Set joint number 4 of the external axis values to 1
eaValues[3] = 1;
if (!myTask.SetExternalAxisJointValues(eaValues))
{
Logger.AddMessage(new LogMessage("Failed to set ExtAxis Values!"));
}
// Import process definitions from an xml file.
// NOTE: Change this to a valid path! DefaultProcessTemplate.xml should be in your RobotStudio installation directory.
myTask.ImportProcessDefinitions(@"C:\Program Files\ABB Industrial IT\Robotics IT\RobotStudio 5.12\ProcessTemplates\DefaultProcessTemplate.xml");
// Output active path.
Logger.AddMessage(new LogMessage("The ActivePathProcedure is:" + myTask.ActivePathProcedure.Name));
// Output active process definition.
Logger.AddMessage(new LogMessage("The ActiveProcessDefinition is:" + myTask.ActiveProcessDefinition.Name));
// Output active tool.
Logger.AddMessage(new LogMessage("The ActiveTool is:" + myTask.ActiveTool.Name));
// Output active workobject.
Logger.AddMessage(new LogMessage("The ActiveWorkObject is:" + myTask.ActiveWorkObject.Name));
// Output the instruction descriptions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following InstructionDescriptions:"));
foreach (RsInstructionDescription descr in myTask.InstructionDescriptions)
{
Logger.AddMessage(new LogMessage(descr.Name));
}
// Output the process definitions in the task.
Logger.AddMessage(new LogMessage("The Task: '" + myTask.Name + "' contains the following ProcessDefinitions:"));
foreach (RsProcessDefinition def in myTask.ProcessDefinitions)
{
Logger.AddMessage(new LogMessage(def.Name));
}
// Output the frame of the task.
Logger.AddMessage(new LogMessage("The Frame of the Task is: "
+ "X: " + myTask.Frame.x
+ "; Y: " + myTask.Frame.y
+ "; Z: " + myTask.Frame.z
));
// Output the mechanism of the task.
Logger.AddMessage(new LogMessage("The mechanism of the task id '" + myTask.Mechanism.Name + "'"));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Events
ActivePathProcedureChanged
Occurs when the ActivePathProcedure property has changed.
Declaration
public event ProjectObjectPropertyChangedEventHandler ActivePathProcedureChanged
Event Type
Type | Description |
---|---|
ProjectObjectPropertyChangedEventHandler |
ActiveToolChanged
Occurs when the ActiveTool property has changed.
Declaration
public event ProjectObjectPropertyChangedEventHandler ActiveToolChanged
Event Type
Type | Description |
---|---|
ProjectObjectPropertyChangedEventHandler |
ActiveWorkObjectChanged
Occurs when the ActiveWorkObject property has changed.
Declaration
public event ProjectObjectPropertyChangedEventHandler ActiveWorkObjectChanged
Event Type
Type | Description |
---|---|
ProjectObjectPropertyChangedEventHandler |
RapidSynchronized
Occurs when RAPID synchronization is finished. This event is raised from the methods SyncPathProcedure(String, SyncDirection, ArrayList, ProgressNotification, Double, Double) and SyncData(String, SyncDirection, List<SyncLogMessage>).
Declaration
public event RapidSynchronizationEventHandler RapidSynchronized
Event Type
Type | Description |
---|---|
RapidSynchronizationEventHandler |