This project simulates and visualizes the kinematics of a prosthetic thumb mechanism. The thumb is modeled as a 4-bar linkage (BCDE) with an additional triangular linkage (DEF) to define a point of interest, F. The simulation explores the range of motion of this mechanism in both 2D and 3D space.
- The 2D simulation (
show.py) analyzes the motion of the 4-bar linkage in a single plane, driven by an angletheta_drive. - The 3D visualization (
visualize_thumb_3d.py) extends this by placing the 2D linkage in a 3D global coordinate system. It introduces a second degree of freedom,theta_A, which rotates the entire 2D linkage plane around the global Y-axis. The script then calculates and visualizes the 3D workspace of point F and shows snapshots of the linkage in various configurations.
The global origin (0,0,0) is considered to be at a point 'A'. The 2D linkage's reference point 'B' is positioned relative to 'A' by a fixed vector. The theta_A rotation occurs around the global Y-axis passing through 'A'.
-
show.py:- Simulates the 2D kinematics of the 4-bar linkage (BCDE) and the extended point F.
- Calculates the positions of all joints for a range of
theta_driveangles (0° to -30°). - Plots the trajectories of points B, D, and F.
- Displays snapshots of the linkage configuration at various
theta_driveangles.
-
visualize_thumb_3d.py:- Takes the 2D linkage model from
show.py. - Introduces a global coordinate system with origin A.
- Defines the initial position of point B relative to A (
VEC_A_to_B). - Simulates two degrees of freedom:
theta_drive: Internal angle of the 4-bar linkage (0° to -30°).theta_A: Rotation of the 2D linkage plane around the global Y-axis (0° to -90°).
- Calculates the 3D coordinates of all joints (B, C, D, E, F) for a grid of
theta_Aandtheta_driveangles. - Prints the 3D coordinates of the joints for 5 specific snapshot configurations.
- Generates a 3D plot showing:
- The global origin A.
- The workspace of point F as a continuous surface.
- Snapshots of the complete 3D linkage at the 5 specified configurations.
- Takes the 2D linkage model from
-
Reference Images (Conceptual - Not part of the codebase execution but provide context for the mechanism design):
Angles4Bar.jpg(Assumed to define linkage parameters and fixed angles used inshow.py)2D-1DOF-ThumbFullRangeOfMotion.jpg(Assumed to illustrate the 2D motion simulated byshow.py)
- Python 3.x
- The following Python libraries:
numpymatplotlibscipy
You can install these libraries using pip:
pip install numpy matplotlib scipy-
2D Simulation (
show.py): To run the 2D simulation and see the planar motion of the linkage:python show.py
This will generate two plots: one showing the trajectories of points B, D, and F, and another showing snapshots of the linkage.
-
3D Visualization (
visualize_thumb_3d.py): To run the 3D visualization and see the workspace of point F and 3D linkage snapshots:python visualize_thumb_3d.py
This will first print the 3D coordinates of the joints for 5 specific configurations to the console. Then, it will display a 3D plot showing the workspace of point F as a surface, the linkage snapshots, and the global origin A.
- 2D Kinematic Solver: Utilizes
scipy.optimize.least_squaresto solve the loop closure equations for the 4-bar linkage. - Parametric Motion: Simulates motion based on one (in 2D) or two (in 3D) driving angles.
- Trajectory Plotting: Visualizes the path of key points in 2D.
- Linkage Snapshots: Shows the configuration of the entire linkage at specific angle increments in both 2D and 3D.
- 3D Workspace Generation: Calculates the reachable space for point F under two degrees of freedom.
- Surface Visualization: Plots the 3D workspace of point F as a continuous surface.
- Coordinate Transformation: Transforms 2D linkage coordinates into a 3D global frame with rotation.
- Core Linkage: A 4-bar planar linkage consisting of points B, C, D, and E.
- Link lengths:
L_CB,L_EB,L_ED,L_CD. - Fixed angles:
Theta_CB(angle of link CB relative to a fixed direction in the 2D plane),Lambda(angle within link EB).
- Link lengths:
- Extended Point: Point F is defined by a triangular linkage DEF with fixed lengths
L_FDandL_FE. - Degrees of Freedom (for 3D visualization):
theta_drive(internal to the 2D linkage): Controls the angle of the input link for the 4-bar mechanism. Ranges from 0° to -30°.theta_A(global rotation): Rotates the plane containing the 2D linkage around the global Y-axis. Ranges from 0° to -90°.
- Global Frame: Point A is at the origin (0,0,0). Point B is initially offset from A by
VEC_A_to_B = [-67.597, 51.149, 3.122]mm before anytheta_Arotation.