Skip to content

4.11 Coordinate System Class

Overview

The CoordinateSystem class is used to manage robot User Frames (UF) and Tool Frames (TF), and provides unified interfaces for adding, deleting, updating, querying, and calculating coordinate systems.

Core Features

  • Support getting user/tool coordinate system summary information list
  • Support adding, deleting, updating, and querying user/tool coordinate systems
  • Support calculating user/tool coordinate systems based on multiple input poses
  • Provide a unified coordinate system management interface to facilitate maintenance of coordinate system lists in the controller

Use Cases

  • Manage different tool coordinate systems during tool switching
  • Maintain consistent spatial references during multi-station debugging
  • Batch management and querying of robot coordinate systems
  • Quickly calculate new user/tool coordinate systems from taught points

4.11.1 Get User/Tool Coordinate System List

Method NameCoordinateSystem.GetCoordinateList(CoordinateType type )
DescriptionGets all coordinate system summary information list for the specified coordinate type.
Request Parameterstype : CoordinateType Coordinate type (UF or TF)
Return ValueList<CoordSummary>: Coordinate summary list
StatusCode: Operation execution result
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

4.11.2 Add User/Tool Coordinate System

Method NameCoordinateSystem.Add(CoordinateType type , Coordinate coordinate )
DescriptionAdds a new coordinate system for the specified coordinate type.
Request Parameterstype : CoordinateType Coordinate type (UF or TF)
coordinate : Coordinate Coordinate data to add
Return ValueStatusCode: Operation execution result
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

4.11.3 Delete User/Tool Coordinate System

Method NameCoordinateSystem.Delete(CoordinateType type , int index )
DescriptionDeletes the coordinate system specified by coordinate type and index.
Request Parameterstype : CoordinateType Coordinate type (UF or TF)
index : int Coordinate index
Return ValueStatusCode: Operation execution result
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

4.11.4 Update User/Tool Coordinate System

Method NameCoordinateSystem.Update(CoordinateType type , Coordinate coordinate )
DescriptionUpdates the coordinate system for the specified coordinate type and coordinate information.
Request Parameterstype : CoordinateType Coordinate type (UF or TF)
coordinate : Coordinate Coordinate data to update
Return ValueStatusCode: Operation execution result
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

4.11.5 Get User/Tool Coordinate System Information

Method NameCoordinateSystem.Get(CoordinateType type , int index )
DescriptionGets coordinate system information by coordinate type and index.
Request Parameterstype : CoordinateType Coordinate type (UF or TF)
index : int Coordinate index
Return ValueCoordinate: Coordinate data
StatusCode: Operation execution result
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

4.11.6 Calculate User/Tool Coordinate System

Method NameCoordinateSystem.Calculate(CoordinateType type , List<Position> pose )
DescriptionCalculates a user/tool coordinate system from input pose points.
Request Parameterstype : CoordinateType Coordinate type (UF or TF)
pose : List<Position> Input pose list. Supports 4-point or 7-point method. In 4-point method, provide 4 poses where the tool points to the same target point. In 7-point method, additionally provide origin, X-direction point, and Y-direction point. Angle unit: degree (°).
Return ValuePosition: Calculated coordinate pose
StatusCode: Operation execution result
Compatible robot software versionCollaborative (Copper): v7.5.0.0+
Industrial (Bronze): v7.5.0.0+

Example Code

CoordinateSystem/TFCoordinateTest.cs
cs
using Agilebot.IR;
using Agilebot.IR.CoordinateSystem;
using Agilebot.IR.Types;

