Separate GyroBalancer drive control loop from balance loop#432
Separate GyroBalancer drive control loop from balance loop#432dwalton76 merged 2 commits intoev3dev:developfrom gregcowell:gyrobal
Conversation
dwalton76
left a comment
There was a problem hiding this comment.
Would be handy to catch SIGTERM and SIGINT and have those set stop_balance. I have an example of this (it uses ‘signal’) in some of the demo robots....MINDCUBER and probably GRIPPER will do it.
| # File I/O functions | ||
| ######################################################################## | ||
| # Constants | ||
| RAD_PER_DEG = 3.14159265/180 |
There was a problem hiding this comment.
I’m not sure how many decimal places it goes but you could do “from math import pi” and use “pi” here
| dutyInt = int(round(duty*voltageCompensation)) | ||
| # On the EV3, "1% speed" corresponds to 1.7 RPM (if speed | ||
| # control were enabled). | ||
| RPM_PER_PERCENT_SPEED = 1.7 |
There was a problem hiding this comment.
Doesn’t this assume LargeMotor is in use? Maybe make this dynamic based on the motor class that is being used.
There was a problem hiding this comment.
Yes. the factor is 2.67 for medium motor.
| log.exception(e) | ||
| shutdown() | ||
| self.motor_left = LargeMotor(left_motor_port) | ||
| self.motor_right = LargeMotor(right_motor_port) |
There was a problem hiding this comment.
Allow the use to pass in the motor class to use but have it default to LargeMotor? I can’t think of any balancers that use medium motors but hey maybe we could build one :)
|
PS |
Good idea. I've added the relevant signal handlers. On a related note, I suspect that Brickman sends a SIGKILL when the back button is pressed and we can't have a handler for that.
Yep, done.
Thanks @dwalton76. I think I'll leave it with just LargeMotor support at least for now. |
|
@dwalton76 Can you take a quick look at this and confirm it's good to go? |
Please see issue #429. This facilitates the writing of simple scripts for controlling the movement of a GyroBalancer robot (eg.BALANC3R).
I recommend reviewing the new example scripts here first.
This pull request also adds the ability to enable debug mode. In debug mode, the GyroBalancer robot logs gyro reading and loop time statistics.