afr2903 / FrED-factory

Tec de Monterrey's FrED factory 3rd generation
4 stars 1 forks source link

xArm movements automation #18

Closed afr2903 closed 6 months ago

afr2903 commented 6 months ago

Automation of the xArm pick and place trajectories using the gripper developed and tested on #12.

These are the subdevelopments needed:

afr2903 commented 6 months ago

Arm states

A dictionary, similar to GRIPPER_STATES, called ARM_STATES was created to store joints or axis positions, as well as the speed for each movement:

ARM_STATES = {
    # [x, y, z, roll, pitch, yaw, speed]
    "HOME": [0, -70, -20, 0, 90, 0, 30],
    "BEFORE_PICK_ARDUINO": [78.9, -5.4, -17, -5.8, -17, 82.1, 30],
    "PICK_ARDUINO": [51.3, 427.3, 171.5, -143.1, -0.1, -5.7, 20],
    "AFTER_PICK_ARDUINO": [44.6, 375.8, 240.8, -136.6, -0.1, -6.5, 30],
    "BEFORE_PLACE_ARDUINO": [50, 12.5, -37.7, -2, 25.5, 52, 30],
    "PLACE_ARDUINO": [260.3, 311.5, 129, 179.5, 1.2, 0.5, 30],
    "AFTER_PLACE_ARDUINO": [260.3, 311.5, 145, 179.5, 1.2, 0.5, 30],
}

The number of values in both cases is 6, and you should specify the desired target movement joints or axis, in the state machine when calling the send_arm_state() function:

self.send_arm_state(self.current_state, lineal=True) # Set the flag lineal to True for lineal movements

The function will then set the specific movement based on the flag:

def send_arm_state(self, state, lineal=False):
    """Send the data to the xArm"""
    x, y, z, roll, pitch, yaw, speed = self.ARM_STATES[state]
    print(f"Sending arm to state: {state}")
    if lineal:
        self.arm.set_position(x=x, y=y, z=z, roll=roll, pitch=pitch, yaw=yaw, speed=speed, wait=True)
    else:
        self.arm.set_servo_angle(angle=[x, y, z, roll, pitch, yaw], speed=speed, wait=True)
afr2903 commented 6 months ago

Using tts API, static files with speech feedback were developed

afr2903 commented 6 months ago

There is now a working implementation but should be refactored first to continue with the remaining Automation steps. Currently there is ready:

Those are not always stable due to the environment inconsistency, but I know how to record again. The refactorization will focus in that issue.