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

Support of multiturn mode for MX motors for suspended pypot creatures #223

Open
ThotAlion opened this issue Jan 20, 2017 · 3 comments
Open

Comments

@ThotAlion
Copy link

For suspended creatures (hung by a string) we would need to take advantage of the multi-turn mode of the MX motors so that we can stick a pulley on the motor rolling a string like a winch.
More generally : there are three modes : joint, wheel and multiturn.
For the joint mode, all is OK
For the wheel mode, set angle limit registers to 0 (not possible in the json since angle limits are converted)
For joint mode, set angle limits to the one you want
For multi-turn mode, set angle limits to 4095.
For multi turn mode, we should add two others properties : multi-turn offset and resolution divider.

I wanted to add it by myself but it is not so simple.

@pierre-rouanet
Copy link
Contributor

Hi @ThotAlion,

I never had the opportunity to play with the multi-turn mode and I don't really have MX motors around.

But let me know where you found the difficulties to add those features and I'll try to help. This would be a cool enhancement for pypot. Do not hesitate to open a WIP pull request where we could directly work and discuss this.

@montequie
Copy link

Hi, was it ever implemented?

@pierre-rouanet
Copy link
Contributor

No it's still an open issue. A few pointers to help out anyone willing to work on this:

  • As @ThotAlion pointed out, to enable multi turn mode you need to set a specific angle limit. This can be done here:

    def get_control_mode(self, ids):
    """ Gets the mode ('joint' or 'wheel') for the specified motors. """
    to_get_ids = [id for id in ids if id not in self._known_mode]
    limits = self.get_angle_limit(to_get_ids, convert=False)
    modes = ['wheel' if limit == (0, 0) else 'joint' for limit in limits]
    self._known_mode.update(zip(to_get_ids, modes))
    return tuple(self._known_mode[id] for id in ids)
    def set_wheel_mode(self, ids):
    """ Sets the specified motors to wheel mode. """
    self.set_control_mode(dict(zip(ids, itertools.repeat('wheel'))))
    def set_joint_mode(self, ids):
    """ Sets the specified motors to joint mode. """
    self.set_control_mode(dict(zip(ids, itertools.repeat('joint'))))
    def set_control_mode(self, mode_for_id):
    models = []
    for m in self.get_model(list(mode_for_id.keys())):
    if m.startswith('MX'):
    models += ['MX']
    elif m.startswith('SR'):
    models += ['SR']
    else:
    models += ['*']
    pos_max = [conv.position_range[m][0] for m in models]
    limits = ((0, 0) if mode == 'wheel' else (0, pos_max[i] - 1)
    for i, mode in enumerate(mode_for_id.itervalues()))
    self._set_angle_limit(dict(zip(mode_for_id.keys(), limits)), convert=False)
    self._known_mode.update(mode_for_id.items())
    and here:
    control_modes = {
    1: 'wheel',
    2: 'joint',
    }

  • Adding the two extra properties (offset and resolution divider) can be done at the end of the io.py file: https://github.com/poppy-project/pypot/blob/master/pypot/dynamixel/io/io.py by adding a new control with the correct spec from robotis support website. Such as in here:

    _add_control('drive mode',
    address=0x0A, length=1,
    access=_DxlAccess.readwrite,
    models=('MX-106', ),
    dxl_to_si=conv.dxl_to_drive_mode,
    si_to_dxl=conv.drive_mode_to_dxl)

This should be a good start!

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

No branches or pull requests

4 participants