File syn_kinematics.c¶
FileList > motor > syn_kinematics.c
Go to the source code of this file
Multi-Axis Robot Forward & Inverse Kinematics Engine Implementation.
#include "../port/syn_port_system.h"#include "syn_kinematics.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_dh_matrix (const SYN_DH_Param * param, q16_t joint_val, SYN_DH_Convention conv, SYN_Matrix * out_t44) Compute single-link 4x4 Homogeneous Transformation Matrix from DH parameters. |
| SYN_Status | syn_kinematics_6dof_fk (const SYN_Kinematics_6DOFConfig * cfg, const q16_t q, SYN_Pose6D * out_pose) Forward kinematics for 6-DOF articulated arm. |
| SYN_Status | syn_kinematics_6dof_ik (const SYN_Kinematics_6DOFConfig * cfg, const SYN_Pose6D * target, SYN_ArmElbow elbow, bool wrist_flip, q16_t out_q) Closed-form inverse kinematics for 6-DOF arm with spherical wrist (Pieper solution). |
| SYN_Status | syn_kinematics_delta_fk (const SYN_Kinematics_DeltaConfig * cfg, q16_t theta1, q16_t theta2, q16_t theta3, SYN_Position3D * out_pos) Forward kinematics for 3-axis Delta parallel robot. |
| SYN_Status | syn_kinematics_delta_ik (const SYN_Kinematics_DeltaConfig * cfg, const SYN_Position3D * target, q16_t * out_theta1, q16_t * out_theta2, q16_t * out_theta3) Inverse kinematics for 3-axis Delta parallel robot. |
| SYN_Status | syn_kinematics_forward (const SYN_DH_Param * chain, size_t num_joints, const q16_t * joint_vals, SYN_DH_Convention conv, SYN_Matrix * out_t44, SYN_Pose6D * out_pose) Compute Forward Kinematics for a general serial DH chain. |
| SYN_Status | syn_kinematics_jacobian (const SYN_DH_Param * chain, size_t num_joints, const q16_t * joint_vals, SYN_DH_Convention conv, SYN_Matrix * out_j6xn) Calculate Geometric 6xN Jacobian Matrix for a serial link chain. |
| SYN_Status | syn_kinematics_planar3_fk (const SYN_Kinematics_Planar3Config * cfg, q16_t q1, q16_t q2, q16_t q3, q16_t * out_x, q16_t * out_y, q16_t * out_phi) Forward kinematics for 3-DOF planar arm. |
| SYN_Status | syn_kinematics_planar3_ik (const SYN_Kinematics_Planar3Config * cfg, q16_t x, q16_t y, q16_t phi, SYN_ArmElbow elbow, q16_t * out_q1, q16_t * out_q2, q16_t * out_q3) Closed-form inverse kinematics for 3-DOF planar arm. |
| SYN_Status | syn_kinematics_scara_fk (const SYN_Kinematics_SCARAConfig * cfg, q16_t q1, q16_t q2, q16_t d3, q16_t q4, SYN_Pose6D * out_pose) Forward kinematics for 4-DOF SCARA robot. |
| SYN_Status | syn_kinematics_scara_ik (const SYN_Kinematics_SCARAConfig * cfg, const SYN_Pose6D * target, SYN_ArmElbow elbow, q16_t * out_q1, q16_t * out_q2, q16_t * out_d3, q16_t * out_q4) Closed-form inverse kinematics for 4-DOF SCARA robot. |
Public Static Functions¶
| Type | Name |
|---|---|
| SYN_Status | delta_calc_arm (q16_t x0, q16_t y0, q16_t z0, q16_t L, q16_t l, q16_t * out_theta) Helper to solve single Delta arm angle. |
| void | rot_matrix_to_rpy (const q16_t r33, SYN_Orientation3D * out_ori) Extract Roll-Pitch-Yaw Euler angles from 3x3 rotation matrix. |
| void | rpy_to_rot_matrix (q16_t roll, q16_t pitch, q16_t yaw, q16_t r33) Build 3x3 rotation matrix from Roll-Pitch-Yaw Euler angles (Z-Y-X order). |
Macros¶
| Type | Name |
|---|---|
| define | Q16_COS120 (([**q16\_t**](syn__qmath_8h.md#typedef-q16_t)) - 32768) |
| define | Q16_COS240 (([**q16\_t**](syn__qmath_8h.md#typedef-q16_t)) - 32768) |
| define | Q16_SIN120 56756 |
| define | Q16_SIN240 (([**q16\_t**](syn__qmath_8h.md#typedef-q16_t)) - 56756) |
| define | Q16_SQRT3_2 56756 |
Public Functions Documentation¶
function syn_dh_matrix¶
Compute single-link 4x4 Homogeneous Transformation Matrix from DH parameters.
SYN_Status syn_dh_matrix (
const SYN_DH_Param * param,
q16_t joint_val,
SYN_DH_Convention conv,
SYN_Matrix * out_t44
)
Parameters:
paramDH parameters for link.joint_valJoint variable (angle in rad for revolute, displacement for prismatic).convDH convention (standard or modified).out_t44Output 4x4 matrix (must be initialized with 4 rows, 4 cols).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL or dimension error.
function syn_kinematics_6dof_fk¶
Forward kinematics for 6-DOF articulated arm.
SYN_Status syn_kinematics_6dof_fk (
const SYN_Kinematics_6DOFConfig * cfg,
const q16_t q,
SYN_Pose6D * out_pose
)
Parameters:
cfg6-DOF arm configuration.qArray of 6 joint angles in radians.out_poseOutput 6-DOF Cartesian pose.
Returns:
SYN_OK on success.
function syn_kinematics_6dof_ik¶
Closed-form inverse kinematics for 6-DOF arm with spherical wrist (Pieper solution).
SYN_Status syn_kinematics_6dof_ik (
const SYN_Kinematics_6DOFConfig * cfg,
const SYN_Pose6D * target,
SYN_ArmElbow elbow,
bool wrist_flip,
q16_t out_q
)
Parameters:
cfg6-DOF arm configuration.targetTarget 6-DOF pose.elbowShoulder/elbow solution choice.wrist_flipInvert wrist pitch/yaw solution if true.out_qOutput array of 6 joint angles in radians.
Returns:
SYN_OK on success, SYN_ERROR if target position or orientation unreachable.
function syn_kinematics_delta_fk¶
Forward kinematics for 3-axis Delta parallel robot.
SYN_Status syn_kinematics_delta_fk (
const SYN_Kinematics_DeltaConfig * cfg,
q16_t theta1,
q16_t theta2,
q16_t theta3,
SYN_Position3D * out_pos
)
Parameters:
cfgDelta robot geometry configuration.theta1Actuator 1 angle (rad).theta2Actuator 2 angle (rad).theta3Actuator 3 angle (rad).out_posOutput 3D Cartesian position of traveling plate center.
Returns:
SYN_OK on success, SYN_ERROR if no real geometric intersection exists.
function syn_kinematics_delta_ik¶
Inverse kinematics for 3-axis Delta parallel robot.
SYN_Status syn_kinematics_delta_ik (
const SYN_Kinematics_DeltaConfig * cfg,
const SYN_Position3D * target,
q16_t * out_theta1,
q16_t * out_theta2,
q16_t * out_theta3
)
Parameters:
cfgDelta robot geometry configuration.targetTarget 3D Cartesian position (X, Y, Z).out_theta1Output actuator 1 angle (rad).out_theta2Output actuator 2 angle (rad).out_theta3Output actuator 3 angle (rad).
Returns:
SYN_OK on success, SYN_ERROR if position is outside workspace.
function syn_kinematics_forward¶
Compute Forward Kinematics for a general serial DH chain.
SYN_Status syn_kinematics_forward (
const SYN_DH_Param * chain,
size_t num_joints,
const q16_t * joint_vals,
SYN_DH_Convention conv,
SYN_Matrix * out_t44,
SYN_Pose6D * out_pose
)
Parameters:
chainArray of DH joint parameters.num_jointsNumber of joints in chain (<= SYN_KINEMATICS_MAX_JOINTS).joint_valsArray of joint values.convDH convention.out_t44Optional output 4x4 end-effector transform matrix (can be NULL).out_poseOptional output 6-DOF pose (can be NULL).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid inputs.
function syn_kinematics_jacobian¶
Calculate Geometric 6xN Jacobian Matrix for a serial link chain.
SYN_Status syn_kinematics_jacobian (
const SYN_DH_Param * chain,
size_t num_joints,
const q16_t * joint_vals,
SYN_DH_Convention conv,
SYN_Matrix * out_j6xn
)
Parameters:
chainArray of DH joint parameters.num_jointsNumber of joints in chain.joint_valsCurrent joint positions.convDH convention.out_j6xnOutput 6xN matrix (rows=6, cols=num_joints).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid inputs.
function syn_kinematics_planar3_fk¶
Forward kinematics for 3-DOF planar arm.
SYN_Status syn_kinematics_planar3_fk (
const SYN_Kinematics_Planar3Config * cfg,
q16_t q1,
q16_t q2,
q16_t q3,
q16_t * out_x,
q16_t * out_y,
q16_t * out_phi
)
Parameters:
cfgPlanar arm configuration.q1Joint 1 angle (rad).q2Joint 2 angle (rad).q3Joint 3 angle (rad).out_xPointer to receive X position.out_yPointer to receive Y position.out_phiPointer to receive tool orientation angle (rad).
Returns:
SYN_OK on success.
function syn_kinematics_planar3_ik¶
Closed-form inverse kinematics for 3-DOF planar arm.
SYN_Status syn_kinematics_planar3_ik (
const SYN_Kinematics_Planar3Config * cfg,
q16_t x,
q16_t y,
q16_t phi,
SYN_ArmElbow elbow,
q16_t * out_q1,
q16_t * out_q2,
q16_t * out_q3
)
Parameters:
cfgPlanar arm configuration.xTarget X position.yTarget Y position.phiTarget end-effector orientation angle (rad).elbowElbow configuration (up or down).out_q1Output joint 1 angle.out_q2Output joint 2 angle.out_q3Output joint 3 angle.
Returns:
SYN_OK on success, SYN_ERROR if target unreachable.
function syn_kinematics_scara_fk¶
Forward kinematics for 4-DOF SCARA robot.
SYN_Status syn_kinematics_scara_fk (
const SYN_Kinematics_SCARAConfig * cfg,
q16_t q1,
q16_t q2,
q16_t d3,
q16_t q4,
SYN_Pose6D * out_pose
)
Parameters:
cfgSCARA configuration.q1Joint 1 shoulder angle (rad).q2Joint 2 elbow angle (rad).d3Joint 3 prismatic vertical displacement (distance down).q4Joint 4 wrist roll angle (rad).out_poseOutput 4-DOF pose (X, Y, Z, Yaw).
Returns:
SYN_OK on success.
function syn_kinematics_scara_ik¶
Closed-form inverse kinematics for 4-DOF SCARA robot.
SYN_Status syn_kinematics_scara_ik (
const SYN_Kinematics_SCARAConfig * cfg,
const SYN_Pose6D * target,
SYN_ArmElbow elbow,
q16_t * out_q1,
q16_t * out_q2,
q16_t * out_d3,
q16_t * out_q4
)
Parameters:
cfgSCARA configuration.targetTarget 6-DOF pose (X, Y, Z, Yaw).elbowElbow configuration (up/left or down/right).out_q1Output joint 1 angle.out_q2Output joint 2 angle.out_d3Output joint 3 vertical position.out_q4Output joint 4 wrist angle.
Returns:
SYN_OK on success, SYN_ERROR if target unreachable.
Public Static Functions Documentation¶
function delta_calc_arm¶
Helper to solve single Delta arm angle.
static SYN_Status delta_calc_arm (
q16_t x0,
q16_t y0,
q16_t z0,
q16_t L,
q16_t l,
q16_t * out_theta
)
Parameters:
x0Projected X coordinate.y0Projected Y coordinate.z0Projected Z coordinate.LUpper arm length.lLower arm parallelogram length.out_thetaPointer to receive solved arm angle.
Returns:
SYN_OK on success, SYN_ERROR if target is unreachable.
function rot_matrix_to_rpy¶
Extract Roll-Pitch-Yaw Euler angles from 3x3 rotation matrix.
Parameters:
r33Flat 9-element Q16 array.out_oriOutput 3D orientation.
function rpy_to_rot_matrix¶
Build 3x3 rotation matrix from Roll-Pitch-Yaw Euler angles (Z-Y-X order).
Parameters:
rollRoll angle (rad).pitchPitch angle (rad).yawYaw angle (rad).r33Flat 9-element Q16 array for 3x3 rotation matrix.
Macro Definition Documentation¶
define Q16_COS120¶
cos(120 deg) in Q16
define Q16_COS240¶
cos(240 deg) in Q16
define Q16_SIN120¶
sin(120 deg) in Q16
define Q16_SIN240¶
sin(240 deg) in Q16
define Q16_SQRT3_2¶
sqrt(3)/2 ≈ 0.866025 in Q16
The documentation for this class was generated from the following file src/syntropic/motor/syn_kinematics.c