Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-code refactorization #20

Open
1 of 2 tasks
afr2903 opened this issue May 19, 2024 · 1 comment
Open
1 of 2 tasks

Low-code refactorization #20

afr2903 opened this issue May 19, 2024 · 1 comment

Comments

@afr2903
Copy link
Owner

afr2903 commented May 19, 2024

Refactorization of the main code implementation for easier use by mechatronic engineering students.

Goals:

  • Record positions within the same script
  • Setup and running detailed instructions
@afr2903
Copy link
Owner Author

afr2903 commented May 27, 2024

Record positions

This feature is possible using the xArm SDK methods. First, the arm is set to manual mode, until Enter is pressed. Alternatively, linear positions can be used to achieve the desired state.

def record_state(self, state):
    """Record a new state for the arm and gripper"""
    print(f"Recording state: {state}")
    self.arm.set_mode(2) # Joint teaching mode
    self.arm.set_state(0)
    print("The arm is now in MANUAL mode, press enter to record the position...")
    input()

Then, the user is guided by the terminal to save the desired state in joint or lineal movements:

    print("Do you want to record a joint or lineal position? (J/L)")
    movement_type = input()
    if movement_type.upper() == "J": # Joint position
        joint_position = self.arm.get_servo_angle()
        print("Joint position recorded, paste the following line in the ARM_STATES dictionary:")
        print(f"\"{state}\": [\"Y\", \"J\", {joint_position[1][0]}, {joint_position[1][1]}, {joint_position[1][2]}, {joint_position[1][3]}, {joint_position[1][4]}, {joint_position[1][5]}, 10],")
    
    elif movement_type.upper() == "L": # Lineal position
        print("Which is the desired TCP, board or wire gripper? (B/W)")
        desired_tcp = input()
        if desired_tcp.upper() == "B":
            self.arm.set_tcp_offset(BOARD_TCP)
        elif desired_tcp.upper() == "W":
            self.arm.set_tcp_offset(WIRE_TCP)
        else:
            self.arm.set_tcp_offset([0,0,0,0,0,0])
        lineal_position = self.arm.get_position()
        print("Lineal position recorded, paste the following line in the ARM_STATES dictionary:")
        print(f"\"{state}\": [\"Y\", \"L\", {lineal_position[1][0]}, {lineal_position[1][1]}, {lineal_position[1][2]}, {lineal_position[1][3]}, {lineal_position[1][4]}, {lineal_position[1][5]}, 10, \"{desired_tcp.upper()}\"],")

An element to add to the dictionary is displayed in the terminal to be copied and pasted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant