/// <summary> /// Initializes a new instance of the Robot class with attached external axes. /// </summary> /// <param name="name"> The name. </param> /// <param name="meshes"> The base and links meshes defined in the world coorindate space. </param> /// <param name="internalAxisPlanes"> The internal axes planes defined in the world coorindate space. </param> /// <param name="internalAxisLimits"> The internal axes limit. </param> /// <param name="basePlane"> The position and orientation of the robot base in the world coordinate space. </param> /// <param name="mountingFrame"> The tool mounting frame definied in the world coordinate space. </param> /// <param name="tool"> The Robot Tool. </param> /// <param name="externalAxes"> The attached external axes. </param> public Robot(string name, List <Mesh> meshes, List <Plane> internalAxisPlanes, List <Interval> internalAxisLimits, Plane basePlane, Plane mountingFrame, RobotTool tool, List <ExternalAxis> externalAxes) { // Robot related fields _name = name; _meshes = meshes; _internalAxisPlanes = internalAxisPlanes; _internalAxisLimits = internalAxisLimits; _basePlane = basePlane; _mountingFrame = mountingFrame; // Tool related fields _tool = tool.Duplicate(); // Make a deep copy since we transform it later _meshes.Add(GetAttachedToolMesh()); CalculateAttachedToolPlane(); // External axis related fields _externalAxes = externalAxes; _externalAxisPlanes = new List <Plane>(); _externalAxisLimits = new List <Interval>(); UpdateExternalAxisFields(); // Transform Robot Tool to Mounting Frame Transform trans = Transform.PlaneToPlane(_tool.AttachmentPlane, _mountingFrame); _tool.Transform(trans); // Set kinematics _inverseKinematics = new InverseKinematics(new RobotTarget("init", Plane.WorldXY), this); _forwardKinematics = new ForwardKinematics(this); }
/// <summary> /// Transforms the robot spatial properties (planes and meshes). /// NOTE: The attached external axes will not be transformed. /// </summary> /// <param name="xform"> Spatial deform. </param> public void Transfom(Transform xform) { _basePlane.Transform(xform); _mountingFrame.Transform(xform); _tool.Transform(xform); for (int i = 0; i < _meshes.Count; i++) { _meshes[i].Transform(xform); } for (int i = 0; i < _internalAxisPlanes.Count; i++) { Plane transformedPlane = new Plane(_internalAxisPlanes[i]); transformedPlane.Transform(xform); _internalAxisPlanes[i] = new Plane(transformedPlane); } CalculateAttachedToolPlane(); }