Having determined the optimal grasping pose for the end-effector matching the tomato cluster’s orientation, we proceed to perform inverse kinematics (IK) solving based on this pose. If the corresponding joint configurations can be successfully computed, the grasping pose is considered feasible. However, in many cases, the target point is located within the non-dexterous workspace of the manipulator, where the robot can often only reach the target with specific orientations. Consequently, the manipulator may be unable to reach the target point with the initially calculated pose, necessitating the determination of an alternative reachable pose that remains close to the original one. In this study, a combined approach utilizing an analytical solution and Particle Swarm Optimization (PSO) is employed to determine the reachable poses of the manipulator.
2.3.1. Analytical Method-Based Inverse Kinematics Analysis
The control of the manipulator’s end-effector requires a mapping from the Cartesian space position and orientation of the end-effector to the joint space. The process of determining each joint angle when the end-effector’s pose is known is referred to as IK. Based on the modified D-H parameters of the RM65-B manipulator in
Table 1 and the modeling rules, the transformation matrix
from the adjacent coordinate system
to
can be expressed as:
where
and
denote
and
, respectively.
From Equation (
8), the transformation matrices of
through
can be derived. Since an end-effector tool is attached to the manipulator in this study, it can be regarded as Link 7. Given that the orientation of the tool coordinate system is defined to be consistent with that of coordinate system 6, and the relative displacement can be obtained through direct measurement, the transformation matrix
between the adjacent coordinate systems is expressed as:
where
is a
identity matrix, representing that the orientation of the tool frame
is identical to that of frame
;
denotes the measured translation vector of the tool relative to frame
.
The transformation matrix from the manipulator base to the tool coordinate system, denoted as
, can be obtained by the sequential multiplication of the transformation matrices from
to
:
According to the D-H parameters, the first three joints (J1, J2, J3) of the manipulator primarily determine the end-effector position, while the axes of the last three joints (J4, J5, J6) intersect at a single point, forming a spherical wrist that is responsible for orientation adjustment. Owing to this spherical wrist configuration, the position and orientation can be kinematically decoupled. Let the target pose of the end-effector (Tool) be
, with its position vector denoted as
and its orientation matrix as
. The coordinates of the wrist center
W in the base coordinate system,
, can be obtained by the following equation:
During the IK solving process, the value of Joint 3 directly determines the extension state of the manipulator in the radial plane. Based on the geometric relationship and the Law of Cosines, consider the triangle formed by the center of Joint 2, the center of Joint 3, and the wrist center
W. Let the length of the upper arm be
and the effective length of the forearm be
. The cosine equation for Joint 3 can be derived from the coordinate transformation relationships as follows:
To ensure that the IK has real solutions, the condition
must be satisfied. Accordingly, the reachability discriminant operator
is defined as follows:
The physical significance of the discriminant lies in characterizing the mapping relationship between the target pose and the boundaries of the robot’s workspace. When , the target pose possesses inverse solutions within the physical space, indicating that it belongs to the reachable region. Conversely, when , the target pose lies beyond the range of the manipulator’s stroke.
2.3.2. Reachable Pose Solving via Particle Swarm Optimization
According to
Section 2.3.1, if
, the joint angles cannot be derived through inverse kinematics, indicating that the manipulator is unable to reach the harvesting pose. Consequently, PSO is employed to search for reachable grasping poses for the manipulator. By identifying the pose matrices that satisfy the condition
, the reachable grasping poses for the manipulator can be determined. The specific steps of the algorithm are as follows:
- (a)
Initialization of Particle Swarm
The position of a particle is determined by the three Euler angle components of the manipulator’s end-effector pose. Specifically, a set of Euler angles is represented as a single particle, where different Euler angles correspond to different position components. The particle is expressed as:
We take the harvesting pose calculated in
Section 2.2 as the initial pose, denoted as
. To ensure a high success rate for harvesting and to accelerate the convergence speed of the algorithm, certain constraints are imposed on the search space of the end-effector orientation. Specifically, when the manipulator is unable to execute harvesting at the initial pose, the orientation search space is restricted to a partial spherical surface centered at the initial pose. With
as the center, the search radius for each position component is set to
. Accordingly, the upper and lower bounds for each component are constrained as follows:
Next, centered at the initial pose , uniform sampling is performed on the search space spherical surface with a sampling interval of . By sampling three discrete values in each dimension, a total of 27 pose particles are obtained through combination, e.g., , , , …, . Subsequently, another 23 pose particles are randomly generated within the workspace range to form an initial population with a size of . For each particle i, the velocity vector is initialized, with its values randomly generated within the range .
- (b)
Fitness Evaluation
Since the manipulator possesses inverse solutions when
, it can be inferred that a larger value of
indicates a higher probability of reachability. Furthermore, as the initial pose is the optimal harvesting pose derived from the geometric analysis of the tomato cluster, the final end-effector pose should be as close to the initial pose as possible while ensuring reachability. Accordingly, the objective function and fitness function are designed as follows:
where
K is the objective function,
is the fitness function, and
and
are the weight coefficients.
and
denote the maximum and minimum values of the objective function calculated for all particles in the current swarm, respectively, while
represents the angular difference between the pose of particle
i and the initial pose. This fitness function reflects that a larger objective function value corresponds to higher fitness. Furthermore, since the target pose should be as close as possible to the initial pose, an angular difference penalty term is incorporated; thus, a smaller angular difference leads to higher fitness. The initial position of each particle is set as its individual historical best solution
, and the position of the particle with the highest fitness in the initial population is selected as the global best solution
.
- (c)
Velocity and Position Update
In each iteration, the Euler angle components of each particle are updated according to the following formulas:
where
is the inertia weight, which controls the influence of the previous velocity on the current state.
and
are acceleration constants that regulate the weights for adjusting the particle toward the individual best and global best solutions, respectively.
and
are random numbers within the range
, which enhance the randomness of the search.
To ensure that the search space is strictly confined within a radius
centered at the initial pose, the following constraints are imposed on position and velocity: if the updated Euler angle components exceed the range defined by Equation (
15), they are truncated to the boundaries of the search space. Meanwhile, to prevent particles from moving too fast and “overshooting,” an upper limit
is set for the velocity components. If
, then
.
- (d)
Individual and Global Best Updates
In each iteration, the following evaluations are performed for each particle: If the fitness of the current position is higher than the fitness of its historical best position , then is updated to . Similarly, if the fitness of the current position is higher than that of the global best position , then is updated to .
- (e)
Iteration and Termination
Repeat steps (b) through (d) until the algorithm satisfies either of the following termination criteria: (1) The maximum number of iterations is reached, at which point the loop terminates. (2) At least one particle in the swarm satisfies the objective function ; its position is then returned as the final pose solution. If multiple particles meet this condition, the one with the higher fitness value is selected as the output.
The flowchart of the PSO-based reachable pose solving algorithm is shown in
Figure 4. Through the optimization iterations of the PSO algorithm, the evaluated reachable grasping pose is finally obtained, and its transformation matrix is expressed as:
where
, and
represent the unit vectors of the gripper’s coordinate system (normal, orientation, and approach vectors, respectively), and
denotes the position vector of the grasp center.
Compared with conventional analytical or map-based reachability-aware grasp planners, the distinct novelty of the proposed method lies in its dynamic optimization paradigm. Standard methods primarily rely on pre-computed offline reachability maps or rigid inverse kinematics tables, which exhibit high offline database storage overhead and struggle to adapt to the highly unstructured and dynamically occluded environments of tomato greenhouses. In contrast, our approach treats reachability optimization as a continuous, real-world iterative search space. By feeding the semantic environment and cluster characteristics directly into the unified PSO fitness function, the optimal transformation matrix is dynamically resolved in real time. This flexible architecture empowers the manipulator to successfully discover dexterous harvesting poses even near the challenging boundaries of non-dexterous workspaces, establishing a significant departure from rigid, pre-mapped geometric grasp planning.