Skip to content

Update auto-drive.py#250

Merged
WasabiFan merged 3 commits into
ev3dev:developfrom
DrClick:patch-2
Nov 8, 2016
Merged

Update auto-drive.py#250
WasabiFan merged 3 commits into
ev3dev:developfrom
DrClick:patch-2

Conversation

@DrClick

@DrClick DrClick commented Nov 7, 2016

Copy link
Copy Markdown
Contributor

fixed bugs in the code. is_pressed is a function, as well as proximity. Also when run_timed, you must set the speed not duty cycle. Thanks again for your work! You had as up and running and a great first day with ev3dev!

fixed bugs in the code. is_pressed is a function, as well as proximity. Also when run_timed, you must set the speed not duty cycle.
Comment thread demo/EXPLOR3R/auto-drive.py Outdated
while not btn.any():

if ts.is_pressed:
if ts.is_pressed():

@WasabiFan WasabiFan Nov 7, 2016

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.

This is actually something that changed in our most recent release, which is not included in the most recent ev3dev image by default. See https://github.com/rhempel/ev3dev-lang-python/releases/tag/0.8.0 for details on that release. If you'd like to upgrade, you can also find instructions on doing so in the README.

Comment thread demo/EXPLOR3R/auto-drive.py Outdated

for m, p in zip(motors, power):
m.run_timed(duty_cycle_sp=p*75, time_sp=t)
m.run_timed(speed_sp=p*750, time_sp=t)

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.

Good catch; I guess we didn't fix all cases of duty_cycle in the demos after we made that change in the library.

Comment thread demo/EXPLOR3R/auto-drive.py Outdated
# Sound backup alarm.
Sound.tone([(1000, 500, 500)] * 3)

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.

Is this whitespace consistent with what we have in other places? While we're here, we should normalize this.

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.

There should be no trailing spaces in the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can you explain the issue. This is a blank line, not sure I understand the objection

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.

@DrClick I think this looks good aside from the whitespace. If you can remove that (both here and two lines above it) I'd say it's ready!

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.

You're right, it has absolutely no effect on the code's functionality. I ask for those changes mainly because they make the diff easier to read and keep the file uniform. For example, if I find a new bug next week and want to use git's "blame" feature to figure out when this section of code was last modified, I would find that you were the last one to change the code, even though all you did was add some whitespace. Keeping those extraneous changes out of our commit history makes things like that significantly easier.

removed whitespace, reverted function calls to properties

@DrClick DrClick left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread demo/EXPLOR3R/auto-drive.py Outdated
# Sound backup alarm.
Sound.tone([(1000, 500, 500)] * 3)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can you explain the issue. This is a blank line, not sure I understand the objection

@WasabiFan WasabiFan merged commit a263ce9 into ev3dev:develop Nov 8, 2016
@WasabiFan

Copy link
Copy Markdown
Member

Thanks!

ir = InfraredSensor(); assert ir.connected
ts = TouchSensor(); assert ts.connected

print('Robot Starting')

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.

Since this is a demo, we could use this as an opportunity to demonstrate espeak functionality, and change the line to

Sound.speak('Robot starting').wait()

It will also be easier to notice when launched from brickman interface.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there a demo somewhere on how to vim a .sh file and chmod + x it so it can be launched? Or is there some other way to make these scripts executable on the brickman?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It not, it would be a valuable edition to the readme.

@ddemidov ddemidov Nov 8, 2016

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.

There could be something about it here:
https://sites.google.com/site/ev3python/putty

EDIT: wrong link

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.

Since this is a demo, we could use this as an opportunity to demonstrate espeak functionality, and change the line to

I can't say I'm particularly excited to talk at people every time they start his robot, but I suppose it could be a good way to help people discover this functionality.

Is there a demo somewhere on how to vim a .sh file and chmod + x it so it can be launched? Or is there some other way to make these scripts executable on the brickman?

I believe the README has a section on preparing Python files for execution.

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