Skip to content

Update demos for python3 - #205

Merged
dwalton76 merged 3 commits into
ev3dev:developfrom
dwalton76:develop
Sep 20, 2016
Merged

dwalton76 merged 3 commits into
ev3dev:developfrom
dwalton76:develop

Conversation

@dwalton76

Copy link
Copy Markdown
Collaborator

No description provided.

@dwalton76

Copy link
Copy Markdown
Collaborator Author

Some fixes for #204

Comment thread demo/lego_official_projects/TRACK3R.py Outdated
def fire_ball(self, state):
if state:
self.medium_motor.run_to_rel_pos(duty_cycle_sp=100, position_sp=3*360)
self.medium_motor.run_to_rel_pos(speed_sp=100, position_sp=3*360)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

duty_cycle_sp and speed_sp use different units of measurement, so you are also changing the effective speed here. For large motors you can multiply by 10 to get close enough. e.g. This should be speed_sp=100.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ah, did not realize that. What should I multiply by for medium motors?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

15 maybe?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

* jQuery UI Touch Punch 0.2.3
*
* Copyright 2011–2014, Dave Furfero
* Copyright 2011-2014, Dave Furfero

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The original - above was not an ascii character, the web server was unable to serve jquery.ui.touch-punch.min.js due to it containing a non-ascii character.

Comment thread ev3dev/auto.py
with open(filename, 'w') as fh:
fh.write(current_platform + '\n')

if current_platform == 'brickpi':

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These changes allow us to avoid import platform and running platform.machine() every time the user runs a program that imports ev3dev.auto. This saves us about 1s.

Comment thread ev3dev/core.py
import re
import stat
from os.path import abspath
from PIL import Image, ImageDraw

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With python3, this import takes 42s so only import when needed.

Comment thread ev3dev/helper.py
stop_mode_choices = (ev3dev.auto.Motor.STOP_COMMAND_COAST,
ev3dev.auto.Motor.STOP_COMMAND_BRAKE,
ev3dev.auto.Motor.STOP_COMMAND_HOLD)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These no longer exists

Comment thread ev3dev/helper.py
import time
import ev3dev.auto
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from http.server import BaseHTTPRequestHandler, HTTPServer

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

python2 vs. python3 change

Comment thread ev3dev/helper.py
else:
# Open as plain text and encode
with open(filename, mode='r') as fh:
self.wfile.write(fh.read().encode())

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

python2 vs. python3 change

@dwalton76
dwalton76 merged commit 9e74a6b into ev3dev:develop Sep 20, 2016
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