|
Teleoperated Robot Hand
|
Directories | |
| src | |
This folder contians the platform.io project for the receiver in the project. The receiver is tasked with receiving flex readings from the transmitter and moving the motors to bend the finger(s) to match the user's movements.
There are 2 tasks for this project, the Receiver Task and the Controller Task. The Receiver Task is blocking waiting for the ESP-NOW callback to run meaning that data from the transmitter has arrived. The callback is made to be extermely fast and quick to ensure safe non critical behavior:
Since the transmitter is unicasting specifically to the MAC address of the receiver ESP32, we do not need to worry about setting up the MAC address like we did in the receiver.
Once having received data the Receiver Task converts the raw flex readings into potentiometer-space targets:
Each target is then sent to it's dedicated finger queue. Similar to the Transmitter Task, a Hand class is used to house all the queues.
The Controller Task implements a 2 state FSM:
Though before entering a state, the Controller reads from the encoders on each loop. There are rotary potentiometers attached to each motor that serve as encoder values. To read the current position of each motor, the potentiometers are connected to an 8 channel external ADC chip that communicates over I2C. We use the official Adafruit library for interfacing with this chip:
In the Homing state, each funger motor is driver towards a known home position
Once all the fingers are homed the system transition to Position Control state. During position control, the task performs non blocking reads of the latest target value from the finger queues:
For both Homing and Position Control, motor movement is calculated through a PID. Each finger/joint has its own PID that takes in the current potentiometer value and the target potentiometer value. There are 2 separate functions for running the PID in the Homing state versus the Position Control state. The Homing state only utilizes a P controller while the Position Control has a PID controller.
This distinction was made because when homing we only want to be around a certain threshold of potentiometer values to be home but we want more precise control when trying to match the user's motion.
The magnitude of the PID and P controller becomes the speed of the motor.
PID Controller:
P Controller:
while the direction comes from the sign of the output.