You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
correct way to specify driver for LargeMotor? #227
class LargeMotor(Motor):
"""
EV3 large servo motor
"""
SYSTEM_CLASS_NAME = Motor.SYSTEM_CLASS_NAME
SYSTEM_DEVICE_NAME_CONVENTION = '*'
def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, name_exact=False, **kwargs):
super(LargeMotor, self).__init__(address, name_pattern, name_exact, driver_name=['lego-ev3-l-motor'], **kwargs)
driver_name set to 'lego-ev3-l-motor' and driver_name is not accepted by LargeMotor.init. How does one overwrite the driver_name? You cannot pass it via kwargs, if you do python barfs because we've passed driver_name twice to Motor.init. I need to set it to 'lego-nxt-motor' for my BrickPi.
Looks like that's just an error; the driver name for the LargeMotor should allow for both NXT and EV3 motors. The intent is that this is not changeable from the user's perspective, but nonetheless the default is wrong in this case. We should just be able to update this line in the spec as well as any other instances of this that may have popped up (I can't think of any right now) and re-run autogen.
I think the default setting is ok, the problem is that the LargeMotor init cannot be passed the driver_name. I've never dug into the autogen side of ev3dev-lang-python though, are the init params also somewhere in the spec?
See this line. That line includes a comment which begins one of the auto-generated blocks, and there is an accompanying one after the LargeMotor class which ends the block. So, that whole thing is generated by a template.
The goal here is that it's easy to make changes to common code (despite the developer's bets efforts to minimize that code) and update everything together. It also significantly decreases the risk of mistakes causing odd behavior that is hard to track down: everything is deliberate and procedural.
If you have cloned this repo with all its submodules, you should just be able to edit the ev3dev-lang/spec.json file and then run ev3dev-lang/autogen.js from the root of the Python repo. It should update everything for you. You can use the git diff to see what was changed but keep in mind that any changes you've made to those special blocks in your local copy will be reset. IIRC, you don't need to pass it any parameters, however you will need Node.js installed.
If you make a change and like it, check out the develop branch in the ev3dev-lang submodule and then commit your changes on that branch and open a PR for them.
Oh, wait... I know why I am not hitting this problem. It's because my NXT motor is being detected as an EV3 motor (lego-ev3-l-motor). @dlech is that expected?
NXT motor has separate class both in specification and in the language bindings.
Ah, that makes sense. I completely forgot that we had a separate class! Although honestly, I'm not sure why we have it separate: It would make more sense if they were both controlled by the basic motor class.
Could be your version of the library is older than #216
Nope, I'm seeing this with direct sysfs attribute access from the shell.
On a somewhat related note, have any of you used a brickpi? I built a lego digitial clock that I've had on my desk at work for 2+ years (plugged in the entire time) and it burned up two of the motors :(
LargeMotor, MediumMotor, and NxtMotor are all just inherit from Motor and do not add any extra functionality besides providing the correct driver names to the constructor. If one needs a universal class, one can just use Motor with appropriate address or driver name directly.
Isn't the NXT motor the same as an EV3 large motor in every aspect but hole placement/shape (and possibly build quality)? i.e. There is no difference in tacho measurements or any other driver capabilities. For that reason, it seems to me that it would make more sense for a LargeMotor to also work with NXT motors -- that way you can easily differentiate between "large" and "medium" motors while still having your code function with NXT motors.
@WasabiFan stick to EV3 :) I've been experimenting with pistorms, brickpi and EVB but none of them are as reliable and easy to use as the EV3 brick is.
Activity
WasabiFan commentedon Oct 6, 2016
Looks like that's just an error; the driver name for the
LargeMotorshould allow for both NXT and EV3 motors. The intent is that this is not changeable from the user's perspective, but nonetheless the default is wrong in this case. We should just be able to update this line in the spec as well as any other instances of this that may have popped up (I can't think of any right now) and re-run autogen.dwalton76 commentedon Oct 6, 2016
I think the default setting is ok, the problem is that the LargeMotor init cannot be passed the driver_name. I've never dug into the autogen side of ev3dev-lang-python though, are the init params also somewhere in the spec?
WasabiFan commentedon Oct 6, 2016
See this line. That line includes a comment which begins one of the auto-generated blocks, and there is an accompanying one after the
LargeMotorclass which ends the block. So, that whole thing is generated by a template.The goal here is that it's easy to make changes to common code (despite the developer's bets efforts to minimize that code) and update everything together. It also significantly decreases the risk of mistakes causing odd behavior that is hard to track down: everything is deliberate and procedural.
If you have cloned this repo with all its submodules, you should just be able to edit the
ev3dev-lang/spec.jsonfile and then runev3dev-lang/autogen.jsfrom the root of the Python repo. It should update everything for you. You can use the git diff to see what was changed but keep in mind that any changes you've made to those special blocks in your local copy will be reset. IIRC, you don't need to pass it any parameters, however you will need Node.js installed.If you make a change and like it, check out the
developbranch in the ev3dev-lang submodule and then commit your changes on that branch and open a PR for them.WasabiFan commentedon Oct 6, 2016
Actually, I'm a bit confused... for me, the
LargeMotorclass already works with NXT motors. I don't have time to look into it now though.dwalton76 commentedon Oct 6, 2016
Thanks for the pointers...I'll futz around with it. I have the same basic problem when using PiStorms though because the driver that is loaded is
but we are looking for lego-ev3-l-motor so it thinks the motor isn't connected
WasabiFan commentedon Oct 6, 2016
Oh, wait... I know why I am not hitting this problem. It's because my NXT motor is being detected as an EV3 motor (
lego-ev3-l-motor). @dlech is that expected?ddemidov commentedon Oct 6, 2016
NXT motor has separate class both in specification and in the language bindings. So it should work with
ddemidov commentedon Oct 6, 2016
The motor was not listed in documentation. c1c80ad fixes this: http://python-ev3dev.readthedocs.io/en/latest/motors.html#nxt-servo-motor
ddemidov commentedon Oct 6, 2016
@WasabiFan,
Could be your version of the library is older than #216
WasabiFan commentedon Oct 6, 2016
Ah, that makes sense. I completely forgot that we had a separate class! Although honestly, I'm not sure why we have it separate: It would make more sense if they were both controlled by the basic motor class.
Nope, I'm seeing this with direct sysfs attribute access from the shell.
dwalton76 commentedon Oct 6, 2016
Ah thank you @ddemidov I had not noticed there was a different motor class for NXT motors...that is the solution I was looking for.
I'm fine if we close this ticket
dwalton76 commentedon Oct 6, 2016
On a somewhat related note, have any of you used a brickpi? I built a lego digitial clock that I've had on my desk at work for 2+ years (plugged in the entire time) and it burned up two of the motors :(
WasabiFan commentedon Oct 6, 2016
I think I am going to open an issue to discuss if we actually want to keep that extra class. Right now though, this issue can be closed I think.
@dwalton76 No, I've never used a BrickPi or any of the other extension boards... Just the EV3. Although I do have some RasPis and a BeagleBone Black.
ddemidov commentedon Oct 6, 2016
LargeMotor,MediumMotor, andNxtMotorare all just inherit fromMotorand do not add any extra functionality besides providing the correct driver names to the constructor. If one needs a universal class, one can just useMotorwith appropriate address or driver name directly.WasabiFan commentedon Oct 6, 2016
Isn't the NXT motor the same as an EV3 large motor in every aspect but hole placement/shape (and possibly build quality)? i.e. There is no difference in tacho measurements or any other driver capabilities. For that reason, it seems to me that it would make more sense for a LargeMotor to also work with NXT motors -- that way you can easily differentiate between "large" and "medium" motors while still having your code function with NXT motors.
ddemidov commentedon Oct 6, 2016
If that is the case, then it does make sense to merge large and nxt motor classes.
ddemidov commentedon Oct 6, 2016
Both EV3 and NXT motors are now covered by the
LargeMotorclass.dlech commentedon Oct 6, 2016
http://philohome.com/motors/motorcomp.htm
The differences are slight, but there are some differences. EV3 motor has slightly more torque and goes slightly faster.
I'm not saying you shouldn't merge the classes, just pointing out the differences.
dwalton76 commentedon Oct 6, 2016
@WasabiFan stick to EV3 :) I've been experimenting with pistorms, brickpi and EVB but none of them are as reliable and easy to use as the EV3 brick is.