Repository navigation
Update GyroBalancer module - #421
Conversation
Is this actually a standalone executable? |
|
No, it’s still just a module like before. |
|
Thanks @WasabiFan, I've fixed the permissions on the file now. |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| # SOFTWARE. |
There was a problem hiding this comment.
If we are still using Laurens PID code (which it looks like we are) we should leave his copyright in place unless he has given us permission to remove it.
| duty = min(max(duty, -100), 100) | ||
| def eprint(*args, **kwargs): | ||
| """Debug print (https://stackoverflow.com/a/14981125).""" | ||
| print(*args, file=sys.stderr, **kwargs) |
There was a problem hiding this comment.
log.info(MESSAGE) or log.debug(MESSAGE) would seem better
|
|
||
|
|
||
| class GyroBalancer(LargeMotorPair): | ||
| class GyroBalancer(): |
There was a problem hiding this comment.
Would have it in inherit from object
There was a problem hiding this comment.
Even though Python 3 does not require it ? I thought that was only important for code that may be run under Python 2.
|
|
||
| # Convert this number to the speed in rad/s per "percent speed" | ||
| radPerSecPerPercentSpeed = degPerSecPerPercentSpeed *\ | ||
| radiansPerDegree |
There was a problem hiding this comment.
It seems like lines 140-191 could be moved up before the while True loop as most of these are either opening filehandles or defining constants. Especially the part where we reset() the two motors and set the mode to run_direct()...does that really need to happen everytime through the loop?
There was a problem hiding this comment.
Ignore this, I see now (this isn't the balancing loop)
There was a problem hiding this comment.
Yep, there was a misleading comment that confused things. I've removed it.
|
|
||
| # Wait for release and proceed to calibration and balancing | ||
| while self.touchSensor.is_pressed: | ||
| time.sleep(0.01) |
There was a problem hiding this comment.
You can use self.touchSensor.wait_for_bump() here (in place of lines 258->264)
|
Thanks @dwalton76. I've made all your requested changes. |
|
@dwalton76 , any more changes needed ? Happy to re-do from scratch if you had something else in mind. |
|
@gregcowell looks good, thanks! |
This module needs to be updated so that the demo script for the BALANC3R robot will work with the latest changes to the Python bindings. I have ported Laurens Valk's latest segway script. @dwalton76 did the previous port and I have followed the same style.