Skip to content

Doubt about Unregulated motors implementation #649

Closed

Description

@JakubVanek

Hi,

I am exploring how devices are handled in ev3dev and in this library and I noticed that unregulated motors should be handled differently. Currently, the port mode is switched to dc-motor. IMHO this is wrong: it is still an EV3 motor. By switching the port to the dumb mode you lose the ability to query the encoder position. Manual power-setting can be achieved with standard tacho-motor by running command run-direct and writing the power to duty_cycle_sp.

Regards,

Jakub

Activity

  1. JakubVanek commented on Feb 23, 2019

    @JakubVanek
    ContributorAuthor

    Hmm, it seems that it is more complicated. This is the way I see it:

    Original leJOS UnregulatedMotor can read out tacho values and is intended for direct PWM control. For example: I once wanted to create a "reading head" for a color sensor and wanted to control it directly [link]. I used UnregulatedMotor to do this.

    ev3dev-lang-java changes meaning of these APIs. UnregulatedMotor is instead intended for non-tacho motors and unregulated motor control is achieved through BaseRegulatedMotor. However, it also changes a meaning of this function, which is newly used for the switch: suspendRegulation(). The original behavior is even stated in the documentation for the new function:

    /**
    * Removes this motors from the motors regulation system. After this call
    * the motors will be in float mode and will have stopped. Note calling any
    * of the high level move operations (forward, rotate etc.), will
    * automatically enable regulation.
    * @return true iff regulation has been suspended.
    */

    Looking into leJOS sources, suspendRegulation() is equal to calling flt().
    However, in this library, no automatic reenabling is done, rather the motor switches to what effectively is the behavior of UnregulatedMotor on leJOS.

  2. JakubVanek commented on Feb 23, 2019

    @JakubVanek
    ContributorAuthor

    The problem I see with it is that UnregulatedMotor cannot read the tacho sensor, because the kernel doesn't try to read it, because it makes no assumptions about what is on the port, because it was configured to see the port as a dc-motor.

  3. JakubVanek commented on Feb 23, 2019

    @JakubVanek
    ContributorAuthor

    Then there is RCXMotor in leJOS. This is the equivalent of a dc-motor - the sysfs kernel device is even getting named like that: ev3-ports:outA:rcx-motor. Indeed, RCX motor has no way of reporting tacho values back, so this way it would be consistent.

  4. JakubVanek commented on Feb 23, 2019

    @JakubVanek
    ContributorAuthor

    TL;DR: the current UnregulatedMotor should be RCXMotor and instead the BaseRegulatedMotor logic behind suspendRegulation/regulationFlag should be in UnregulatedMotor. suspendRegulation should essentially call flt().

  5. jabrena commented on Feb 25, 2019

    @jabrena
    Member

    Hi @JakubVanek,

    The support is running fine for DC Motors, you have many examples in examples Repo. I don´t know the nature of this issue.

    If you have a doubt about the behaviour, post an example in the issue to review.
    Did you tests a DC Motor with your Brick?

    Juan Antonio

  6. changed the title [-]Unregulated motors are implemented incorrectly[/-] [+]Doubt about Unregulated motors implementation[/+] on Feb 25, 2019
  7. JakubVanek commented on Feb 26, 2019

    @JakubVanek
    ContributorAuthor

    Hi @jabrena,

    no, my doubt is about the API. The UnregulatedMotor is not supposed to be for DC Motors. RCXMotor is. In particular, leJOS UnregulatedMotor can read tacho count, while UnregulatedMotor in this library cannot.

    Regards,

    Jakub Vanek

  8. JakubVanek commented on Feb 26, 2019

    @JakubVanek
    ContributorAuthor

    There is also another reason why I'd like fix the API to be like on leJOS: because then UnregulatedMotors will not need to wait for a switch to dc-motor mode - they will be handled by the tacho-motor mode (+ see note below). RCXMotors will however still have the problem and this can be avoided only by udev, retry mechanism or a delay. RCXMotors will simply need to be flagged as problematic.

    suspendRegulation() in leJOS was intended to be like flt(). It was not related to UnregulatedMotor switching.

    Note: If and after #651 (comment) is implemented:

    I think that reading the port mode before writing it is the way to go. It should not be changed if it is in auto or tacho-motor mode, only when it is in a different mode. If the mode attribute is not readable, there is also a status attribute which should be.

    the permission denied issue will disappear for BaseRegulatedMotor descendants and the fixed UnregulatedMotor.

  9. jabrena commented on Feb 26, 2019

    @jabrena
    Member

    Please, lets me consider if it is a bug or not.

  10. self-assigned this
    on Aug 18, 2019
  11. added this to the v1.0.0 milestone on Aug 18, 2019
  12. jabrena commented on Sep 1, 2019

    @jabrena
    Member

    Current implementation is working fine for RCXMotor and EV3Motor as Unregulated motors.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions