Class NcKinematicsDependency
- Namespace
- Hi.NcParsers.Dependencys.SystemWired
- Assembly
- HiMech.dll
Provides IMachineKinematics as an INcDependency for SoftNcRunner.PipelineNcDependencyList.
The actual kinematics instance is resolved at runtime via KinematicsProvider. This supports scenarios where the machine tool is loaded or changed after the runner is configured (e.g., XML config loaded first, kinematics assigned later).
Consumed by G53p1RotaryPositionSyntax,
IsoG68p2TiltSyntax, and
McLinearMotionSemantic via
dependencyList.OfType<IMachineKinematics>().
public class NcKinematicsDependency : INcDependency, IMakeXmlSource, IMachineKinematics
- Inheritance
-
NcKinematicsDependency
- Implements
- Inherited Members
- Extension Methods
Constructors
NcKinematicsDependency()
Initializes a new instance with no KinematicsProvider; assign one before the runner queries kinematics.
public NcKinematicsDependency()
NcKinematicsDependency(Func<IMachineKinematics>)
Initializes a new instance with the given KinematicsProvider.
public NcKinematicsDependency(Func<IMachineKinematics> provider)
Parameters
providerFunc<IMachineKinematics>Delegate that resolves the live IMachineKinematics at lookup time.
Properties
KinematicsOrNull
Non-throwing probe: the live kinematics instance, or null when
the provider is unwired or resolves to null (e.g. the machining chain
is a ClMillingDevice, so no XyzabcSolver exists). Lets a
syntax/semantic that supports both CL and MC chains branch on
availability instead of catching InvalidOperationException
from the IMachineKinematics members.
public IMachineKinematics KinematicsOrNull { get; }
Property Value
KinematicsProvider
Runtime provider for the kinematics instance. Null provider or null return means kinematics is not yet available.
public Func<IMachineKinematics> KinematicsProvider { get; set; }
Property Value
ProgramZeroToPnOrNull
The program-zero → Pn transform resolved via
ProgramZeroToPnProvider, or null when
unwired/unavailable; consumers fall back to identity (workpiece frame
≡ Pn frame).
public mat4d_t? ProgramZeroToPnOrNull { get; }
Property Value
ProgramZeroToPnProvider
Runtime provider for the rigid transform from program-zero (workpiece)
coordinates to the kinematic Pn frame, for pipelines whose source
positions live in the workpiece frame (the NX CLSF pipeline). NC
G-code pipelines leave it unwired — their program→MC mapping is
carried per block by work-offset transform sections instead. The host
wires it from the equipment topology
(MachiningEquipmentUtil.GetProgramToPnMat4d); the provider is
resolved per call so a re-aligned workpiece is picked up without
rewiring.
public Func<mat4d_t?> ProgramZeroToPnProvider { get; set; }
Property Value
UnavailableReasonProvider
Why KinematicsProvider answers null when it does, for the exception the throwing accessor raises: the host that refused to build the solver (a machine chain whose mounts are not connected, or one with a role branch marked as an error term) sets it, so the first block that needs the kinematics fails with the reason named instead of a bare “returned null”. Null or empty adds nothing.
public Func<string> UnavailableReasonProvider { get; set; }
Property Value
XName
XML element name used to register this dependency with XFactory.
public static string XName { get; }
Property Value
Methods
MakeXmlSource(string, string, bool)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.
McAbcToMat(vec3d_t)
Converts machine ABC coordinates to a tilt matrix. the tilt matrix is the transformation matrix from table to attacher.
public mat4d_t McAbcToMat(vec3d_t mcAbc_rad)
Parameters
mcAbc_radvec3d_tThe machine ABC coordinates in radians
Returns
- mat4d_t
The tilt matrix
McToMat(dvec3d_t)
Converts machine coordinates to an attacher matrix.
public mat4d_t McToMat(dvec3d_t mcXyzabc)
Parameters
mcXyzabcdvec3d_tThe machine coordinates
Returns
- mat4d_t
The attacher matrix
McToPn(dvec3d_t)
Machine coordinate to tool attacher Pn (Point and Normal). The Pn is from table mount to tool attacher.
public dvec3d_t McToPn(dvec3d_t mcXyzabc)
Parameters
mcXyzabcdvec3d_tmachine coordinate. ABC is in radian.
Returns
- dvec3d_t
tool attacher Pn (Point and Normal)
OrientationToMcAbc(mat4d_t, out vec3d_t)
Converts a tilt matrix to machine ABC coordinates.
the tilt matrix is the transformation matrix from table to attacher.
the solution only fit the orientation part of the tiltMat.
public bool OrientationToMcAbc(mat4d_t tiltMat, out vec3d_t mcAbc_rad)
Parameters
tiltMatmat4d_tThe tilt matrix to convert
mcAbc_radvec3d_tOutput parameter that will contain the machine ABC coordinates in radians
Returns
- bool
Whether the conversion was successful: the orientation the answer realises meets the target within the solver's polish tolerance (about 1e-6 rad; see SetPn(dvec3d_t, out dvec3d_t)); on false the solver state is as it was on entry. A matrix with a NaN or an infinite element is refused (false, a NaN out value).
OrientationToMcAbc(mat4d_t, AbcTravel, out vec3d_t)
OrientationToMcAbc(mat4d_t, out vec3d_t) restricted to the
rotary travel travel (the machine's A/B/C stroke
limits, typically). A full orientation fixes the rotary positions up to
axis periodicity, so a solution outside the travel is a posture this
machine cannot take: the conversion then fails (false) and leaves the
solver state as it was, so that the caller can fall back to
OrientationToMcAbc(vec3d_t, AbcTravel, out vec3d_t), where
the free rotation about the tool axis opens the other branch. A null
travel, or one without any configured end
(HasAnyLimit false), does not restrict: this is
then the plain overload.
The travel is data, not a delegate: XyzabcSolver runs its inverse kinematics in core.dll and hands the record there. Build it from the runner's dependency list with RotaryTravel(IEnumerable<INcDependency>). The default implementation is the plain solve, refused when IsAdmissible(vec3d_t) refuses its result.
public bool OrientationToMcAbc(mat4d_t tiltMat, AbcTravel travel, out vec3d_t mcAbc_rad)
Parameters
tiltMatmat4d_tThe tilt matrix to convert.
travelAbcTravelThe rotary travel to respect; null, or a record without any configured end, does not restrict.
mcAbc_radvec3d_tOutput machine ABC coordinates in radians.
Returns
- bool
Whether an admissible conversion was found.
OrientationToMcAbc(vec3d_t, out vec3d_t)
Converts a target tool axial direction (endpoint orientation) to machine ABC coordinates. Only the axial alignment is constrained; rotation about the tool axis is free.
Use this in place of OrientationToMcAbc(mat4d_t, out vec3d_t) when the
rotation about the tool axis is irrelevant (e.g. G53.1 rotary positioning). The
axial-only solve avoids the redundant 6-target full-matrix constraint and is more
likely to converge for tilt configurations such as G68.2 I180 J90 K0.
public bool OrientationToMcAbc(vec3d_t toolAxialNormal, out vec3d_t mcAbc_rad)
Parameters
toolAxialNormalvec3d_tTarget tool axial direction in table coordinates (the third row of the tilt matrix; e.g. AxialNormal).
mcAbc_radvec3d_tOutput machine ABC coordinates in radians.
Returns
- bool
Whether the conversion was successful: the tool axis the answer realises meets the target within the solver's polish tolerance (about 1e-6 rad; see SetPn(dvec3d_t, out dvec3d_t)); on false the solver state is as it was on entry. A normal with a NaN or an infinite component is refused (false, a NaN out value).
OrientationToMcAbc(vec3d_t, AbcTravel, out vec3d_t)
OrientationToMcAbc(vec3d_t, out vec3d_t) preferring the
solution branch inside the rotary travel travel. The
axial-only problem has two branches on a two-rotary-axis machine
(on a table-table A/C: (A, C) and (−A, C+180°)); the plain overload
returns the branch nearest the solver's seed, which from the rotary
pole (A0 C0) is the one the tilt's azimuth happens to favour — half
the time the branch a cradle table with an asymmetric tilt travel
cannot reach (CHEM20180926 N100: G68.2 I210 J-90 + G53.1
solved to A=+90° on a −120°…+30° A axis). When the nearest branch is
outside the travel, an implementation with a real solver searches the
other branches and returns the admissible one nearest the seed; when
none is admissible it returns the refused solution and true, and the
stroke-limit check downstream reports it. A null travel, or one without
any configured end (HasAnyLimit false), makes
this the plain overload.
The travel is data, not a delegate: XyzabcSolver runs the solve and the branch search in core.dll and hands the record there. Build it from the runner's dependency list with RotaryTravel(IEnumerable<INcDependency>). The default implementation is the plain solve — the travel is advisory for an implementation without a solver, which searches no branch.
public bool OrientationToMcAbc(vec3d_t toolAxialNormal, AbcTravel travel, out vec3d_t mcAbc_rad)
Parameters
toolAxialNormalvec3d_tTarget tool axial direction in table coordinates.
travelAbcTravelThe rotary travel to prefer; null, or a record without any configured end, does not restrict.
mcAbc_radvec3d_tOutput machine ABC coordinates in radians.
Returns
- bool
Whether the conversion was successful (admissible or not).
PnToMc(dvec3d_t, out dvec3d_t)
Tool attacher Pn (Point and Normal) to machine coordinate. The Pn is from table mount to tool attacher.
public bool PnToMc(dvec3d_t pn, out dvec3d_t mcXyzabc_rad)
Parameters
pndvec3d_ttool attacher Pn (Point and Normal)
mcXyzabc_raddvec3d_tmachine coordinate (ABC in radian)
Returns
- bool
whether conversion succeeded; a pn with a NaN or an infinite component is refused (false, a NaN out value)
Reg(XFactory)
Registers this type's deserializer with the given XFactory
(or Default when factory is
null). Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory