Creating RsToolData
This example provides information on creating a tool for your robot. The tool is defined by RsToolData (e.g. tool center point, if the robot holds the tool or not, the name of the tool), and the load of the tool is defined by RsLoadData (e.g. mass, center of gravity).
Solution
Create a RsTooldata object.
// Create a gripper tool using sample data from the RAPID manual. RsToolData myTool = new RsToolData();Set the Tool Center Point, expressed in the wrist coordinate system.
// Set the TCP, expressed in the wrist coordinate system. myTool.Frame.X = 0.0974; myTool.Frame.Y = 0; myTool.Frame.Z = 0.2231; myTool.Frame.RX = Globals.DegToRad(45); myTool.Frame.RY = 0; myTool.Frame.RZ = Globals.DegToRad(45);Create and attach load data for the tool.
// Create the load data for the tool. RsLoadData myloadData = new RsLoadData(); // Set mass. myloadData.Mass = 5; // Set center of gravity. myloadData.Cog = new Vector3(0.023, 0, 0.075); // Set the axis of moment. myloadData.Aom = new Quaternion(1, 0, 0, 0); // The load can be considered a point mass in this example, i.e. without any moment of inertia. myloadData.Inertia = new Vector3(0, 0, 0); // Att the load data to the tool. myTool.LoadData = myloadData;Add the tool data to the active task.
// Add the tool data to the ActiveTask. station.ActiveTask.DataDeclarations.Add(myTool);
Example
This example provides information on creating tool data.
private static void CreateRsToolData()
{
Project.UndoContext.BeginUndoStep("RsToolDataExample");
try
{
Station station = Station.ActiveStation;
// Create a gripper tool using sample data from the RAPID manual.
RsToolData myTool = new RsToolData();
// Get a valid RAPID name and assign it.
myTool.Name = station.ActiveTask.GetValidRapidName("gripper", "_", 1);
// The robot is holding the tool.
myTool.RobotHold = true;
// Set the TCP, expressed in the wrist coordinate system.
myTool.Frame.X = 0.0974;
myTool.Frame.Y = 0;
myTool.Frame.Z = 0.2231;
myTool.Frame.RX = Globals.DegToRad(45);
myTool.Frame.RY = 0;
myTool.Frame.RZ = Globals.DegToRad(45);
// Create the load data for the tool.
RsLoadData myloadData = new RsLoadData();
// Set mass.
myloadData.Mass = 5;
// Set center of gravity.
myloadData.Cog = new Vector3(0.023, 0, 0.075);
// Set the axis of moment.
myloadData.Aom = new Quaternion(1, 0, 0, 0);
// The load can be considered a point mass in this example, i.e. without any moment of inertia.
myloadData.Inertia = new Vector3(0, 0, 0);
// Att the load data to the tool.
myTool.LoadData = myloadData;
// Show the name of the tool data in the graphics.
myTool.ShowName = true;
// Set the frame size to twice its default size.
myTool.FrameSize = myTool.FrameSize * 2;
// Show the tool data in the graphics.
myTool.Visible = true;
// Add the tool data to the ActiveTask.
station.ActiveTask.DataDeclarations.Add(myTool);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
}
Required Namespaces
ABB.Robotics.RobotStudio.Stations