public class TFCoordinateTest
{
    /// <summary>
    /// 测试 TF 坐标系的计算、添加、获取列表、获取单个坐标系、更新和删除操作
    /// </summary>
    public static StatusCode Run(string controllerIP, bool useLocalProxy = true)
    {
        // [ZH] 初始化捷勃特机器人
        // [EN] Initialize the Agilebot robot
        Arm controller = new Arm(controllerIP, useLocalProxy);

        // [ZH] 连接捷勃特机器人
        // [EN] Connect to the Agilebot robot
        StatusCode code = controller.ConnectSync();
        Console.WriteLine(code != StatusCode.OK ? code.GetDescription() : "连接成功/Successfully connected.");

        if (code != StatusCode.OK)
        {
            return code;
        }

        try
        {
            // [ZH] 准备测试数据
            // [EN] Prepare test data
            var poseData = new List<Position>
            {
                new Position(847.0999429718556, 166.7999999999656, 276.8195498896624, 90, 0, -70),
                new Position(809.0227439212846, 166.79999999994843, 459.80354972094295, 90, 0, -45),
                new Position(717.1223240422377, 166.79999999993265, 654.0891675073312, 90, 0, -30),
                new Position(572.917828754028, 166.79999999992168, 825.1862002007621, 90, 0, -40),
            };

            Console.WriteLine("开始TF坐标系测试/Starting TF Coordinate Test");

            // [ZH] 计算坐标系
            // [EN] Calculate coordinate system
            Coordinate calculatedCoord = new Coordinate();
            (Position coord, StatusCode calculateCode) = controller.CoordinateSystem.Calculate(
                CoordinateType.ToolCoordinate,
                poseData
            );

            if (code == StatusCode.OK)
            {
                Console.WriteLine("计算TF坐标系成功/Calculate TF Coordinate Success");
            }
            else
            {
                Console.WriteLine($"计算TF坐标系失败/Calculate TF Coordinate Failed: {code.GetDescription()}");
                return code;
            }
            calculatedCoord.Id = 5;
            calculatedCoord.Data = coord;

            // [ZH] 删除可能存在的坐标系
            // [EN] Delete existing coordinate if exists
            StatusCode deleteCode = controller.CoordinateSystem.Delete(
                CoordinateType.ToolCoordinate,
                calculatedCoord.Id
            );
            Console.WriteLine($"删除现有坐标系/Delete Existing Coordinate: {deleteCode.GetDescription()}");

            // [ZH] 添加坐标系
            // [EN] Add coordinate system
            StatusCode addCode = controller.CoordinateSystem.Add(CoordinateType.ToolCoordinate, calculatedCoord);
            if (addCode == StatusCode.OK)
            {
                Console.WriteLine("添加TF坐标系成功/Add TF Coordinate Success");
            }
            else
            {
                Console.WriteLine($"添加TF坐标系失败/Add TF Coordinate Failed: {addCode.GetDescription()}");
                return addCode;
            }

            // [ZH] 获取坐标系列表
            // [EN] Get coordinate list
            List<CoordSummary> listRes;
            (listRes, code) = controller.CoordinateSystem.GetCoordinateList(CoordinateType.ToolCoordinate);
            if (code == StatusCode.OK)
            {
                Console.WriteLine("获取TF坐标系列表成功/Get TF Coordinate List Success");
                Console.WriteLine($"坐标系列表数量/Coordinate List Count: {listRes.Count}");
            }
            else
            {
                Console.WriteLine($"获取TF坐标系列表失败/Get TF Coordinate List Failed: {code.GetDescription()}");
                return code;
            }

            // [ZH] 获取单个坐标系
            // [EN] Get single coordinate
            Coordinate getCoord;
            (getCoord, code) = controller.CoordinateSystem.Get(CoordinateType.ToolCoordinate, calculatedCoord.Id);
            if (code == StatusCode.OK)
            {
                Console.WriteLine("获取TF坐标系成功/Get TF Coordinate Success");
                Console.WriteLine($"坐标系名称/Coordinate Name: {getCoord.Name}");
            }
            else
            {
                Console.WriteLine($"获取TF坐标系失败/Get TF Coordinate Failed: {code.GetDescription()}");
                return code;
            }

            // [ZH] 更新坐标系
            // [EN] Update coordinate system
            getCoord.Name = "test";
            StatusCode updateCode = controller.CoordinateSystem.Update(CoordinateType.ToolCoordinate, getCoord);
            if (updateCode == StatusCode.OK)
            {
                Console.WriteLine("更新TF坐标系成功/Update TF Coordinate Success");
            }
            else
            {
                Console.WriteLine($"更新TF坐标系失败/Update TF Coordinate Failed: {updateCode.GetDescription()}");
                return updateCode;
            }

            // [ZH] 删除坐标系
            // [EN] Delete coordinate system
            deleteCode = controller.CoordinateSystem.Delete(CoordinateType.ToolCoordinate, calculatedCoord.Id);
            if (deleteCode == StatusCode.OK)
            {
                Console.WriteLine("删除TF坐标系成功/Delete TF Coordinate Success");
            }
            else
            {
                Console.WriteLine($"删除TF坐标系失败/Delete TF Coordinate Failed: {deleteCode.GetDescription()}");
                return deleteCode;
            }

            Console.WriteLine("TF坐标系测试完成/TF Coordinate Test Completed");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"执行过程中发生异常/Exception occurred during execution: {ex.Message}");
            code = StatusCode.OtherReason;
        }
        finally
        {
            // [ZH] 关闭连接
            // [EN] Close the connection
            StatusCode disconnectCode = controller.Disconnect();
            if (disconnectCode != StatusCode.OK)
            {
                Console.WriteLine(disconnectCode.GetDescription());
                if (code == StatusCode.OK)
                    code = disconnectCode;
            }
        }

        return code;
    }
}