MeArm Connect4 Simulation
The project consists of the development of an end-to-end physics simulator of a robotic arm (MeArm) capable of playing Connect Four against a human. The system leverages the PyBullet physics engine for a realistic simulation of gravity,collisions, and motor kinematics, combining it with a Minimax algorithm to ensure the robot chooses the best move.
Software
The architecture is modularized to separate the physics simulation from the user interface, preventing rendering freezes:
Interface and Logic (simulazione.py): Generates the interactive GUI, manages the game state, win checking, and the Minimax algorithm for calculating the robot's optimal move.
Physics and Environment (mearm_real_env.py): Uses a custom Gymnasium environment to load the robot's URDF model, handle the physics of the Connect Four grid, and coordinate the complex rod kinematics.
Multiprocessing: Leverages Python's multiprocessing library to asynchronously communicate between the GUI and the PyBullet environment at 60fps via shared variables (mp.Value) such as shared_target_col and shared_user_col.
Calibration
To ensure millimeter precision when inserting tokens without encountering inverse kinematics bugs, a pre-calculated calibration technique is used.
Electromechanical Teach & Play
Using the calibra.py script, a mapping was created where a safe configuration of angles (Base, Shoulder, Elbow) was saved for each of the 7 board columns.
Guide Holograms: During the execution of calibra.py, the system generates blue holographic cubes at the ideal release heights. Using dedicated sliders, you move the servomotors until a red block on the robot's gripper perfectly overlaps with the hologram.
Problem Solving
Grid Collisions
The simultaneous movement of the 3 axes (point-to-point) inevitably caused the arm to crash against the central grid.
Solution (State Machine and Clearance Plane): Development of a state machine to simulate the behavior of industrial arms. Movement is divided into rigid inverse "L"-shaped phases: LIFT_ARM (the arm rises while keeping the base still), ROTATE_TO_COL (the robot rotates safely flying over the grid), and DROP (token release), followed by the ROTATE_TO_HOME return before lowering again (LOWER_ARM).
Token Jams and Bouncing
The use of cubic blocks led to frequent jams in the partitions, while standard spheres tended to bounce or vibrate infinitely due to the physics engine.
Solution (Sphere Optimization and Friction): The tokens were replaced with perfect 13mm small spheres. Upon release, the sphere's dynamics are overridden via p.changeDynamics, setting elasticity to zero (restitution=0.0) and increasing rotational friction (rollingFriction=0.1, spinningFriction=0.1).
Conclusion
The project demonstrates the perfect synergy between UI development, physics calculation, and algorithmic logic,resolving the complexities of mechanical simulation through rigid state machines.
MeArm Connect4 Simulation
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Luca Fagioli
-
-
AudioLink – USB & Bluetooth LE Audio / Auracast Receiver with Balanced Line Outputs (nRF5340)
122 0 0 -
-
-
-
Émetteur Récepteur Optique Expérimental (communication UART ATtiny + fibre optique)
301 0 1 -
SmallOLED - Live PC Stats, Animated Clocks & Audio Visualizer
1279 0 3 -
"Talking Multimeter": Arduino-Based Speech Add-on for Multimeters with SCPI Protocol
732 0 1 -
Programmable Mist Maker - XIAO / QT PY Extension
3257 2 4







