Modifying Position and Orientation
This example provides information on translating (moving) and rotating targets. This example expects targets are already created. The translation and rotation of targets can be seen graphically.
Solution
Change position in the 3D space of your simulation by changing the translation for each axis
// Translate the target's frame target.RobTarget.Frame.X = 0.5; target.RobTarget.Frame.Y = 0.2; target.RobTarget.Frame.Z = 0.2;Rotate target
// Rotate the frame by 90 degrees around the x-axis target.RobTarget.Frame.RX += System.Math.PI / 2; // Rotate the frame by 180 degrees around the y-axis target.RobTarget.Frame.RY += System.Math.PI;
Example
This example provides information on translating and rotating targets in RobotStudio.
// Begin UndoStep
Project.UndoContext.BeginUndoStep("Rotate");
try
{
// Get the targets from the active station and task
RsTargetCollection existingTargets = Station.ActiveStation.ActiveTask.Targets;
// Translate and rotate each target
foreach (RsTarget target in existingTargets)
{
// Translate the target's frame
target.RobTarget.Frame.X = 0.5;
target.RobTarget.Frame.Y = 0.2;
target.RobTarget.Frame.Z = 0.2;
// Rotate the frame by 90 degrees around the x-axis
target.RobTarget.Frame.RX += System.Math.PI / 2;
// Rotate the frame by 180 degrees around the y-axis
target.RobTarget.Frame.RY += System.Math.PI;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Required Namespaces
ABB.Robotics.RobotStudio.Stations