Skip to content

Separate GyroBalancer drive control loop from balance loop#432

Merged
dwalton76 merged 2 commits intoev3dev:developfrom
gregcowell:gyrobal
Jan 11, 2018
Merged

Separate GyroBalancer drive control loop from balance loop#432
dwalton76 merged 2 commits intoev3dev:developfrom
gregcowell:gyrobal

Conversation

@gregcowell
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Collaborator

@dwalton76 dwalton76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ev3dev/control/GyroBalancer.py Outdated
# File I/O functions
########################################################################
# Constants
RAD_PER_DEG = 3.14159265/180
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t this assume LargeMotor is in use? Maybe make this dynamic based on the motor class that is being used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

@dwalton76
Copy link
Copy Markdown
Collaborator

PS
Supporting motors other than LargeMotor isn’t super important to me, feel free to ignore those comments if you want.

@gregcowell
Copy link
Copy Markdown
Member Author

Would be handy to catch SIGTERM and SIGINT and have those set stop_balance.

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.

you could do “from math import pi” and use “pi” here

Yep, done.

Supporting motors other than LargeMotor isn’t super important to me, feel free to ignore those comments if you want.

Thanks @dwalton76. I think I'll leave it with just LargeMotor support at least for now.

@WasabiFan
Copy link
Copy Markdown
Member

@dwalton76 Can you take a quick look at this and confirm it's good to go?

@dwalton76 dwalton76 merged commit ee75c5c into ev3dev:develop Jan 11, 2018
@gregcowell gregcowell deleted the gyrobal branch January 12, 2018 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants