Results 1 to 5 of 5

Thread: Attempting to make simple script to move the motor to angles between 0 and 360

  1. Question Attempting to make simple script to move the motor to angles between 0 and 360

    Hey all,

    I've found this nifty little script and have decided to adjust it so that it fits the dynamixel model I am using (XM540-W270-R) https://github.com/cckieu/dxl_control.

    I've adjusted the control table of the script accordingly (since the script provides the control table for the AX12 model). Afterwards, I run the the script which requires the user to input the desired position in which case it ranges from 2048-4095 (no idea why that's the case but it clearly states so in the documentation and the dynamixel wizard)

    Below are images for the code output (error received) and an image confirming the position are correct

    https://imgur.com/a/CEBGMKn

    Below is the code that enables the motor to set a new position

    Code:
        def set_position(self, dxl_goal_position):
            """Write goal position."""
            self.set_register2(ADDR_X_GOAL_POSITION, dxl_goal_position)
            print("Position of dxl ID: %d set to %d " %
                  (self.id, dxl_goal_position))
    And here is the code that asks the user for the input and calls set_position

    Code:
    def user_input():
        """ Check to see if user wants to continue """
        ans = input('Continue? : y/n ')
        if ans == 'n':
            return False
        else:
            return True
    
    
    def test_pos(motor_object):
        bool_test = True
        while bool_test:
            motor_object.get_position()
            # desired angle input
            input_pos = int(input("input pos: "))
            motor_object.set_position(input_pos)
            bool_test = user_input()
    
    test_pos(my_dxl)
    I'd appreciate any help, thanks!

  2. #2
    Join Date
    Sep 2010
    Location
    ಠ_ಠ
    Posts
    2,313
    Images
    27
    Rep Power
    278

    Re: Attempting to make simple script to move the motor to angles between 0 and 360

    The PROTOCOL_VERSION must be set to 2.0.
    The BAUDRATE must match the setting shown in Dynamixel Wizard.
    The MAX_POS_VAL = 1023 must be changed to MAX_POS_VAL = 4095.

    I did not look closely enough in the dxl_control.py file to catch any other issues.
    Please pardon the pedantry... and the profanity... and the convoluted speech pattern...
    "You have failed me, Brain!"
    [git][mech][hack]
    gives free advice only on public threads

  3. Re: Attempting to make simple script to move the motor to angles between 0 and 360

    Oh damn, sorry I should have mentioned that I adjusted all of those parameters prior, I even set up the control table to reflect the X series (model that I am using).

    I tested it out by enabling the LED lights via script and that worked just fine but the torque seems to be an issue.

    What I am trying to do is simply change the position from 270 degrees to 90 and 90 to 270.

  4. #4
    Join Date
    Sep 2010
    Location
    ಠ_ಠ
    Posts
    2,313
    Images
    27
    Rep Power
    278

    Re: Attempting to make simple script to move the motor to angles between 0 and 360

    argh. again? That library/example does not indicate what version of the SDK it is designed around or which one you are using. Older SDK versions do not necessarily support the DXL2.0 protocol or newer X-series servos.

    The Robotis example (http://emanual.robotis.com/docs/en/s...on-protocol-20) imports a different library name and uses a different collection of parameters for each command.
    Please pardon the pedantry... and the profanity... and the convoluted speech pattern...
    "You have failed me, Brain!"
    [git][mech][hack]
    gives free advice only on public threads

  5. Re: Attempting to make simple script to move the motor to angles between 0 and 360

    Alright, so I went ahead and attempted to run the read write protocol again, making sure that all the values matched my dynamixel model.

    Prior to actually running the torque there are 3 if condition to make sure the port is open, the baud rate is changed and the torque is enabled, it keeps failing for the third condition returning the following error

    Code:
    [TxRxResult] There is no status packet!
    It seems that quite a few people have run into the same problem, but there solutions does not seem to help me, below are the pre-configured setting for everything, and I made sure everything matches the model I am using http://emanual.robotis.com/docs/en/d...le-description

    Code:
    # Control table address
    ADDR_PRO_TORQUE_ENABLE      = 64               # Control table address is different in Dynamixel model
    ADDR_PRO_GOAL_POSITION      = 116
    ADDR_PRO_PRESENT_POSITION   = 132
    
    # Protocol version
    PROTOCOL_VERSION            = 2.0               # See which protocol version is used in the Dynamixel
    
    # Default setting
    DXL_ID                      = 1                        # Dynamixel ID : 1
    BAUDRATE                    = 1000000            # Dynamixel default baudrate : 57600
    DEVICENAME                  = 'COM5'    
    
    TORQUE_ENABLE               = 1                                      # Value for enabling the torque
    TORQUE_DISABLE              = 0                                      # Value for disabling the torque
    DXL_MINIMUM_POSITION_VALUE  = 10                            # Dynamixel will rotate between this value
    DXL_MAXIMUM_POSITION_VALUE  = 4000                             
    DXL_MOVING_STATUS_THRESHOLD = 20                          # Dynamixel moving status threshold
    
    index = 0

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Similar Threads

  1. Question(s) RX-28 doesn't move
    By Harber in forum DYNAMIXEL & Robot Actuators
    Replies: 2
    Last Post: 06-27-2018, 02:13 AM
  2. Replies: 1
    Last Post: 03-23-2015, 03:50 PM
  3. Question(s) com port via VB Script - help needed
    By cbrooks999 in forum Software and Programming
    Replies: 5
    Last Post: 01-29-2015, 07:43 AM
  4. Attempting to set up Pypose for a Quad
    By Kenvs in forum Arbotix, Microcontrollers, Arduino
    Replies: 14
    Last Post: 08-18-2013, 09:53 PM
  5. Question(s) Advise needed for simple DC motor control project
    By Wicklonious in forum Robotics General Discussion
    Replies: 4
    Last Post: 03-20-2009, 03:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •