-
Notifications
You must be signed in to change notification settings - Fork 197
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
DS402: Homing fails depending on power state, unnecessary state changes #244
Comments
Created PR #245 with some generic clean-up changes, which are hopefully less controversial than the things mentioned here. |
Thanks @af-silva for merging the changes so far, #245, #247 and #248. I will push some PRs with the above mentioned additional changes piecewise, just so we have the code available for discussion. In general, we need to be aware of breaking changes for previous users. But as far as I can see, the code was in pretty rough shape and I doubt many people had been relying on its current quirks. In any case, if the proposed new behavior will be accepted, a big warning for in the change log would be in order I suppose. Or what's your general stance on backwards compatibility regarding the DS402 implementation? |
Opened #249 to fix the main issue described here. |
Other changes to streamline what happens during operation mode switching are proposed in #251. |
Hi @acolomb, Thanks for the time reviewing and improving the code ;) Every contribution and discussion helping improving this library and the DS402 profile is welcome, furthermore, getting the library and the DS402 profile to a true library standard (i.e., not depending on manufactures bells and whistles) is awesome.
Give a fare warning and break things if they improve the usage, stability and maintainability of the code base.
Not at all, like a said this was due to my specific use case and was ported here. |
Thank you for reviewing :-)
Quite similar to my case--I am currently working on a project in $day_job where we use eight drive controllers from Nanotec with this library. So I have something to test the changes with and my application code actually relies on the changes I proposed here (see https://github.com/acolomb/canopen/tree/proposed). Each change is tested on that setup and considering that Nanotec seems to follow the DS402 standard quite closely, I assume it should work for other manufacturers as well. Have some other DS402-supporting hardware, but not in active use currently. So if anything seems unclear or questionable whether it works, I can offer specific testing. However most changes are more of a "don't do it all in the library, allow some interaction with the app in between" nature. That's where application compatibility will break, but not relying on different drive behavior.
Then I look forward to some comments on the various PRs :-)
I have a commit ready for this, but it would conflict with #250 and is therefore based off that. Either I wait for that to get merged or we add the other change to it. Refer to my branch mentioned above to see the desired end result. |
@af-silva I hope you're not drowning in my flood of DS402-related pull requests :-) I tried to base them on master as far as possible, so you can pick whichever you want to review / merge first. But there will inevitably be merge conflicts at some point. Feel free to ping me to get those fixed, or refer to my "proposed" branch for the "correct" resolution. Looking forward to getting this module in really good shape, and thanks again for your great ground work! |
The proposed |
@acolomb Sorry for not get back to you sooner. I'm will try to check and merge your changes during this week. |
…251) * ds402: Keep target values on operation mode change. As the comment already stated, clearing the target values should possibly happen before switching to the OPERATION ENABLED state, to avoid unexpected movements. So doing that when actually leaving that state is mostly useless. Some legitimate use cases even require switching the operation mode while in OPERATION ENABLED, e.g. switching between Profile Position and Profile Velocity. This change does not allow that, but at the very least will avoid the need to reset target values again. * ds402: Keep power state on operation mode change. Some legitimate use cases require switching the operation mode while in OPERATION ENABLED, e.g. switching between Profile Position and Profile Velocity. If an application or specific controller needs the transition from OPERATION ENABLED to SWITCHED ON during operation mode changes, that should be handled outside this library, and is easy enough to do. On the other hand, having it inside the op_mode setter prevents the above mentioned use-case. * ds402: Improve logging in op_mode setter. Do not generate a log message about the changed operation mode when it actually failed. Use a consistent style for the TypeError message formatting.
@christiansandberg I purpose a new version to include the changes purposed by @acolomb. What do you think? |
@af-silva Thanks for taking time to review and merge. Unfortunately there were some faulty merge commits which I have now corrected in #265. Sorry, I could not avoid all conflicts when trying to separate changes into multiple PRs. I honestly thought there would be more discussion about the individual changes... Next time just ping me when there's a conflict, I will then rebase or merge from master. Better to go slowly than having conflicts unnoticed 😉
I'm not sure what you mean, is there some Roadmap documentation? Regarding my proposed changes, the only missing piece now is #264, which I have also tested on hardware.
You mean the documentation? I took care of the "Device profiles" page, but there was not much of an example for the p402 code. Knowing what the standard is supposed to do and now having the I still don't know where we should put the incompatibility note / warning explaining how the application code needs to adapt for the next release. @christiansandberg any preferred place or existing file / wiki / ...? |
Hi @acolomb, ok that's set, I resolved the merge conflicts but didn't notice that parts of the code in other commits where being lost ... sorry. Regarding the discussion, a looked at each of the commits and everything seemed right and a like your design decisions and organization, the code is cleaner and more maintainable, and like you said, it needs more work out of the library to get things working but also covers more use cases than before (it was a bit tailored to my needs and I try to be agnostic but the time was short). Also, I don't have access to hardware right now to validate, so I trust your judgement. By roadmap I meant the overall implementation/changes you are planing, maybe it should be better to release a new version where the warning of breaking changes to ds402 was present. Documentation on code should suffice, but if you have some working example on how to extend and use the ds402 you could also put it on the docs... it's just a thought, you are contributing already in much needed changes. Last, the PR with changes to the state machine i will have a closer look and share my thought, I have to revisit the documentation for the ds402. Thanks, |
Sorry for not being involved in the discussions, but I have no clue about any profiles so you seem to have it under control. Great work both of you! 👏 Are the changes big enough to warrant a new major release (2.0)? If there is a risk that behavior will change for some people I think it is best to follow semantic versioning rules and try to explain the major differences in the release notes. @acolomb could you write a proposal for what we should write? |
As you may have guessed, I'm also scratching my own itch mainly, but trying to give back to the community by going the extra mile. 😉 So some more needed changes may possibly come up, but with the PRs so far I consider it usable and good enough for many purposes. No immediate plans for a further roadmap. Also my application is rather complex with eight drives involved and therefore not many script-style examples for easy consumption in the documentation. It's not a revolutionary change where I'd have thought of bumping the major version, as it just concerns a small part of the code. But you're right that proper semantic versioning would require the bump, unless we considered the DS402 profile as unofficial and unsupported icing on the cake until now. Either way we need a description of the breaking changes, so I'll try to come up with something in the days ahead. |
Sorry it took a while longer, but here's my suggestion for a NEWS entry (wherever we may put that):
Once we are certain where this should be documented, I will gladly adjust the formatting accordingly. While writing it up, I noticed a bug which will be fixed by #277. |
Great work @acolomb, for me is a go. |
Status of this issue? PR is merged. Will close it for now. |
I think all concerns have been addressed, thus fine with closing. |
The
BaseNode402.homing()
method tries to enter state SWITCHED ON upon entry. I think that's unnecessary, the application should handle these transitions. But more importantly, it actually fails in many cases, namely if the previous state is SWITCH ON DISABLED, the default power-up state of most devices. That's because there is an automatic way to reach OPERATION ENABLED over multiple intermediate steps, but the library does not know how to reach SWITCHED ON from any other state than OPERATION ENABLED or READY TO SWITCH ON. In addition, setting theop_mode
property will already change to SWITCHED ON only if coming from OPERATION ENABLED (which is usually a good idea to avoid unexpected movement).So I propose to just leave out that initial state switching, but wanted to discuss here first because it will probably break some people's application on upgrades. Note that switching the operation mode to HOMING is actually safe in any power state, at least on devices I encountered.
Another change I propose is not restoring the previous operation mode, at least as an option. Just needless bus traffic and delay in case the next operation mode must be decided by the application anyway. So I would add an optional argument with the default value
restore_op_mode=False
. Anyone opposed?Same goes for restoring the power state after switching the operation mode. Not really necessary and in case of
homing()
it will even cause additional delays by switching back and forth. Leaving OPERATION ENABLED when switching modes should also be optional, because there are valid applications where e.g. Profile Velocity and Profile Position need to be switched during operation without delay.I will PR any agreed upon changes, so this issue is just for tracking and finding consensus.
The text was updated successfully, but these errors were encountered: