Skip to content

Update GyroBalancer module - #421

Merged
dwalton76 merged 2 commits into
ev3dev:developfrom
gregcowell:gyrobal
Oct 25, 2017
Merged

dwalton76 merged 2 commits into
ev3dev:developfrom
gregcowell:gyrobal

Conversation

@gregcowell

@gregcowell gregcowell commented Oct 21, 2017 •

Copy link
Copy Markdown
Member

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.

@WasabiFan

Copy link
Copy Markdown
Member

ev3dev/control/GyroBalancer.py 100644 → 100755

Is this actually a standalone executable?

@gregcowell

Copy link
Copy Markdown
Member Author

No, it’s still just a module like before.

@gregcowell

Copy link
Copy Markdown
Member Author

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.

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.

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.

Comment thread ev3dev/control/GyroBalancer.py Outdated
duty = min(max(duty, -100), 100)
def eprint(*args, **kwargs):
"""Debug print (https://stackoverflow.com/a/14981125)."""
print(*args, file=sys.stderr, **kwargs)

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.

log.info(MESSAGE) or log.debug(MESSAGE) would seem better

Comment thread ev3dev/control/GyroBalancer.py Outdated


class GyroBalancer(LargeMotorPair):
class GyroBalancer():

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.

Would have it in inherit from object

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

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.

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?

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.

Ignore this, I see now (this isn't the balancing loop)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, there was a misleading comment that confused things. I've removed it.

Comment thread ev3dev/control/GyroBalancer.py Outdated

# Wait for release and proceed to calibration and balancing
while self.touchSensor.is_pressed:
time.sleep(0.01)

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.

You can use self.touchSensor.wait_for_bump() here (in place of lines 258->264)

@gregcowell

Copy link
Copy Markdown
Member Author

Thanks @dwalton76. I've made all your requested changes.

@gregcowell

Copy link
Copy Markdown
Member Author

@dwalton76 , any more changes needed ? Happy to re-do from scratch if you had something else in mind.

@dwalton76

Copy link
Copy Markdown
Collaborator

@gregcowell looks good, thanks!

@dwalton76
dwalton76 merged commit a00032c into ev3dev:develop Oct 25, 2017
@gregcowell
gregcowell deleted the gyrobal branch October 25, 2017 22:25
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.

3 participants