Hello,
It’s me Barney again! This time I am writing about motors. The S.A.R.T team ran into an issue with the motors constantly overloading and not going to the desired speeds. After a little troubleshooting, the issue was found. The pyax12 library doesn’t support the new MX-12w motors. I decided to replace the library with PyPot, a library which supports a wide range of motors.
PyPot is quite a useful library it seems, it allows us to limit the angles of motors when programming an arm or just have the motor be used as wheels for the robot. This is done through a configuration file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | { "controllers": { "my_dxl_controller": { "sync_read": false, "attached_motors": ["front", "back"], "port": "auto" } }, "motorgroups": { "left": ["front_left", "back_left"], "right": ["back_right", "front_right"] }, "motors": { "front_left": { "orientation": "indirect", "type": "MX-12W", "id": 1, "angle_limit": [0.0, 0.0], "wheel_mode": true, "offset": 0.0 }, "front_right": { "orientation": "direct", "type": "MX-12W", "id": 2, "angle_limit": [0.0, 0.0], "wheel_mode": true, "offset": 0.0 }, "back_left": { "orientation": "indirect", "type": "MX-12W", "id": 3, "angle_limit": [0.0, 0.0], "wheel_mode": true, "offset": 0.0 }, "back_right": { "orientation": "direct", "type": "MX-12W", "id": 4, "angle_limit": [0.0, 0.0], "wheel_mode": true, "offset": 0.0 } } } |
The above JSON file is a configuration file made for the base of the Mk4. As you can see it is relatively simple and allows a fair bit of customisation in terms of motors. In particular, the angle limit feature would be very useful when using an arm. However, PyPot does not support all Dynamixel motors (Our arm uses xl430-w250-t motors). So S.A.R.T hasn’t been able to enjoy all the features, nonetheless PyPot is pretty neat.
We have updated our Servo_Party.py file for the MK4 to reflect the change in library:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #!/usr/bin/env python3 class ServoParty(): def __init__(self): # Import desired libraries when initialised. # Initialise the motors by using the mkIV configuration # Set all # Set shortname aliases from pypot.robot import from_json from contextlib import closing self.robot = from_json('mkiv.json') for m in self.robot.motors: m.compliant = False m.goal_position = 0 self.fr = self.robot.front_right self.fl = self.robot.front_left self.br = self.robot.back_right self.bl = self.robot.back_left self.last_left = 0; self.last_right = 0; self.speed_factor = 5; def move(self, left, right): # Move motors with designated speed, set last left and right (For compatibility, will be removed) self.fl.moving_speed = left; self.bl.moving_speed = left; self.fr.moving_speed = right; self.br.moving_speed = right; self.last_left = left; self.last_right = right; def move_left(self, left): # Move left motors with designated speed self.fl.moving_speed = left; self.bl.moving_speed = left; self.last_left = left; def move_right(self, right): # Move right motors with designated speed self.fr.moving_speed = right; self.br.moving_speed = right; self.last_right = right; def stop(self): # Stop all motors self.fl.moving_speed = 0; self.bl.moving_speed = 0; self.fr.moving_speed = 0; self.br.moving_speed = 0; def close(self): # Cleanly close program (PyPot) DOES NOT WORK with closing(from_json('mkiv.json')) as my_robot: self.robot.close() pass |
Unfortunately due to personal circumstances, I will be leaving S.A.R.T for the remainder of the year. I may be rejoining next year, however, it all depends how a few things go.
Featured image is not owned by S.A.R.T, Ownership belongs to the developer(s) of PyPot.